Dependency service issue with PUGX multi user in symfony - php

I'm currently working on a symfony project that I have to finish to end my degree.
I wanted to create two kinds of users for my site so I installed PUGX which was the most popular and easy to use. I followed the documentation on github to achieve the installation but I'm stuck since two days now and I cant really find the solution.
I get this error when I want to go on my index page :
ServiceNotFoundException in
CheckExceptionOnInvalidReferenceBehaviorPass.php line 58:
The service "pugx_user.manager.orm_user_manager" has a dependency on a
non-existent service "fos_user.util.password_updater".
As you can see I'm using FOSUserBundle as well.
I don't really know what that means, I didn't find anything about it on forums and stuff.
Feel free to ask my files if you want to take a look and i will add them to the topic.
Im adding the main config one below :
**app/config/config.yml**
# FOS user config
fos_user:
db_driver: orm
firewall_name: main
user_class: Utilisateurs\UtilisateursBundle\Entity\Utilisateurs
service:
user_manager: pugx_user_manager
# PUGXmultiuser config
pugx_multi_user:
users:
Client:
entity:
class: Utilisateurs\UtilisateursBundle\Entity\Client
registration:
form:
type: Utilisateurs\UtilisateursBundle\Form\Type\RegistrationClientFormType
name: fos_user_registration_form
validation_groups: [Registration, Default]
template: UtilisateursUtilisateursBundle:views:Registration:Client.html.twig
profile:
form:
type: Utilisateurs\UtilisateursBundle\Form\Type\ProfileClientFormType
name: fos_user_profile_form
validation_groups: [Profile, Default]
Moniteur:
entity:
class: Utilisateurs\UtilisateursBundle\Entity\Moniteur
registration:
form:
type: Utilisateurs\UtilisateursBundle\Form\RegistrationMoniteurFormType
template: UtilisateursUtilisateursBundle:views:Registration:Moniteur.html.twig
profile:
form:
type: Utilisateurs\UtilisateursBundle\Form\Type\ProfileMoniteurFormType
thanks for your help in advance!
EDIT :
There is what i have on my console :
[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
The service "pugx_user.manager.orm_user_manager" has a dependency on a non-existent service "f
os_user.util.password_updater".
there is my composer.json file as well :
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": { "": "src/" },
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.8.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"symfony/swiftmailer-bundle": "~2.3,>=2.3.10",
"symfony/monolog-bundle": "^3.0.2",
"sensio/distribution-bundle": "~5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "2.0.*#dev",
"pugx/multi-user-bundle": "3.0.*#dev"
},
"require-dev": {
"sensio/generator-bundle": "~3.0",
"symfony/phpunit-bridge": "~2.7"
},
"scripts": {
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-install-cmd": [
"#symfony-scripts"
],
"post-update-cmd": [
"#symfony-scripts"
]
},
"config": {
"bin-dir": "bin",
"platform": {
"php": "5.3.9"
}
},
"minimum-stability": "dev",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.8-dev"
}
}
}
Note that i'm using Symfony 2.8 version. Does that matter if it's not the newest version?
EDIT 2
i have done this :
# FOS user config
fos_user:
db_driver: orm
firewall_name: main
user_class: Utilisateurs\UtilisateursBundle\Entity\Utilisateurs
services:
user_manager: pugx_user_manager
fos_user.doctrine_registry:
alias: doctrine
but it doesn't work i get this message when executing in web_dev.php :
Unrecognized option "services" under "fos_user"
Is my services term nicely place?

In PUGX\MultiUserBundle\Resources\config\orm.yml replace "#fos_user.entity_manager" by "#fos_user.object_manager"
In app\config\config.yml add (or modify)
services:
fos_user.doctrine_registry:
alias: doctrine
It should solve your problem.

Related

Symfony - why "There is no extension able to load the configuration for "when#dev" "

