I am new to symfony2. I am designing a form.
My action for submission is task_new. And my routing.yml is as follows:
task:
pattern: /task/
defaults: { _controller: AcmeTaskBundle:Task:new}
task_new:
defaults:{_controller:AcmeTaskBundle:Task:sub}
I want that after submission the form it should go to sub action. when i am running this code I am getting the following error:
Cannot import resource "C:\wamp\www\Symfony\src\Acme\TaskBundle/Resources/config/routing.yml" from "C:/wamp/www/Symfony/app/config\routing.yml".
What should I do?
While most configuration resources are files (e.g. YAML, XML, PHP), Symfony is able to load configuration from anywhere (e.g. a database or even via an external web service). The service container is built using a single configuration resource ( config/services.yaml by default).
Third-party bundle container configuration, including Symfony core services, are usually loaded using another method: a container extension. Internally, each bundle defines its services in files like you've seen so far. However, these files aren't imported using the import directive.
Loading the configuration normally starts with a search for resources, mostly files. This can be done with the Symfony\Component\Config\FileLocator: The locator receives a collection of locations where it should look for files. The first argument of locate () is the name of the file to look for.
The Symfony\Component\Config\Loader\LoaderResolver receives as its first constructor argument a collection of loaders. When a resource (for instance an XML file) should be loaded, it loops through this collection of loaders and returns the loader which supports this particular resource type.
Such error usually appears when you have error in your resource file.
In your case - I guess, you missed the pattern
for task_new
route
Also check if defaults
starts right after 4 spaces from the beginning
task_new:
defaults: { _controller:AcmeTaskBundle:Task:sub }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With