how to route symfony urls and remove front controller from url

  apache, php, routes, symfony

i ve tried some methods to route my url

rootdirectory/src/Simplex/app.php
require __DIR__.'/../vendor/autoload.php';
use SymfonyComponentRoutingRoute;
use SymfonyComponentRoutingRouteCollection;

$routes = new RouteCollection();

$routes->add('ip',
          new Route('/ip',
                [
                    'IPAddress'   => "52.77.50.64",
                    '_controller' => 'ControllerController::getIPResponse',
                ]
            )
        );
$routes->add('home',
          new Route('/',
                [
                    'IPAddress'   => "52.77.50.64",
                    '_controller' => 'ControllerController::getIPResponse',
                ]
            )
        );

and

rootdirectory/front.php
require __DIR__.'/vendor/autoload.php';

use SymfonyComponentHttpFoundationRequest;

$globals = (Request::createFromGlobals())->getPathInfo();

$request = Request::create($globals);

$routes    = include __DIR__ . '/src/app.php';

$container = include __DIR__ . '/src/container.php';

$response  = $container->get('framework')->handle($request);

$response->send();

when i try to access myDomain.com/front.php/ip it works but when i try to use myDomain.com/ip it doesnt work.

I also worked on my .conf file and it pointing to my front controller.
i.e. if i go to myDomain.com/ it works .

I also checked symfony routing doc but i think they didnt give the solution for this.

I havent used .htaccess file

Source: Ask PHP

LEAVE A COMMENT