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**
Related
I'm trying to figure out something I couldn't understand while exploring Symfony/Mailer source code.
At first I created a whole new project using these commands:
symfony new my_project_name --version=lts
composer require symfony/mailer
Then, when I was exploring the Symfony\Component\Mailer\Transport\AbstractHttpTransport and saw
it was using Symfony\Contracts\HttpClient\HttpClientInterface.
I was surprised to find out that the HttpClientInterface is not part of my project, I can't find it anywhere and neither does PhpStorm.
How is this possible? Is that a programming trick I am not aware of?
I searched on the internet and find out about Symfony/Contracts project and its purpose but I don't understand how it can be declared in the project and not being part of it.
Here is a part of the source code of the AbstractHttpTransport in Symfony/mailer
use Symfony\Contracts\HttpClient\HttpClientInterface;
...
abstract class AbstractHttpTransport extends AbstractTransport
{
public function __construct(HttpClientInterface $client = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
...
Edit: As required here is the composer.json generated for the project
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"symfony/console": "4.4.*",
"symfony/dotenv": "4.4.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "4.4.*",
"symfony/mailer": "4.4.*",
"symfony/yaml": "4.4.*"
},
"require-dev": {
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"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": {
"allow-contrib": false,
"require": "4.4.*"
}
}
}
The reason why you are unable to find HttpClientInterface, is that you do not require any library that provides a symfony/http-client-implementation.
To allow a transport to use symfony/http-client you will need to explicitly install and configure it.
composer require symfony/http-client
# config/packages/framework.yaml
framework:
# ...
http_client:
max_host_connections: 10
default_options:
headers: { 'X-Powered-By': 'ACME App' }
max_redirects: 7
I don't understand how it can be declared in the project and not being
part of it.
You are able to declare any fully qualified namespace within a PHP application, without the subsequent class or file existing. Example: https://3v4l.org/RIWqS
namespace Foo;
use Non\Existing\NamespaceClass;
class Bar
{
public function __construct()
{
echo NamespaceClass::class;
}
}
new \Foo\Bar(); //Non\Existing\NamespaceClass
Symfony has the capability to ignore autowired arguments that declare a service namespace that does not exist, and will instead supply null for its value.
Clarification
symfony/mailer is a modular component, that does not require the Symfony Framework or the symfony/http-client in order to be used and can be used in virtually any application. Since the mailer can support a variety of different transports and those transports different clients, the code is included to work with them, but they are not a dependency for the mailer package. Allowing you to choose the transports you want to use.
In this instance, extending the AbstractHttpTransport will also require a service that implements the Symfony\Contracts\HttpClient\HttpClientInterface to be provided or overridden. This allows for the HttpClientInterface to be used when it is available.
Symfony Framework specifically looks for the configuration for http_client and will configure the services that can utilize it for you. [sic] Once symfony/http-client is installed and configured, a transport that supports it, will utilize it for the connection.
Source
The HttpClientInterface is supplied in symfony/http-client-contracts. Where a library that provides the implementation, will specify as such in the composer.json as "provide": { "symfony/http-client-implementation": "*" }. Such as symfony/http-client
Which is why no classes within symfony/mailer package extends AbstractHttpTransport, as it is intended to be used by other libraries, such as symfony/amazon-mailer. While symfony/mailer does not provide the implementation for symfony/http-client, multiple classes and methods reference HttpClientInterface, allowing it to be used when available.
For more information see Symfony Contracts and Symfony Http Client
Usage
The various transports that symfony/mailer supports need to be added as desired by you. By default the only transport symfony/mailer comes pre-installed with is SMTP. Where other transports that support the symfony/http-client features but do not require it, are also available.
I am using doctrine/data-fixtures in dev environments and require it as follows:
composer.json:
"autoload": {
"psr-0": {
"": "src/",
"SymfonyStandard": "app/"
},
"classmap": [ "app/AppKernel.php", "app/AppCache.php" ]
},
"require-dev": {
"symfony/maker-bundle": "^1.8",
"phpunit/phpunit": "^7.0",
"doctrine/data-fixtures": "dev-rfc1872 as v1.2.1",
"doctrine/doctrine-fixtures-bundle": "^3.0"
},
In my Symfony 3.4 application my data fixtures live in /src/AppBundle/DataFixtures/ORM/*.php.
When I run composer, which in turn runs a Symfony cache:clear I get the following error:
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'"
command:
In DefinitionErrorExceptionPass.php line 37:
While discovering services from namespace "AppBundle\", an error was thrown
when processing the class "AppBundle\DataFixtures\ORM\LoadCourseData": "Cl
ass Doctrine\Common\DataFixtures\AbstractFixture not found".
I would like to exclude the DataFixtures namespace from being autoloaded but I cannot find a way to do that.
I think you don't want to exclude data fixtures from being autoloaded, because they are valid PHP classes.
This error comes from Symfony's autowiring feature. So I assume you're indeed using autowiring.
You should data fixtures from autowiring discovery, which can be done in services.yml with exclude option.
Assuming you have something like (which should be there by default):
AppBundle\:
resource: '../../src/AppBundle/*'
exclude: '../../src/AppBundle/{Entity,Repository}'
All you need to do is to add DataFixtures namespace to exclude:
AppBundle\:
resource: '../../src/AppBundle/*'
exclude: '../../src/AppBundle/{Entity,Repository,DataFixtures}'
You can read more about it in here nad here
I am learning the Symfony framework and trying to deploy a simple boilerplate app I put together to Heroku using Git.
The deployment fails due to the following fatal error:
Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "WebServerBundle" from namespace "Symfony\Bundle\WebServerBundle
Did you forget a "use" statement for another namespace? in /tmp/build_cbeb92af6c9ee04b07e1f85618211649/src/Kernel.php:32
Kernel.php
<?php
namespace App;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
class Kernel extends BaseKernel {
use MicroKernelTrait;
const CONFIG_EXTS = '.{php,xml,yaml,yml}';
public function getCacheDir(){
return $this->getProjectDir().'/var/cache/'.$this->environment;
}
public function getLogDir(){
return $this->getProjectDir().'/var/log';
}
public function registerBundles(){
$contents = require $this->getProjectDir().'/config/bundles.php';
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
yield new $class();
}
}
}
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader){
$container->setParameter('container.autowiring.strict_mode', true);
$container->setParameter('container.dumper.inline_class_loader', true);
$confDir = $this->getProjectDir().'/config';
$loader->load($confDir.'/packages/*'.self::CONFIG_EXTS, 'glob');
if (is_dir($confDir.'/packages/'.$this->environment)) {
$loader->load($confDir.'/packages/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
}
$loader->load($confDir.'/services'.self::CONFIG_EXTS, 'glob');
$loader->load($confDir.'/services_'.$this->environment.self::CONFIG_EXTS, 'glob');
}
protected function configureRoutes(RouteCollectionBuilder $routes){
$confDir = $this->getProjectDir().'/config';
if (is_dir($confDir.'/routes/')) {
$routes->import($confDir.'/routes/*'.self::CONFIG_EXTS, '/', 'glob');
}
if (is_dir($confDir.'/routes/'.$this->environment)) {
$routes->import($confDir.'/routes/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
}
$routes->import($confDir.'/routes'.self::CONFIG_EXTS, '/', 'glob');
}
}
What Ive done so far:
install the dotenv bundle (composer require symfony/dotenv)
run composer dump-autoload
set the production environment variable via the heroku CLI as per this article (heroku config:set SYMFONY_ENV=prod)
Some things Ive learned/have noticed:
According to the README file for WebServerBundle:
WebServerBundle provides commands for running applications using the PHP
built-in web server. It simplifies your local development setup because you
don't have to configure a proper web server such as Apache or Nginx to run your
application.
.. that is, WebServerBundle is a development dependency - yet it is being included in production.
WebServerBundle is also being included in the composer.lock file under autoload
"autoload": {
"psr-4": {
"Symfony\\Bundle\\WebServerBundle\\": ""
},
...
},
My bundles.php file includes WebServerBundle for dev
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
];
I have a .env file and a .env.dist file - Im assuming the .env.dist file is for production? They both have the same contents:
APP_ENV=dev
APP_SECRET=0473d15a4ce2723619d2e8b0405186d3
Im pretty new to symfony and do not really understand how a production environment is instantiated other than that the dotenv bundle reads the .env file and sets the environment variables.
Any help and clarity on all of this would be appreciated.
Edit: here is my composer.json file
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"sensio/framework-extra-bundle": "^5.1",
"symfony/asset": "^4.0",
"symfony/console": "^4.0",
"symfony/dotenv": "^4.0",
"symfony/flex": "^1.0",
"symfony/framework-bundle": "^4.0",
"symfony/lts": "^4#dev",
"symfony/twig-bundle": "^4.0",
"symfony/yaml": "^4.0"
},
"require-dev": {
"symfony/profiler-pack": "^1.0",
"symfony/web-server-bundle": "^4.0"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-apcu": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-update-cmd": [
"#auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"id": "01C1BVQJ19BG3WAS3299PDHH9P",
"allow-contrib": false
}
}
}
I'm not sure about the command you are using, (I use git)
heroku config:set SYMFONY_ENV=prod
But if your .env file has
APP_ENV=dev
That is explictly setting the environment to dev, so it is trying to load dev dependencies (proven by your error) which don't get pushed to the server(read the article you provided).
You need the .env file that is on the server to have APP_ENV=prod
The .env is for the specific machine, it is ignored by git, while .env.dist is tracked. So edit the .env.dist and commit it, then once it is on the server just rename it .env then I would run composer install or composer update on the server which will update dependencies and clear the cache. Then refresh your browser.
The answer likely depends on how you deploy your app and I assume you will install only production dependencies in your deployment, i.e. you run composer with --no-dev as you should. This means that none of the dev dependencies, which very likely includes the webserver-bundle as this is not needed in production where you use a real webserver like apache or nginx, are installed.
What it boils down to is either your code requiring this dev dependency which is not installed or your webserver is trying to run your app in the wrong APP_ENV.
If it's the latter you should check your webserver config if you set the appropriate environment variables (APP_ENV & APP_DEBUG at the very least, probably also the DATABASE_URL). In apache you have to use SetEnv APP_ENV prod and in nginx you use fastcgi_param APP_ENV prod.
edit: I just read that you use composer, so dev dependencies are definitely not installed as is mentioned in the Getting Started Guide: https://devcenter.heroku.com/articles/php-support#build-behavior
So you can't use the dev environment for Symfony or you have to reinstall the dev-dependencies as regular dependencies using composer (which is absolutely not recommended).
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.
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