I have build a library using some of the Symfony2 components and Doctrine. I now want to use this library inside a Symfony2 console app. I have included my library through Composer as a vendor, however, I'm getting the following error when I execute my library code:
PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Bundle "default" does not exist or it is not enabled.' in /home/user/project/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php:90
I'm not sure what the "default" bundle would be, how this is related to Doctrine or how to start to debug this.
Any help much appreciated.
UPDATE:
This is the Composer.json for my console app:
{
"name": "my/console",
"type": "application",
"repositories": [
{
"type": "vcs",
"url": "git#bitbucket.org:my/library.git"
}
],
"require": {
"php": ">=5.3.3",
"my/library": "dev-dev-master"
},
"autoload": {
"psr-0": {
"My\\": ["src/"]
}
}
}
This is the Composer.json for my library:
{
"name": "my/library",
"type": "library",
"keywords": [
"my", "library"
],
"homepage": "https://www.mine.com/",
"autoload": {
"psr-0": { "My\\": ["src/"] }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": "2.3.*",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"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.*",
"underscore/underscore.php": "1.3.1",
"sami/sami": "v1.1"
},
"scripts": {
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache"
],
"post-update-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache"
]
},
"config": {
"bin-dir": "bin"
},
"minimum-stability": "stable",
"extra": {
"symfony-app-dir": "app"
}
}
You can see what is causing this in the AbstractDoctrineExtension. As you can see, this error has something to do with the mappings you have defined in your config file.
It is also mentioned here that this error is triggered by an error in the mappings, just try to comment out what you have in the mappings.
orm:
auto_generate_proxy_classes: %kernel.debug%
default_entity_manager: default
entity_managers:
default:
mappings:
#whatever you have here
Related
I recently made a composer update on my Symfony app (2.7). Since I did this update, swiftmailer went from 2.4 to 2.5 and after the command, the console displayed me this error:
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
Unable to replace alias "swiftmailer.mailer.default.transport.real" with actual definition "mail".
[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
You have requested a non-existent service "mail".
I tried to remove the swiftmailer directory in "vendor", but it didnt work.
Here's my composer.json:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-4": { "": "src/" }
},
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.7.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~4.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/user-bundle": "dev-master"
},
"require-dev": {
"sensio/generator-bundle": "~2.3",
"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": "7.0"
}
},
"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.7-dev"
}
}
}
Thank you in advance for your help.
This has definitely been happening since today. (I'm on Symfony 2.8.17.) Reverting the Swiftmailer bundle back to version 2.4 fixed this for me.
In your composer.json file change
"symfony/swiftmailer-bundle": "~2.3",
to
"symfony/swiftmailer-bundle": "2.4",
Now do a composer update so you go back to version 2.4 of the Swiftmailer bundle and all should be well. Looks like there is a bug in the 2.5 update.
--
If you're still having problems try these commands to fully flush out cache:
rm -rf app/cache/*
rm app/bootstrap.php.cache
Also check your composer.lock file to ensure that the Swiftmailer bundle really has reverted back to 2.4. You should see a section like this:
{
"name": "symfony/swiftmailer-bundle",
"version": "v2.4.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/swiftmailer-bundle.git",
"reference": "ad751095576ce0c12a284e30e3fff80c91f27225"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/swiftmailer-bundle/zipball/ad751095576ce0c12a284e30e3fff80c91f27225",
"reference": "ad751095576ce0c12a284e30e3fff80c91f27225",
"shasum": ""
},
"require": {
"php": ">=5.3.2",
"swiftmailer/swiftmailer": ">=4.2.0,~5.0",
"symfony/config": "~2.7|~3.0",
"symfony/dependency-injection": "~2.7|~3.0",
"symfony/http-kernel": "~2.7|~3.0"
},
"require-dev": {
"symfony/console": "~2.7|~3.0",
"symfony/framework-bundle": "~2.7|~3.0",
"symfony/phpunit-bridge": "~2.7|~3.0",
"symfony/yaml": "~2.7|~3.0"
},
"suggest": {
"psr/log": "Allows logging"
},
"type": "symfony-bundle",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Bundle\\SwiftmailerBundle\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien#symfony.com"
}
],
"description": "Symfony SwiftmailerBundle",
"homepage": "http://symfony.com",
"time": "2016-12-20T04:44:33+00:00"
},
Most likely the issue you're describing was not caused by a bug, but by changed related dependency to swiftmailer/swiftmailer.
You have requested a non-existent service "mail". says that a service mail is missing, Unable to replace alias "swiftmailer.mailer.default.transport.real" with actual definition "mail". is a broad hint that this is related to swfitmailer transport mail, the class Swift_Transport_MailTransport using insecure php mail() function. This transport is deprecated since
swiftmailer version 5.4.5 for security reasons.
In order to fix the issue, you need to
switch from transport mail to a transport supported by current swiftmailer, or
add "swiftmailer/swiftmailer": "<6.0" to your composer.json dependencies in order to prevent packages from installing swiftmailer v6.x where Swift_Transport_MailTransport is gone. Unfortunately, symfony/swiftmailer-bundle requires swiftmailer v6.x starting from v3.0.0, so you would need to require "symfony/swiftmailer-bundle": "^2"
I can not get Moltin Cart plugin to install for symfony 2.7. I get following issues when I try to install.
Problem 1
- Installation request for moltin/cart dev-master -> satisfiable by moltin/c
art[dev-master].
- moltin/cart dev-master requires moltin/tax dev-master -> no matching packa
ge found.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your min
imum-stability setting
This is my composr.lock
.....
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=5.3.3"
},
.....
And this is my composer.json complete file
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/", "SymfonyStandard": "app/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.5.*",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"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": "~3.0,>=3.0.12",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2",
"incenteev/composer-parameter-handler": "~2.0",
"symfony/var-dumper": "^2.7",
"jms/serializer-bundle": "^1.0",
"symfony/finder": "^2.7",
"moltin/cart": "dev-master"
},
"require-dev": {
"sensio/generator-bundle": "~2.3"
},
"scripts": {
"post-root-package-install": [
"SymfonyStandard\\Composer::hookRootPackageInstall"
],
"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",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
],
"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",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
]
},
"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.5-dev"
}
}
}
This is Moltin/cart site page link. It would be great help if someone can look into it.
If you want to install a package that depends on non-stable packages, you will to explicitly require those packages too or lower the minimum stability setting in your project's Composer configuration.
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"
}
}
}
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
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.