I am developing an application using Symfony 2.4 and doctrine mongodb bundle. I have faced an annoying error saying:
ClassNotFoundException: Attempted to load class "FlattenException" from namespace "Symfony\Component\Debug\Exception" in /opt/apps/aff/vendor/doctrine/mongodb-odm/lib/Doctrine/ODM/MongoDB/Cursor.php line 455. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\Component\HttpKernel\Exception\FlattenException, Symfony\Component\Debug\Exception\FlattenException.
This error occurs especially when visiting sonata admin bundle's list methods. I have faced with this error also when playing repository classess.
The exact code is running perfectly on the remote server. But on the local machine this error is occuring. I do not know why. I have run the following code on terminal to see version numbers or git commit ref codes.$ php composer.phar show -i
The result is axactly same on both computers. The following is my composer.json
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.4",
"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": "~2.3",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
"doctrine/mongodb-odm": "1.0.*#dev",
"doctrine/mongodb-odm-bundle": "3.0.*#dev",
"doctrine/doctrine-fixtures-bundle": "dev-master",
"gedmo/doctrine-extensions": "dev-master",
"jms/serializer-bundle" : "dev-master",
"friendsofsymfony/user-bundle": "*",
"friendsofsymfony/facebook-bundle": "1.2.*#dev",
"friendsofsymfony/rest-bundle" : "dev-master",
"nelmio/api-doc-bundle" : "dev-master",
"sonata-project/core-bundle": "~2.2#dev",
"sonata-project/admin-bundle": "2.2.*#dev",
"sonata-project/doctrine-mongodb-admin-bundle":"dev-master",
"sonata-project/block-bundle": "2.2.*#dev",
"sonata-project/user-bundle": "2.2.3",
"sonata-project/easy-extends-bundle" : "dev-master",
"sonata-project/intl-bundle": "dev-master",
"knplabs/knp-menu-bundle":"1.1.x-dev",
"zeitnot/cp_oauth_client" : "dev-master"
},
"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",
"php app/console assets:install --symlink",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"minimum-stability": "beta",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml",
"keep-outdated": true
},
"branch-alias": {
"dev-master": "2.4-dev"
}
}
}
I am really confused and I do not know how to procceed. What is the meaning of this annoying exception?
I had the same thing, the error was forced by a wrong parameter type in the hint() method in Cursor.php. And the PHP strict standards error setting of PHP is creating an error for that. That might be the reason it was working fine on the remote server (different PHP settings).
The problem is solved now, so updating your MongoDB vendors should fix it.
More information
Related
I need to update to Doctrine 2.5 for a bundle which requires it (Vich\UploaderBundle). However I am facing two difficulties:
How do I know which Doctrine version is compatible with my Symfony 2.8 setup
How do I actually run the upgrade
Composer management is still quite obscure to me, especially the output you get when you try to update.
Here is my current composer.json:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": { "": "src/" },
"files": ["app/AppKernel.php"]
},
"require": {
"php": ">=7.0",
"symfony/symfony": "2.8.*",
"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.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "1.2.*",
"doctrine/migrations": "dev-master",
"doctrine/doctrine-migrations-bundle": "dev-master",
"doctrine/doctrine-fixtures-bundle": "dev-master"
"incenteev/composer-parameter-handler": "~2.0",
"apy/datagrid-bundle": "dev-master",
"pagerfanta/pagerfanta": "dev-master",
"white-october/pagerfanta-bundle": "dev-master",
"idci/admin-generator-bundle": "dev-master",
"mopa/bootstrap-bundle": "dev-master",
"twbs/bootstrap": "v3.2.0",
"knplabs/knp-paginator-bundle": "dev-master",
"knplabs/knp-menu-bundle": "dev-master",
"craue/formflow-bundle": "dev-master",
"friendsofsymfony/user-bundle": "~2.0#dev",
"liuggio/excelbundle": "~2.0",
"excelwebzone/recaptcha-bundle": "~2.3",
"robertotru/to-inline-style-email-bundle": "dev-master",
},
"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"
},
"minimum-stability": "dev",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.3-dev"
}
},
"require-dev": {
}
}
[EDIT]
Specified require doctrine version.
I also have the feeling that this composer.json needs to be cleaned up somehow but that's another question...
Your problem seem to come from this strict restriction on the dependency : "doctrine/doctrine-bundle": "1.2.*" which require "doctrine/orm" < 2.5 (see here : https://packagist.org/packages/doctrine/doctrine-bundle#v1.2.0)
The solution might be to upgrade the version of this first dependency to
"doctrine/doctrine-bundle": "^1.6"
I didn't check the compatibility with all others packages so i'm not completly sure but you still can try.
I've just inherited a bunch of php apps built with Symfony2 from a former colleague. I'm struggling to get them going, but feel like I've very close.
I'm using Composer to install the vendor/ and bin/ directories using composer install. I've deleted (really renamed) the original composer.lock file, because he had some paths for bundles using his local machine's directory.
Running composer install gets me all the way to the end of the composer.json file and then it starts to "Writing lock file" I get an Command "app" is not defined error. What's up with that? I can't run the the php app/console server:run or anything else, because essentially I have yet to create a bootstrap.php.cache file.
I feel like I'm so close! Has anyone run into this before? Below is the output I'm getting from the console. I've still very new to Symfony and really appreciate any help!
Writing lock file
Generating autoload files
[InvalidArgumentException]
Command "app" is not defined.
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when generating the bootstrap file.
Updated with composer.json file.
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" },
"files": [
"vendor/tobie/ua-parser/php/bin/uaparser.php",
"vendor/simplehtmldom_1_5/simple_html_dom.php"
]
},
"repositories": [
{
"type": "vcs",
"url": "ssh://git#sourcecode.ts.vcu.edu:22/~git/vcu-cas-bundle.git"
}
],
"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.*",
"jms/serializer-bundle": "0.12.*#dev",
"incenteev/composer-parameter-handler": "~2.0",
"beberlei/DoctrineExtensions": "dev-master",
"vcu/cas-bundle": "dev-master",
"tobie/ua-parser": "dev-master"
},
"scripts": {
"post-install-cmd": [
"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": [
"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"
},
"minimum-stability": "alpha",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"branch-alias": {
"dev-master": "2.2-dev"
}
}
}
Everything was great with my Symfony2 setup until I started messing around with Composer.
I did install Symfony2 with Composer, but then manually added bundles - including ones I created myself.
Then, I needed to add something which seemed easier with Composer. Lots of messing around in the Terminal later I then find when I run in a browser I get an error in AppKernel.php saying none of the bundles exist - including:
FatalErrorException: Error: Class 'Acme\DemoBundle\AcmeDemoBundle' not found in /path/app/AppKernel.php line 39
I'm 100% the folders exist and nothing has changed other than running various Composer commands.
Composer has no reference to these bundles.
How do I resolve this? I'm guessing I either tell Composer to clear off (like before) or somehow I get Composer to understand the bundles.
I'm guessing it has something to do with the bootstrap file. I believe Composer will create one after being updated, but this is where I'm struggling.
--
composer.json:
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.2.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.1.*",
"symfony/swiftmailer-bundle": "2.2.*",
"symfony/monolog-bundle": "2.2.*",
"sensio/distribution-bundle": "2.2.*",
"sensio/framework-extra-bundle": "2.2.*",
"sensio/generator-bundle": "2.2.*",
"jms/security-extra-bundle": "1.4.*",
"jms/di-extra-bundle": "1.3.*"
},
"scripts": {
"post-install-cmd": [
"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": [
"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"
},
"minimum-stability": "alpha",
"extra": {
"symfony-web-dir": "web",
"symfony-app-dir": "app",
"branch-alias": {
"dev-master": "2.2-dev"
}
}
}
I think you didn't update app/autoload.php file. Check the source of standard distribution: https://github.com/symfony/symfony-standard/blob/master/app/autoload.php
You need to include vendor/autoload.php, which is generated by the composer.
I just upgraded my Symfony 2.2 installation to Symfony 2.3. I was abe to get "composer update" to run with no errors, but this has caused every route in my application to return a blank page. If I check the network tab on my JavaScript console, I see that a 500 Internal Server Error is being thrown, but have no insight as to what might be causing it. Any ideas? Here's my composer.json file:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"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.*",
"jms/security-extra-bundle": "1.5.*",
"jms/di-extra-bundle": "1.4.*",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/jsrouting-bundle": "*",
"sandeepshetty/shopify_api": "dev-master#dev"
},
"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"
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.3-dev"
}
}
}
You need to enable it manually in 2.3.
Debug::enable();
See: https://github.com/symfony/symfony-standard/blob/2.3/UPGRADE-2.3.md
Inspect your logifles in order to find the exception... app/logs/dev.log or app/logs/prod.log depending on which environment you are trying to access.
And clear your cache :-)
app/console cache:clear
Update those lines from your composer.json thouse versions are not supported by symfony >= 2.3
Before
"jms/security-extra-bundle": "1.5.*",
"jms/di-extra-bundle": "1.4.*",
After
"jms/di-extra-bundle": "dev-master",
"jms/security-extra-bundle": "dev-master",
Regards.
So I'm having issues trying to get composer to work again after installing the Sonata Admin Bundle on Symfony2. When using the command php composer.phar ...., I get the following error message: [UnexpectedValueException] Could not parse version constraint composer.phar: Invalid version string "composer.phar"
It doesn't matter what action I do with composer, it always produces that error. Well, one exception is php composer.phar require --no-update sonata-project/media-bundle says it updated composer.json with no error message, but didn't actually install anything.
So far I have just removed and reinstalled composer.phar with an updated version. I'm running Symfony 2.2.1-dev on Mac OS 10.7.5 with MAMP and PHP 5.4.4. Not sure if this is related, but I also cannot clear the cache using php app/console cache:clear anymore either. I have to delete the cache via Finder.
Here's my composer.json file just in case:
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": "composer.phar",
"symfony/symfony": "2.2.*",
"doctrine/orm": "2.3.*",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.1.*",
"symfony/swiftmailer-bundle": "2.2.*",
"symfony/monolog-bundle": "2.2.*",
"sensio/distribution-bundle": "2.2.*",
"sensio/framework-extra-bundle": "2.2.*",
"sensio/generator-bundle": "2.2.*",
"jms/security-extra-bundle": "1.4.*",
"jms/di-extra-bundle": "1.3.*",
"sonata-project/cache-bundle": "dev-master",
"sonata-project/block-bundle": "dev-master",
"sonata-project/jquery-bundle": "1.8.*",
"knplabs/knp-menu-bundle": "1.1.*-dev",
"sonata-project/exporter": "1.1.*",
"sonata-project/admin-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"doctrine/common": "2.3.x-dev",
"sonata-project/media-bundle": "dev-master"
},
"scripts": {
"post-install-cmd": [
"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": [
"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"
},
"minimum-stability": "dev",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"branch-alias": {
"dev-master": "2.2-dev"
}
}
Any help/advice would be great :)
Looks like you have some typos in your composer file.
Replace "php": "composer.phar" with "php": ">=5.3.3" and add the missing closing bracket at the end of your file :
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.2.*",
"doctrine/orm": "2.3.*",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.1.*",
"symfony/swiftmailer-bundle": "2.2.*",
"symfony/monolog-bundle": "2.2.*",
"sensio/distribution-bundle": "2.2.*",
"sensio/framework-extra-bundle": "2.2.*",
"sensio/generator-bundle": "2.2.*",
"jms/security-extra-bundle": "1.4.*",
"jms/di-extra-bundle": "1.3.*",
"sonata-project/cache-bundle": "dev-master",
"sonata-project/block-bundle": "dev-master",
"sonata-project/jquery-bundle": "1.8.*",
"knplabs/knp-menu-bundle": "1.1.*-dev",
"sonata-project/exporter": "1.1.*",
"sonata-project/admin-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"doctrine/common": "2.3.x-dev",
"sonata-project/media-bundle": "dev-master"
},
"scripts": {
"post-install-cmd": [
"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": [
"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"
},
"minimum-stability": "dev",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"branch-alias": {
"dev-master": "2.2-dev"
}
}
}