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
Related
I am integrating FOSUserBundle in my application and I am trying to run php bin/console doctrine:migration:diff after following the recommended set-up.
I am systematically getting a:
In ArrayNode.php line 319:
Unrecognized option "resource" under "fos_user"
Yet, I have set the following in my config/packages/routing.yaml:
framework:
router:
strict_requirements: ~
fos_user:
resource: "#FOSUserBundle/Resources/config/routing/all.xml"
What am I doing wrong? I have "friendsofsymfony/user-bundle": "~2.0" in my composer.json and ran composer update.
Update
My fos_user.yaml is:
fos_user:
db_driver: orm
firewall_name: main
user_class: App\Entity\Admin\User
from_email:
address: no_reply#xxx.com
sender_name: xxx
Dlondero's suggestion fixed the issue, the fos_user configuration should be set in config/routes.yaml.
From documentation, routes are never automatically added in configuration.
move the :
fos_user:
resource: "#FOSUserBundle/Resources/config/routing/all.xml"
into config/routes.yaml insted of confing/packages/routing.yml
If I am not wrong, config/packages/routing.yaml file is not for routes, it is the config file for routing bundle, you can not put your routing configs to there. Instead, you should put them under config/routes folder, as bundle_name.yml.
Like this, eg. config/routes/imagine.yml:
_liip_imagine:
resource: "#LiipImagineBundle/Resources/config/routing.yaml"
In my case with Symfony 4.3.2 skeleton
fos_user:
resource: "#FOSUserBundle/Resources/config/routing/all.xml"
should be pasted in
config/routes/annotations.yaml
and
php bin/console debug:router
displays all the fos_user routes
I tried to setup the Symfony routing. I'm using Symfony 2.7. I have two bundles that work under a different subdomain. The domainname can be an wild card and the tld can be multiple.
Here is my current config file:
company_api:
resource: "#ApiBundle/Controller/"
type: annotation
prefix: /
company_core:
resource: "#CoreBundle/Controller/"
type: annotation
prefix: /
I want that the first bundle only works under the subdomain "api", the domain can be an wildcard and for the TLD I want to specify a few like (nl|eu).
edited
company_core:
resource: "#ApiBundle/Controller/"
type: annotation
prefix: /
host: www.mydomainname.{tld}
defaults:
tld: nl
requirements:
tld: "nl|eu"
I have nog upgarde the config to this setup. And the tld works correct. Only would it be possible to have an wildcard for the domain name "mydomainname"? This is easy as the dev and producten server use different doamain names.
Here is an example of what I use on a 3.1 app, where I use a placeholder for the top-level domain that varies by environment —
app:
resource: "#AppBundle/Controller/"
type: annotation
host: www.example.{tld}
defaults:
tld: "%tld%"
requirements:
tld: "%tld%"
I don’t see why the following would not work for your API routes, as this should all be compatible with 2.7 according to the docs:
company_api:
resource: "#ApiBundle/Controller/"
type: annotation
host: api.{domain}.{tld}
defaults:
domain: yourdefaultdomain
tld: nl
requirements:
tld: "nl|eu"
I do remember that during development the routing config seemed to be aggressively cached, so as always, be sure to clear the cache after making any routing changes.
I'm developping a Symfony 2 application (version 2.6.1) but I can only run it on PROD mode. When trying to access to the following URL :
http://localhost/lawAdmin/web/app_dev.php
I'm having the next error message:
RouteNotFoundException in appDevUrlGenerator.php line 32: Unable to
generate a URL for the named route "_profiler" as such route does not
exist.
Both my routing.yml and routing_dev.yml files look the same:
law_admin:
resource: "#LawAdminBundle/Controller/DefaultController.php"
type: annotation
prefix: /
Running
app/console debug:router
returns:
[router] Current routes
Name Method Scheme Host Path
porfolio_show GET ANY ANY /
gallery_show GET ANY ANY /gallery/{galleryId}
I've also tried the following command just in case unsuccessfully:
php app/console cache:clear
Change your routing dev to
_wdt:
resource: "#WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "#WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_main:
resource: routing.yml
This will load profiler and toolbar routes on dev environment, and load your own application routes from routing.yml file.
I'm using FOS User bundle to allow users to register and log in to my app. Until now it works just fine but i don't know how to get my hand on those views? Can i generate them somehow? Documentation doesnt seem to know anything about it, just about overriding templates, which is not what i need...
At first i thought routing file might be of some use, since it points to specific places in the project, but it lists folders I dont even have in my application
fos_user_security:
resource: "#FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "#FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "#FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "#FOSUserBundle/Resources/config/routing/resetting.xml"
prefix: /resetting
fos_user_change_password:
resource: "#FOSUserBundle/Resources/config/routing/change_password.xml"
prefix: /profile
There is no FOSUserBundle directory at all...
You can find third party bundles installed in the vendor directory.
In this case, #FOSUserBundle should be a pointer to vendor/friendsofsymfony/user-bundle/FOS/UserBundle/.
If you don't have that directory, try running this on your project root: composer update.
Overriding templates is well documented here
I have just installed Symfony2 and created my bundle. I removed the Acme demo bundle and tested my new route "/" which worked fine.
I then went to config.php and followed the link to _configurator and get the above route error. I also get the same error when trying to load _profiler.
Here is my route file:
asf_core_homepage:
pattern: /
defaults: { _controller: ASFCoreBundle:Home:index }
And the Symfony routing_dev file:
_wdt:
resource: "#WebProfilerBundle/Resources/config/routing/wdt.xml"
prefix: /_wdt
_profiler:
resource: "#WebProfilerBundle/Resources/config/routing/profiler.xml"
prefix: /_profiler
_configurator:
resource: "#SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
prefix: /_configurator
_main:
resource: routing.yml
Any ideas why this is happening?
EDIT
I have narrowed it down and it looks like it has nothing to do with symfony. I have it installed in a subfolder of root so I use htaccess to rewrite all requests from /forum to /forum/web
RewriteRule forum/(.*) /forum/web/$1 [L]
If I point the browser to /forum/app_dev.php it works fine. the error comes from /forum/app_dev.php/_configurator
But if I skip the rewrite rule and use /forum/web/app_dev.php/_configurator it works fine.