I'm in deep over my head here trying to move into symfony flex finally. I'm following along with the symfonycast here (https://symfonycasts.com/screencast/symfony4-upgrade/flex-alive#play) moving step-by-step but I get an error where he has none and was wondering if I could get a hint as to where I've gone wrong.
upon running php bin/console I am hit by:
In FileLoader.php line 180:
There is no extension able to load the configuration for "when#dev" (in "/Users/mattias/Documents/www/webtools/config/package
s/monolog.yaml"). Looked for namespace "when#dev", found ""doctrine_cache", "doctrine", "fos_user", "sensio_framework_extra",
"monolog", "swiftmailer", "framework", "twig", "security"" in /Users/mattias/Documents/www/webtools/config/packages/monolog.
yaml (which is loaded in resource "/Users/mattias/Documents/www/webtools/config/packages/monolog.yaml").
In YamlFileLoader.php line 722:
There is no extension able to load the configuration for "when#dev" (in "/Users/mattias/Documents/www/webtools/config/package
s/monolog.yaml"). Looked for namespace "when#dev", found ""doctrine_cache", "doctrine", "fos_user", "sensio_framework_extra",
"monolog", "swiftmailer", "framework", "twig", "security"".
If I remove the when#dev from the monolog.yml file the same error appears with the next section instead (the when#test) so I assume there is some main wireing that hasn't been done etc.
I've googled the error but I seem to be the first one 😂
It seems as though I've ended up with monolog config for sym 5 so I wonder whether that tutorial is inaccurate in one of the composer directives. I might need to restrict some component to an earlier version when using it these days?
Here's my composer.json:
{
"name": "a/b",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"AppBundle\\": "src/AppBundle",
"App\\": "src/"
},
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"autoload-dev": {
"psr-4": {
"Tests\\AppBundle\\": "tests/AppBundle",
"App\\Tests\\": "tests/"
}
},
"repositories": [
{
"type": "package",
"package": {
"name": "jquery/jquery",
"version": "1.11.1",
"dist": {
"url": "https://code.jquery.com/jquery-1.11.1.js",
"type": "file"
}
}
}
],
"require": {
"php": "^7.1.3",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"doctrine/orm": "^2.5",
"friendsofsymfony/user-bundle": "~2.1",
"sensio/framework-extra-bundle": "^5.0.0",
"symfony/console": "^4.0",
"symfony/flex": "^1.19",
"symfony/framework-bundle": "^4.0",
"symfony/lts": "^4#dev",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^3.1",
"symfony/yaml": "^4.0",
"twig/twig": "^1.0||^2.0"
},
"require-dev": {
"symfony/dotenv": "^4.0",
"symfony/phpunit-bridge": "^4.0"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true,
"allow-plugins": {
"symfony/flex": true
}
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-update-cmd": [
"#auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"id": "",
"allow-contrib": false
}
}
}
The configuration is not handled by the bundle (monolog in this case), but by flex itself.
After package installation it runs "recipes" that take care of creating configuration, assets, etc. You can find the recipe for the monolog version here. There's no when# directive to be found until 3.7 but composer.json declares ^3.1.0.
Use composer show symfony/monolog-bundle to see what version is installed, but I doubt there will be a problem in the version resolution. You can try to nuke vendor/ and reinstall all packages.
The easiest way to go about it is to delete config/packages/monolog.yaml. since you should have your old configuration under confib/packages/{dev,prod,test}/monolog.yaml everything should continue working. If that's not the case you can always reinstall the recipe with composer recipes:install symfony/monolog-bundle --force to bring it back.
As for the tutorial itself, on a brief glance everything seems okay so far.
And keep in mind that the ability to parse when directives comes from framework-bundle >= 5.3. If you plan to upgrade all the way up you might want to reinstall recipes to pull in the latests configs (or maybe use composer recipes:update for an interactive, git-based update). Having all configs in one file is only a matter of convenience if the changes are small per environment, but everything will work just the same.

Vendor updates broke FOS User Bundle with "Call to a member function has() on a non-object"

I updated my vendors for a Symfony 2.8 project and suddenly the login page isn't loading – instead I get this:
Error: Call to a member function has() on a non-object in
vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php
at line 184
"name": "hazardlog",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"": "src/"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"repositories": [
{
"type": "package",
"package": {
"name": "jquery/jquery",
"version": "1.11.1",
"dist": {
"url": "https://code.jquery.com/jquery-1.11.1.js",
"type": "file"
}
}
}
],
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.8.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"braincrafted/bootstrap-bundle": "~2.0",
"twbs/bootstrap": "3.0.*",
"jquery/jquery": "1.11.*",
"hwi/oauth-bundle": "^0.5.0",
"friendsofsymfony/user-bundle": "~2.0#dev",
"stephanecollot/datetimepicker-bundle": "dev-master"
},
"require-dev": {
"sensio/generator-bundle": "~3.0",
"symfony/phpunit-bridge": "~2.7"
},
"scripts": {
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-install-cmd": [
"#symfony-scripts"
],
"post-update-cmd": [
"#symfony-scripts"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
}
}
I have seen this sort of question several times but I could not find one with an accepted answer and explanation. So here goes.
The basic problem lies with:
"friendsofsymfony/user-bundle": "~2.0#dev",
Back when Symfony 2.8/3.0 was first released, the stable 1.x version of FOSUserBundle no longer worked. The 2.x version has been in development for years with no actual road map in sight for when it would be stabilized. So the development branch was hacked up to get it working. And folks had no choice but to use it which of course is dangerous because you never know when a development change might in fact break your code.
Time went by and eventually a stable 2.x version of the FOSUserBundle was released. However, quite a few developers never got around to updating their dependencies and continued to use the master branch.
Fast forward to the present. The release of Symfony 4 has now triggered a fair amount of development in the master branch. Development which is introducing breaking changes to existing 2.8 (and probably 3.0) code.
The bottom line is to use a stable branch with:
"friendsofsymfony/user-bundle": "~2.0",
followed by a composer update.
For those using Symfony 3.2, it looks like version "~2.1" throws same error along with the OP's version "~2.0#dev".
This worked:
"friendsofsymfony/user-bundle": "2.0"
Keeping it at 2.0 did the trick for me.
had a problem like this here but solved,i just did the opposite of this.
i had:
"friendsofsymfony/user-bundle": "^2.1",
in my composer.json file which give me a Call to a member function has() on null error to solve this i Actually add "#dev it became:
"friendsofsymfony/user-bundle": "^2.1#dev",
then updated my composer with :
composer update

