Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot import resource in symfony2

Tags:

symfony

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?

like image 545
Rohitashv Singhal Avatar asked Jul 25 '12 07:07

Rohitashv Singhal


People also ask

How are Symfony configuration resources different from configuration files?

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

How are Symfony core services loaded in containers?

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.

How do I load a Symfony configuration using filelocator?

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.

How does Symfony loaderresolver work?

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.


1 Answers

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 }
like image 58
Vitalii Zurian Avatar answered Sep 28 '22 11:09

Vitalii Zurian