Category : routes

I want to match all paths for a specific host and redirect to a new one: redirect_from_host: path: /{uri}/ host: www.my-old-domain.com defaults: _controller: FrameworkBundle:Redirect:urlRedirect path: https://www.my-new-domain.com permanent: true This works for URL’s like www.my-old-domain.com/foo/ but doesn’t with: www.my-old-domain.com/foo/bar/ So I have to add more routing definitions like: redirect_from_host_2: path: /{uri}/{uri2}/ host: www.my-old-domain.com defaults: _controller: FrameworkBundle:Redirect:urlRedirect ..

Read more

I’m trying to pass some bool parameter in a route to generate (using generateUrl from symfony controller): $this->generateUrl(‘my_route’, [‘bool’ => true]); $this->generateUrl(‘my_route’, [‘bool’ => false]); The first one works fine, the second one throw an exception: Parameter "bool" for route "my_route" must match "[^/]++" ("" given) to generate a corresponding URL. Here is the defined ..

Read more

I have a problem with the images in symfony when the website is in production env. It says No route found for "GET /images/logo.png". I have set the full path , but it does not work. Does someone knows ho to fix it? (https://example.com/public/images/logo.png) Thank you 🙂 Source: Symfony..

Read more

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(); ..

Read more

I can’t display Api platform (127.0.0.1:8000/api) view when i have this inside my DefaultController.php : class DefaultController extends AbstractController { /** * @Route("/{reactRouting}", name="home", defaults={"reactRouting": null}) */ public function index() { return $this->render(‘default/index.html.twig’); } But when i remove it i can access /api but i can’t access my route from react (/login etc). Source: Symfony ..

Read more

I have the following annotation, so any route except the api, I wanna also exclude all the routes that start with /admin too I’m sorry I’m new to symfony and i also dont know much about regular expressions please someone help /** * @Route("/", name="homepage") * @Route("/{route}", name="vue_pages", requirements={"route"="^(?!.*api).+"}) */ Source: Symfony..

Read more

I’m brand new to Symfony and I’m just exploring the basics. I’ve created an extremely simple toy application to try out annotation routing, and I’m stumped by its behavior. I’ve modified no files in the clean install of Symfony 4.4.15, Flex, and annotations, and added only one, src/Controller/LoginController.php: <?php namespace AppController; use SymfonyComponentHttpFoundationResponse as HttpResponse; ..

Read more