Symfony 2.8 is the last release of the 2.x branch and the previous LTS.
Symfony 3.4 is the last release of the 3.x branch and the current LTS.
What steps are required in order to upgrade Symfony from 2.8 to 3.4 and switch to this last LTS?
Prepare upgrade
Check that all the dependencies and bundles listed in composer.json have published a version compatible with Symfony 3.4, you can do this by searching each package on Packagist, for example EasyAdmin is compatible with Symfony 3 because the dependencies in the requires are not limited to Symfony 2 (we would see something like symfony/*: ~2.3). If one of the dependencies it not compatible with Symfony 3, you'll have to find replacement packages or patch these libraries.
composer.json
In order to upgrade you app from Symfony 2.8 to Symfony 3.4 you'll have to update your dependencies by changing your composer.json file:
([…] indicates unchanged code)
Old (2.8) version:
{
[…]
"autoload-dev": {
"files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
},
"require": {
"php": ">=5.3.9",
"doctrine/doctrine-bundle": "~1.4",
"doctrine/orm": "^2.4.8",
"incenteev/composer-parameter-handler": "~2.0",
"sensio/distribution-bundle": "~4.0",
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/monolog-bundle": "^3.0.2",
"symfony/swiftmailer-bundle": "~2.3,>=2.3.10",
"symfony/symfony": "2.8.*",
"twig/twig": "^1.0||^2.0"
},
"require-dev": {
"sensio/generator-bundle": "~3.0",
"symfony/phpunit-bridge": "~2.7"
},
"config": {
"bin-dir": "bin",
"platform": {
"php": "5.6"
},
"sort-packages": true
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative",
[…]
"branch-alias": {
"dev-master": "2.8-dev"
}
}
}
New (3.4) version:
{
[…]
"autoload-dev": {
"psr-4": { "Tests\\": "tests/" },
"files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]
},
"require": {
"php": ">=5.5.9",
"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": "^5.0.0",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"twig/twig": "^1.0||^2.0"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
},
"config": {
"platform": {
"php": "5.6"
},
"sort-packages": true
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
[…]
"branch-alias": {
"dev-master": "3.4-dev"
}
}
}
Summary
autoload-dev.psr-4 has been added (it has to be changed with the path to your tests directory)
Symfony and dependencies are updated
symfony/polyfill-apcu is a new dependency
extra has been updated in order to use new directory structure: var for temporary files, etc.
config.bin-dir has been removed
More details about upgrades: → 3.0, → 3.1, → 3.2, → 3.3, → 3.4
app/AppKernel.php
Add getRootDir and update registerContainerConfiguration functions:
public function getRootDir()
{
return __DIR__;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
Cache and logs
If you want to put cache and logs in var/, you have to update your app/AppKernel.php file by adding the following lines:
public function getCacheDir()
{
return dirname(__DIR__).'/var/cache/'.$this->getEnvironment();
}
public function getLogDir()
{
return dirname(__DIR__).'/var/logs';
}
Then create the var/ directory and put an empty file .gitkeep
And apply these changes to your .gitignore file:
/var/cache/*
/var/logs/*
!var/cache/.gitkeep
!var/logs/.gitkeep
See also: What is the new Symfony 3 directory structure?
Final steps
Once you have updated your composer.json file, you have to update the dependencies:
composer update
Then you may need to flush the cache:
php app/console cache:clear --env=dev
Note: I used the following command in order to get the composer.json files:
# create Symfony "2.8.*" project in the "2.8" directory
composer create-project symfony/framework-standard-edition "2.8" "2.8.*" --no-interaction -v
# create Symfony "3.4.*" project in the "3.4" directory
composer create-project symfony/framework-standard-edition "3.4" "3.4.*" --no-interaction -v
# compare the Symfony 2.8 and 3.4 composer.json files
diff -u 2.8/composer.json 3.4/composer.json
The diff is available at GitHub too.
Bonus: enable autowiring of services.
2019+ Instant Upgrades Version
Today, you can automate most of the work with instant upgrade tool called Rector (I'm author of). It has prepared sets for many frameworks, the Symfony ones are most complete. Also include PHP upgrade, that you might need.
You can read more about this particular upgrade path in: How to Upgrade Symfony 2.8 to 3.4
Related
I have a Symfony 3.4 project I'm trying to upgrade to 4.x with Flex but I'm falling at the first hurdle.
With the output of Composer this verbose I assume the answer is staring me straight in the face, but I'm not seeing it. What do I need to do? I've deleted everything in vendor, deleted my composer.lock file, cleared composer cache, etc.
composer.json
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"sensio/framework-extra-bundle": "^5.5",
"symfony/console": "4.4.*",
"symfony/dotenv": "4.4.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "4.4.*",
"symfony/monolog-bundle": "^3.5",
"symfony/orm-pack": "^1.0",
"symfony/profiler-pack": "^1.0",
"symfony/twig-pack": "^1.0",
"symfony/yaml": "4.4.*",
"friendsofsymfony/jsrouting-bundle": "^2.5",
"friendsofsymfony/user-bundle": "~2.0",
"stof/doctrine-extensions-bundle": "^1.3",
"symfony/swiftmailer-bundle": "^2.6.4",
"ext-json": "*"
},
"require-dev": {
"symfony/debug-pack": "^1.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.19",
"phpstan/phpstan-doctrine": "^0.12.10",
"phpunit/phpunit": "^7.5",
"symfony/phpunit-bridge": "^3.0"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"#auto-scripts"
],
"post-update-cmd": [
"#auto-scripts"
]
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.4.*"
}
}
}
Tried to composer install with:
php -d memory_limit=-1 /usr/local/bin/composer install
And it spews all this out (too big to paste here): https://pastebin.com/KLVRkYdF
Saw something elsewhere about needing to install Flex on its own first, so I tried this:
php -d memory_limit=-1 /usr/local/bin/composer update symfony/flex --no-plugins --no-scripts
But got the following error (too big to paste here): https://pastebin.com/KxG2siZi
The problem is that you haven't updated symfony/swiftmailer-bundle - as given in the composer.json, you tried to install at most v2.6.7 which requires symfony/http-kernelin v2.7 or v3.x. This is not compatible with symfony/framework-bundle in v4.4, as this requires symfony/http-kernel to be of that same v4.4 branch.
Conclusion: also update symfony/swiftmailer-bundle to at least v3.1 which is the first one to be compatible with Symfony v4.
I also had a lot of issues with composer, packageversions and memory limits in the past.
Package vesions:
Set all symfony packages to the version "*" if yout dont require a specific Version at this point. Thisway composer will select the one suitable to your configured symfony version.
Memory limit:
Which IDE are you using? Which PHP Version? 32 or 64 bit? Try running the commany outside of the IDE and see what happens. Alternatively try the symfony command.
This looks like a simple issue, but I can't explain what's happening.
In composer.json for my Symfony project the twig version is specified as <2.0, to avoid breaking changes between v1 and v2. However, Composer installs the latest Twig version (2.4.3) anyway.
php c:\php\composer\composer.phar depends -t "twig/twig"
twig/twig v2.4.3 Twig, the flexible, fast, and secure template language for PHP
|--symfony/framework-standard-edition dev-develop (requires twig/twig <2.0)
|--symfony/symfony v2.8.24 (requires twig/twig ~1.34|~2.4)
| `--symfony/framework-standard-edition dev-develop (requires symfony/symfony 2.8.*)
`--twig/extensions v1.5.1 (requires twig/twig ~1.27|~2.0)
`--symfony/framework-standard-edition dev-develop (requires twig/extensions ^1.3)
Relevant chunk of composer.json:
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.8.*",
"doctrine/dbal": "2.5.*",
"doctrine/orm": "2.5.*",
"doctrine/doctrine-bundle": "~1.2",
"twig/twig": "<2.0",
"twig/extensions": "^1.3",
etc
}
It looks to me like the requirements of the symfony/symfony and twig/extensions packages, combined with those of the project, would result in the highest possible 1.x version of Twig, 1.34.4, but that's not what happens. Why?
EDIT:
Composer 1.4.2
Full composer.json
{
"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.8.*",
"doctrine/dbal": "2.5.*",
"doctrine/orm": "2.5.*",
"doctrine/doctrine-bundle": "~1.2",
"twig/twig": "<2.0",
"twig/extensions": "^1.3",
"symfony/assetic-bundle": "^2.8",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0",
"sensio/framework-extra-bundle": "~3.0",
"incenteev/composer-parameter-handler": "~2.0",
"beberlei/DoctrineExtensions": "^1.0",
"royopa/fpdf-symfony2": "^1.0",
"liuggio/excelbundle": "^2.0",
"patchwork/jsqueeze": "^2.0",
"leafo/scssphp": "^0.6.5",
"doctrine/doctrine-migrations-bundle": "^1.0",
"ocramius/proxy-manager": "~2.0.0",
"aws/aws-sdk-php-symfony": "^1.2"
},
"require-dev": {
"sensio/generator-bundle": "~2.3",
"symfony/phpunit-bridge": "^3.1",
"deployer/deployer": "^3.3"
},
"scripts": {
"post-root-package-install": [
"SymfonyStandard\\Composer::hookRootPackageInstall"
],
"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",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
],
"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",
"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"
}
}
}
EDIT 2:
Deleting composer.lock and completely updating and reinstalling gives me what I thought I should get!
What version of composer are you using?
I tested that json file on a Linux Mint 17, with php 5.5 and composer 1.3.2 and the twig version installed is the right one (twig/twig - v1.34.4).
Can you try to paste your complete composer.json file?
Also, I suggest removing the composer.lock file and all the contents of the vendor folder and try the install again.
I'm trying to deploy my Symfony app to Microsoft Azure.
I have created a service plan, App, made sure PHP is v5.6 (on which I developed the app locally), added the php_intl.dll extension, pushed files from Git and when running __ php -d extension=php_intl.dll composer.phar install __ after vendor are installed I get the below errors. I run this command in the cloud Kudu command console.
What am I doing wrong? How do I deploy? The guide on Symfony.com is a bit outdated but got me up until this step.
Generating autoload files
Deprecation Notice: The callback Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap declared at D:\home\site\wwwroot\vendor\sensio\distribution-bundle\Composer\ScriptHandler.php accepts a Composer\Script\CommandEvent but post-install-cmd events use a Composer\Script\Event instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes in phar://D:/home/site/wwwroot/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:290
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
Deprecation Notice: The callback Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache declared at D:\home\site\wwwroot\vendor\sensio\distribution-bundle\Composer\ScriptHandler.php accepts a Composer\Script\CommandEvent but post-install-cmd events use a Composer\Script\Event instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes in phar://D:/home/site/wwwroot/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:290The symfony-bin-dir (bin) specified in composer.json was not found in D:\home\site\wwwroot, can not clear the cache.
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
Deprecation Notice: The callback Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets declared at D:\home\site\wwwroot\vendor\sensio\distribution-bundle\Composer\ScriptHandler.php accepts a Composer\Script\CommandEvent but post-install-cmd events use a Composer\Script\Event instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes in phar://D:/home/site/wwwroot/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:290
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets
Deprecation Notice: The callback Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile declared at D:\home\site\wwwroot\vendor\sensio\distribution-bundle\Composer\ScriptHandler.php accepts a Composer\Script\CommandEvent but post-install-cmd events use a Composer\Script\Event instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes in phar://D:/home/site/wwwroot/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:290
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile
The symfony-bin-dir (bin) specified in composer.json was not found in D:\home\site\wwwroot, can not install assets.
The symfony-bin-dir (bin) specified in composer.json was not found in D:\home\site\wwwroot, can not install the requirements files.
Deprecation Notice: The callback Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget declared at D:\home\site\wwwroot\vendor\sensio\distribution-bundle\Composer\ScriptHandler.php accepts a Composer\Script\CommandEvent but post-install-cmd events use a Composer\Script\Event instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes in phar://D:/home/site/wwwroot/composer.phar/src/Composer/EventDispatcher/EventDispatcher.php:290
> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget
Composer.json file:
{
"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" ]
},
"autoload-dev": {
"psr-4": { "Tests\\": "tests/" }
},
"require": {
"php": ">=5.5.9",
"symfony/symfony": "3.0.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "^2.8",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"symfony/console": "^3.0",
"symfony/assetic-bundle": "^2.7",
"symfony/security": "^3.0",
"knplabs/knp-menu-bundle": "^2.1",
"twbs/bootstrap": "^3.3",
"gregwar/captcha-bundle": "^2.0",
"friendsofsymfony/rest-bundle": "^1.7",
"jms/serializer-bundle": "^1.1",
"ci/restclientbundle": "^1.0",
"eightpoints/guzzle-bundle": "^4.4",
"jasongrimes/paginator": "^1.0",
"knplabs/knp-paginator-bundle": "^2.5",
"liip/imagine-bundle": "^1.5",
"symfony/dependency-injection": "^3.0",
"sensio/generator-bundle": "^3.0",
"symfony/event-dispatcher": "^3.0",
"friendsofsymfony/jsrouting-bundle": "^1.6",
"league/oauth2-client": "^1.4",
"league/oauth2-facebook": "^1.4"
},
"require-dev": {
"symfony/phpunit-bridge": "^2.7"
},
"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",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"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",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "3.0-dev"
}
}
}
I never deployed on Microsoft Azure but so far it looks like some resources are not where they're expected. Have a look to your composer.json
You need to make sure that your .gitignore file has the following so that composer knows which requirements need to be installed
!bin/console
!bin/symfony_requirements
As documented by gitignore/Symfony.gitignore here
I'm getting error below when trying to install Behat+Mink+Selenium. What could be the solution?
php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for symfony/framework-standard-edition 2.4.x-dev -> satisfiable by symfony/framework-standard-edition[2.4.x-dev].
- symfony/framework-standard-edition 2.4.x-dev requires behat/behat 2.4.*#stable -> no matching package found.
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Composer.json:
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"minimum-stability": "dev",
"autoload": {
"psr-0": { "": "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",
"behat/behat": "2.4.*#stable",
"behat/mink": "1.4.*#stable",
"behat/mink-extension": "*",
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*",
"behat/symfony2-extension": "*",
"behat/mink-browserkit-driver": "*",
"behat/mink-sahi-driver": "*",
"phpunit/phpunit": "3.7.*"
},
"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'm following these two blogs to install it:
Installing, configuring and running Behat on Symfony2 with Mink and
Selenium
Installing Behat, Mink and Selenium2 for Symfony2
IMO, you have registered too many packages. For example, behat is a dependency of the symfony2-extension. So, just need to require the symfony2-extension and behat will be required :) The problem when you require everything explicitly is you need to check if every packages constraints can work together on packagist (which can becomes a pain)...
For a Symfony 2.4 project, I would use the following packages:
"require-dev": {
"behat/symfony2-extension": "~1.1",
"behat/mink-extension": "~1.3",
"behat/mink-selenium2-driver": "~1.1",
"behat/mink-goutte-driver": "~1.0",
}
I would suggest run composer require, and before you installing do a composer update so that all dependencies are at updated version. So the below dependencie were usesful for my symfony2.8 project:
composer update
composer require behat/behat
composer require behat/symfony2-extension
composer require behat/mink
composer require behat/mink-browserkit-driver
composer require behat/mink-extension
composer require behat/mink-goutte-driver
composer require behat/mink-selenium2-driver
composer require emuse/behat-html-formatter
composer require coduo/php-matcher
Since Im getting error messages about the icu version When running php composer.phar install, I have added this line below as said here:
"symfony/icu": "1.1.*",
So my composer.json is like this:
{
"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/icu": "1.1.*",
"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",
"ziiweb/frontendbundle": "#dev",
"friendsofsymfony/user-bundle": "~2.0#dev",
"sonata-project/admin-bundle": "dev-master",
"sonata-project/core-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"sonata-project/media-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": "stable",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.3-dev"
}
}
}
But after installing again, I get this errors:
Problem 1
- The requested package symfony/icu could not be found in any version, there may be a typo in the package name. Problem 2
- Installation request for symfony/framework-standard-edition 2.3.x-dev -> satisfiable by symfony/framework-standard-edition[2.3.x-dev].
- symfony/framework-standard-edition 2.3.x-dev requires symfony/icu 1.1.* -> no matching package found. Problem 3
- Installation request for symfony/symfony v2.3.8 -> satisfiable by symfony/symfony[v2.3.8].
- symfony/symfony v2.3.8 requires symfony/icu ~1.0 -> no matching package found. Problem 4
- symfony/symfony v2.3.8 requires symfony/icu ~1.0 -> no matching package found.
- sonata-project/media-bundle 2.2.x-dev requires symfony/symfony ~2.2 -> satisfiable by symfony/symfony[v2.3.8].
- Installation request for sonata-project/media-bundle 2.2.x-dev -> satisfiable by sonata-project/media-bundle[2.2.x-dev].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details
.
it is "symfony/Icu" with capital letter
You need to download the INTL extension of PHP.Go to http://pecl.php.net/get/intl-3.0.0.tgz
Tar that file, and compile it with the following commands.
tar zxvf intl-3.0.0.tgz
cd intl-3.0.0
/usr/bin/phpize
./configure --with-php-config=[YOUR OWN INSTALLED PHP DIRECTORY]/bin/php-config
Update your php.ini.
extension=intl.so
Restart your php server
By the way, if the problem still shows up after you finish above procedures, please check if you install that extension for PHP CLI. You know there are different php.ini files for PHP and PHP CLI sometimes.
what worked for me was deleting the composer.lock file, then do a composer install.
edit: I also deleted the vendor directory