gstreamer0.10-ffmpeg
gstreamer0.10-plugins-good
packages.
Our project is now on Symfony 4.0, and it still works! Well, it almost works: we would just need to remove a few references to SensioDistributionBundle
and SensioGeneratorBundle
.
The point is this: if you want, you can upgrade to Symfony 4, but not migrate to the new Flex project structure. That's fine.
But... since Flex is awesome... let's do it!
Flex is a Composer plugin, and, it's pretty simple: when you install a package, it checks to see if there is a recipe for that package. A recipe can add configuration files, auto-enable the bundle, add paths to your .gitignore
file and more. But, for Flex to work, you need to use the Flex directory structure.
So here's the plan: we're going to bootstrap a new Flex application right inside our existing project. Then, little-by-little, we'll move our code and configuration into it. It's going to be pretty freakin' cool.
Before we start, make sure that your Composer is at the latest version:
composer self-update
Seriously, do this. Composer recently released a bug fix that helps Flex.
Ok, so... let's install Flex!
composer require symfony/flex
As soon as this is in our project, it will find and install recipes each time we add a new library to our project. In fact, check it out!
Configuring symfony/flex
Ha! Flex even installed a recipe for itself! What an over-achiever! Let's find out what it did:
git status
Of course, it modified composer.json
and composer.lock
. But there are two new files: .env.dist
and symfony.lock
. Open the first.
How did this get here? It was added by the symfony/flex
recipe! More about this file later.
Next, look at symfony.lock
. This file is managed by Flex: it keeps track of which recipes were installed. You should commit it, but not think about it.
Because this is an existing project, our app already contains a bunch of vendor libraries... and a lot of these might have recipes that were never installed because Flex wasn't in our project yet! Lame! No problem! Empty the vendor/
directory and run composer install
rm -rf vendorcomposer install
Normally, Flex only installs a recipe when you first composer require
a library. But Flex knows that the recipes for these libraries were never installed. So it runs them now.
Yea! 11 recipes! Woh! And one of them is from the "contrib" repository. There are two repositories for recipes. The official one is heavily guarded for quality. The "contrib" one also has some checks, but the quality is not guaranteed. That's why you see this question. I'll type "p" to permanently allow recipes from contrib.
Run git status
to see what changed:
git status
Woh! We have a new config/
directory and a lot more! Starting with nothing, Flex is scaffolding the new project around us! It's even auto-enabling all the bundles in a new bundles.php
file.
Sweet!
When you start a new Flex project, you actually clone this symfony/skeleton repository... which is literally one file: composer.json
. This has a few really important things in it, including the fact that it requires symfony/framework-bundle
but not symfony/symfony
.
Let's work on that next!
// composer.json
{
"require": {
"php": "^7.1.3",
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/doctrine-bundle": "^1.6", // 1.8.1
"doctrine/doctrine-cache-bundle": "^1.2", // 1.3.2
"doctrine/doctrine-migrations-bundle": "^1.1", // v1.3.1
"doctrine/orm": "^2.5", // v2.7.2
"fzaninotto/faker": "^1.7", // v1.7.1
"knplabs/knp-markdown-bundle": "^1.4", // 1.6.0
"sensio/framework-extra-bundle": "^5.0", // v5.1.3
"stof/doctrine-extensions-bundle": "dev-master", // dev-master
"symfony/asset": "^4.0", // v4.0.1
"symfony/console": "^4.0", // v4.0.1
"symfony/flex": "^1.0", // v1.9.10
"symfony/form": "^4.0", // v4.0.1
"symfony/framework-bundle": "^4.0", // v4.0.1
"symfony/lts": "^4@dev", // dev-master
"symfony/maker-bundle": "^1.0", // v1.0.2
"symfony/monolog-bundle": "^3.1", // v3.1.2
"symfony/polyfill-apcu": "^1.0", // v1.6.0
"symfony/profiler-pack": "^1.0", // v1.0.3
"symfony/security-bundle": "^4.0", // v4.0.1
"symfony/security-csrf": "^4.0",
"symfony/swiftmailer-bundle": "^3.1", // v3.1.6
"symfony/translation": "^4.0", // v4.0.1
"symfony/twig-bundle": "^4.0", // v4.0.1
"symfony/validator": "^4.0", // v4.0.1
"symfony/web-server-bundle": "^4.0", // v4.0.1
"symfony/yaml": "^4.0" // v4.0.1
},
"require-dev": {
"symfony/dotenv": "^4.0", // v4.0.1
"symfony/phpunit-bridge": "^4.0", // v4.0.1
"doctrine/doctrine-fixtures-bundle": "^3.0" // 3.0.2
}
}