Symfony: Namespaced bundle not loaded correctly

I have a freshly installed (through composer) Symfony app. I've moved things around a bit, and it seems this has caused Symfony's annotation driver for controllers to break down. Most notably, I'm using a namespace.
My app/config/routing.yml is unmodified. I.e.:
app:
resource: '#Kafoso/TestApp/AppBundle/Controller/'
type: annotation
And app/config/routing_dev.yml points to app/config/routing.yml.
Now, I've moved the AppBundle class to a new namespace (and thus folder location) Kafoso\TestApp\AppBundle.
I have a default controller Kafoso\TestApp\AppBundle\Controller\DefaultController for GET /:
namespace Kafoso\TestApp\AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class DefaultController extends Controller
{
/**
* #Route("/", name="homepage")
*/
public function indexAction(Request $request)
{
// replace this example code with whatever you need
return $this->render('default/index.html.twig', [
'base_dir' => realpath($this->getParameter('kernel.project_dir')).DIRECTORY_SEPARATOR,
]);
}
}
The bundle is indeed added to app/AppKernel.php (new Kafoso\TestApp\AppBundle()).
The error I get:
request.CRITICAL: Uncaught PHP Exception Symfony\Component\Config\Exception\FileLoaderLoadException: "Cannot load resource "#Kafoso/TestApp/AppBundle/Controller/". Make sure the "Kafoso" bundle is correctly registered and loaded in the application kernel class. If the bundle is registered, make sure the bundle path "#Kafoso/TestApp/AppBundle/Controller/" is not empty." at (...)/vhosts/testapp/framework/server/vendor/symfony/symfony/src/Symfony/Component/Config/Loader/Loader.php line 73
Notice how Symfony thinks my bundle's name is "Kafoso".
The strange thing is, if I put an error_log or var_dump in the DefaultController (outside the class declaration), I see the output. But for some reason Symfony doesn't parse the controller's annotations.
Is it not possible to use namespaces here? Must everything be placed under AppBundle (or a differently chosen name)?
If it's the latter it seems like a rather restrictive and unnecessary enforcement.
EDIT
app/config/services.yml:
# Learn more about services, parameters and containers at
# https://symfony.com/doc/current/service_container.html
parameters:
#parameter_name: value
services:
# default configuration for services in *this* file
_defaults:
# automatically injects dependencies in your services
autowire: true
# automatically registers your services as commands, event subscribers, etc.
autoconfigure: true
# this means you cannot fetch services directly from the container via $container->get()
# if you need to do this, you can override this setting on individual services
public: false
# makes classes in src/Kafoso/TestApp/AppBundle available to be used as services
# this creates a service per class whose id is the fully-qualified class name
Kafoso\TestApp\AppBundle\:
resource: '../../src/Kafoso/TestApp/AppBundle/*'
# you can exclude directories or files
# but if a service is unused, it's removed anyway
exclude: '../../src/Kafoso/TestApp/AppBundle/{Entity}'
# controllers are imported separately to make sure they're public
# and have a tag that allows actions to type-hint services
Kafoso\TestApp\AppBundle\Controller\:
resource: '../../src/Kafoso/TestApp/AppBundle/Controller'
public: true
tags: ['controller.service_arguments']
# add more services, or override services that need manual wiring
# Kafoso\TestApp\AppBundle\Service\ExampleService:
# arguments:
# $someArgument: 'some_value'
EDIT
composer.json:
{
"name": "kafoso/testapp",
"license": "proprietary",
"type": "project",
"authors": [
{
"name": "Kafoso",
"email": ""
}
],
"autoload": {
"psr-4": {
"Kafoso\\TestApp\\": "src/Kafoso/TestApp"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"autoload-dev": {
"psr-4": {
"Kafoso\\TestApp\\AppBundle\\Tests\\Integration\\": "tests/integration",
"Kafoso\\TestApp\\AppBundle\\Tests\\Unit\\": "tests/unit"
},
"files": [
"vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
]
},
"require": {
"php": "7.1.*",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/symfony": "3.3.*",
"twig/twig": "^1.0||^2.0",
"webmozart/glob": "^4.1"
},
"require-dev": {
"phpunit/phpunit": "^6.2",
"phpunit/dbunit": "^3.0",
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
},
"scripts": {
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-install-cmd": [
"#symfony-scripts"
],
"post-update-cmd": [
"#symfony-scripts"
]
},
"config": {
"sort-packages": true
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "../../www",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": null
}
}
The only changes from the vanilla file are:
Test specification of test namespaces, which have no influence on this problem.
The addition of the package webmozart/glob.
The change of symfony-web-dir, which is indeed working (www/app.php is run).
The PSR-4 autoload is Kafoso\TestApp, and not Kafoso\TestApp\AppBundle, but this shouldn't be necessary.
The problem is the autoload of symfony.
Open you composer.json file and edit :
AnnuaireBundle\AnnuaireBundle
"autoload": {
"psr-4": {
"AppBundle\": "src/AppBundle",
"Kafoso\": "src/Kafoso"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
then, run the next command in your composer:
composer dumpautoload
You can always rename every folder inside your on application project, you just have to alter the config files propery
Here are some hints:
Take a look at the config files in `app/config` if there is something old
Check all your `php-files` if the namespace is properly altered
Check your `project config-files` inside the Bundle `Resources/config`
Remove the `cache-folder` => `bin/cache` completely, symfony will automatically recreate it
And for the point of truth is saw your problem,... the error message is correct and pretty clear:
new Kafoso\TestApp\AppBundle\AppBundle()
for the registration the Bundle constructor must be called and this is located in the php file inside the folder which has the same name as the bundle-folder
... Since you added the composer.json, why don't you use:
"psr-0": { "": "src/" },
inside the autoload block
I just had this issue in a project I maintain, and the problem was sensio_framework_extra bundle in app/config/config.yml:
I changed:
sensio_framework_extra:
router:
annotations: false
To
sensio_framework_extra:
router:
annotations: true <-----
All my routes where using annotations, so this was weird. Changed it and it started to work!
Please in composer.json replace
"psr-4": {
"[Bundles names]\\": "src/[same bundle]"
// Even if there is one or more bundles
},
by this
"psr-4": {
"": "src/"
},
file: config.yml
fos_rest:
routing_loader:
"If **enable:true** / Just change this for **false**. so if this is false, change this for true, and restart the project, i'm thinks this is a bug when we're upgrading to a new version!!, and i fixed in the way that I'm mentioning to you
"
**enabled: false**

Error in attempting to create a bundle within symfony2

I have installed symfony2 and i have ensured the application has been installed correctly and i am trying to create a bundle for my project and i seem to be getting this message and i have edited the composer.json manually and added the correct bundle to the file:
Generating the bundle code: OK
Checking that the bundle is autoloaded: FAILED
Confirm automatic update of your Kernel [yes]? yes
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]? yes
Importing the bundle routing resource: OK
i have ensured composer has been configured correctly and i have removed previous namespaces from appkernel.php and routing.yml any help would be much appreciated.
this is my composer.json file:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": {
"Acme": "src/"
}
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.4",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.4-dev"
}
}
}
I also encountered the same problem while generating my first bundle. I did the following things:
1. Make sure you have Composer installed before generating a bundle.
2. If the same failure message occurs on generating bundles, then in the terminal type this in your project directory $ sudo composer dumpautoload -o.
This will run your application.

