I need to include href to profile/edit in my view. Template engine is twig, so code look like this:
Edit profile
But i get exception:
An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "fos_user_profile" as such route does not exist.") in VputiUserBundle:ProfileShow:show.html.twig at line 4.
Please help, where is mistake?
First, debug your router
$ php app/console router:debug --env=[env]
And use the correct environment
If the route shows up, then you probably need to clear the cache
$ php app/console cache:clear --env=[env]
If the route doesn't show up, then whatever bundle that provides that route isn't being loaded correctly.
Also, if you're using a front-controller with debugging turned on, you can check the web debug toolbar.
The message tells it all. Route with name fos_user_profile does not exist.
I guess this route name comes from FOSUserBundle, so check that VputiUserBundle extends it properly.
The path('fos_user_profile') does not exist. It routes to #FOSUserBundle/Resources/config/routing/profile.xml. There you can find the actual usable routes, like:
Edit profile
Related
I'm starting to develop a project that will be quite big (hear lots of files) and I want to have an organization that's different from Symfony's default one: instead of having one dir for all my controllers, another for all my forms, etc, I want to have one dir per functionality, ie a directory for my homepage which will contain the controller, the templates, another dir for the blog page with the controller, forms and templates, and so on.
I tried what was explained in this (old) answer, and it didn't work : my routes weren't recognized, and a php bin/console debug:router showed they weren't listed anymore.
I feel I will have something to adapt in my routes.yaml file, which looks like this for now, and which explains why it doesn't work because it explicitely searches in the src\Controller directory:
controllers:
resource:
path: ../src/Controller/
namespace: App\Controller
type: attribute
I looked in the documentation I found, but I didn't find anything useful (I think I will have to remove the path and change it to something else, but I don't know what yet.
The above solutions are only for differentiating controller and template files. But For Entity, Events, and Forms it will not work.
It seems like you want to separate files for each module or functionality. For example, settings.yaml, controller, entity, forms, events, etc...
For that Symfony provides a Bundle feature. You can create a new Bundle in Symfony and use it as a separate feature. For more details please read this link
I installed SonataClassificationBundle and extend it on my App\Application folder. The documentation on the official website isn't clear Classification Bundle
I corrected all namespaces to point into my extended bundle. I cleared the cache without error and I run the server.
When I log into the profile, I get this exception :
An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "admin_app_sonataclassificationcategory_create" as such route does not exist.").
There is my sonata_classification:
sonata_classification:
class:
category: App\Application\Sonata\ClassificationBundle\Entity\Category
collection: App\Application\Sonata\ClassificationBundle\Entity\Collection
context: App\Application\Sonata\ClassificationBundle\Entity\Context
tag: App\Application\Sonata\ClassificationBundle\Entity\Tag
I detected the same problem with SonataUserBundle, but after promoting my user to ROLE_ADMIN, the problem was solved.
Can someone help?
Thank you
Solved again.
I just run :
composer update
I am following the instructions at https://symfony.com/doc/2.x/bundles/SonataAdminBundle/cookbook/recipe_custom_action.html to build a custom CRUDController in a Symfony/Sonata application.
When I look at the list view, I get the following error message:
An exception has been thrown during the rendering of a template
("Unable to generate a URL for the named route "clone" as such route
does not exist.").
Is there additional code needed in order to get the application to recognize my new route?
Ah -- I had to put my configureRoutes() definition in the admin class rather than the controller class. The documentation was wrong.
I know there is php app/console debug:router --show-controllers but it only show Controller::Action. Is it possible to list route names with controller class path ?
I'm afraid there is no really smart method to see all classes associated to controllers.
Profiler is listening FilterControllerEvent to find out a class, and it must be application to be run to fire this event.
But. Controllers you see after running php app/console debug:router --show-controllers has two formats: either something like VendorNameBundle:Task:get (and in this case it's obvious where to find controller, in VendorBundle/Controllers/TaskController) or it's, like in your case, is service's name. And in this case you can find a class by running
php app/console debug:container | grep sylius.controller.product
i want to get the "PublisherId" from my twig file.
it returns me an error ----An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "myBundle_publisher" as such route does not exist.")
I read the twig documentation and there it also write like how i write it.
Do anyone knows how i can solve this problem . Really stack here, can someone solve this problem, thanks in advanced.
The routes need to be imported to be active as any other routing resources (note the annotation type):
# import routes from a controller class
post:
resource: "#SensioBlogBundle/Controller/PostController.php"
type: annotation
More information about #Route