http://localhost/Symfony/web/app.php/demo/hello/Alex
shows
"Cannot import resource "@AcmeDemoBundle/Controller/SecuredController.php" from "D:/UserData/WWWRoot/Symfony/app/config/routing.yml". Make sure the "AcmeDemoBundle/Controller/SecuredController.php" bundle is correctly registered and loaded in the application kernel class."
This is my routes of app\\config\\routing.yml
Internal routing configuration to handle ESI
_internal:
resource: "@FrameworkBundle/Resources/config/routing/internal.xml"
prefix: /_internal
_welcome:
pattern: /
defaults: { _controller: AcmeDemoBundle:Welcome:index }
_demo_secured:
resource: "@AcmeDemoBundle/Controller/SecuredController.php"
type: annotation
_demo:
resource: "@AcmeDemoBundle/Controller/DemoController.php"
type: annotation
prefix: /demo
AcmeDemoBundle
is activated in AppKernel
for dev
and test
environments only:
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Acme\DemoBundle\AcmeDemoBundle();
}
If you want to access it via app.php
— which is for the prod
envifonment — you need to move the bundle activation out of the condition.
AFAIK, adding prod in the getEnvironment()
options array is OK, assuming you know what bundles dont go to prod.
Have a separate condition to check if its dev or test for other bundles that don't go to prod
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.