InvalidConfigurationException installing Symfony2 CMF

Just getting into Symfony2 and I wanted to use the CMF bundle.
I am following the cookbook here:
http://symfony.com/doc/current/cmf/cookbook/editions/cmf_core.html
When running
composer.phar update
I am getting this error:
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
When the dynamic router is enabled, you need to either enable one of the persistence layers or set the cmf_routing.dynamic.route_provider_service_id option
What is the proper setting for route_provider_service_id? I cannot find any docs on this.
config.yml
# CMF config
cmf_routing:
chain:
routers_by_id:
cmf_routing.dynamic_router: 200
router.default: 100
dynamic:
enabled: true
route_provider_service_id: ~
sonata_block:
default_contexts: [cms]
Here is my composer.json file:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"minimum-stability": "dev",
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.3.*",
"symfony/monolog-bundle": "2.3.*",
"sensio/distribution-bundle": "2.3.*",
"sensio/framework-extra-bundle": "2.3.*",
"sensio/generator-bundle": "2.3.*",
"incenteev/composer-parameter-handler": "~2.0",
"jackalope/jackalope-doctrine-dbal": "dev-master",
"doctrine/phpcr-bundle": "1.0.*",
"doctrine/phpcr-odm": "1.0.*",
"symfony-cmf/symfony-cmf": "1.0.*"
},
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.3-dev"
}
}
}
If anyone could just shine some light on these cmf_routing settings to get a clean update from composer would be great.
One thing that I find frustrating with this new Sym2 method is it seems every bundle you need, comes with another required bundle, compiling your probabilities for errors and confusion.
UPDATE
I have looked at the Dynamic configuration here:
http://symfony.com/doc/master/cmf/reference/configuration/routing.html#dynamic
It says this about route_provider_service_id:
route_provider_service_id
type: string
When none of the persistence layers is enabled, a route provider service must be provided in order to get the routes. This is done by using the route_provider_service_id setting.
I understand if i do not set persistence, I should add this setting. I know the setting should be a string. But I don't know what the service_id actually is, so I don't know what the setting could be. Perhaps I am still unclear on what I am doing with the dynamic router.
I was able to fix this by enabling persistence.phpcr and giving the manager_name: null
Removed the error, but it could be that defining the manager_name is an important step in getting the CMF off the ground.
You need to configure the route provider. Otherwise the router won't know how to load routes. The idea of the dynamic router is that you can load routes from the database, so you need to tell it how to load them. you can either enable persistence.phpcr or persistence.orm, or provide your own service.
There is an introduction to the cmf routing here
http://symfony.com/doc/master/cmf/book/routing.html
And more details here http://symfony.com/doc/master/cmf/bundles/routing/dynamic.html (i just clarified the thing with the route provider a bit more, as i realized it was not very explicit).
The configuration reference for routing is here:
http://symfony.com/doc/master/cmf/reference/configuration/routing.html#dynamic

Categories