gstreamer0.10-ffmpeg
gstreamer0.10-plugins-good
packages.
To upgrade from Symfony 4.3 to 4.4 - that's a "minor" version upgrade - we need to change the extra.symfony.require
value to 4.4.*
- done! - and update each Symfony package version to that same value.
Let's get to work! I'll start with symfony/asset
: change it to 4.4.*
. Copy that and start repeating it:
{ | |
... lines 2 - 3 | |
"require": { | |
... lines 5 - 20 | |
"symfony/asset": "4.4.*", | |
"symfony/console": "4.4.*", | |
... line 23 | |
"symfony/form": "4.4.*", | |
"symfony/framework-bundle": "4.4.*", | |
"symfony/mailer": "4.4.*", | |
"symfony/messenger": "4.4.*", | |
... line 28 | |
"symfony/security-bundle": "4.4.*", | |
"symfony/sendgrid-mailer": "4.4.*", | |
... line 31 | |
"symfony/twig-bundle": "4.4.*", | |
... line 33 | |
"symfony/validator": "4.4.*", | |
"symfony/web-server-bundle": "4.4.*", | |
... line 36 | |
"symfony/yaml": "4.4.*", | |
... lines 38 - 40 | |
}, | |
... lines 42 - 95 | |
"extra": { | |
"symfony": { | |
... lines 98 - 99 | |
"require": "4.4.*" | |
} | |
} | |
} |
I will skip a few packages that start with symfony/
because they are not part of the main Symfony repository - like symfony/flex
:
{ | |
... lines 2 - 3 | |
"require": { | |
... lines 5 - 22 | |
"symfony/flex": "^1.0", | |
... lines 24 - 40 | |
}, | |
... lines 42 - 102 | |
} |
These follow their own release schedules... so they usually have a version that's very different than everything else.
All "packs" - those are the, sort of, "fake" packages that just require other packages for convenience - are another example:
{ | |
... lines 2 - 3 | |
"require": { | |
... lines 5 - 27 | |
"symfony/orm-pack": "^1.0", | |
... lines 29 - 30 | |
"symfony/serializer-pack": "^1.0", | |
... line 32 | |
"symfony/twig-pack": "^1.0", | |
... lines 34 - 40 | |
}, | |
... lines 42 - 102 | |
} |
These usually allow pretty much any version of the libraries inside of them - so any Symfony packages will update correctly. If you want more control over the versions, remember that you can run:
composer unpack symfony/orm-pack
When you do that, Flex will remove this line and replace it with the individual packages so you can manage their versions. That's not required, but also not a bad idea.
WebpackEncoreBundle is another example of a package that isn't part of the main repository - you can see that its version is totally different:
{ | |
... lines 2 - 3 | |
"require": { | |
... lines 5 - 35 | |
"symfony/webpack-encore-bundle": "^1.4", | |
... lines 37 - 40 | |
}, | |
... lines 42 - 102 | |
} |
Don't forget to also check the require-dev
section: there are a bunch here:
{ | |
... lines 2 - 41 | |
"require-dev": { | |
... lines 43 - 45 | |
"symfony/browser-kit": "4.4.*", | |
"symfony/debug-bundle": "4.4.*", | |
"symfony/dotenv": "4.4.*", | |
... lines 49 - 50 | |
"symfony/phpunit-bridge": "4.4.*", | |
... line 52 | |
"symfony/var-dumper": "4.4.*" | |
}, | |
... lines 55 - 102 | |
} |
Including symfony/debug-bundle
, which has a funny-looking version because I unpacked it from a debug-pack
in one of our courses. And both MakerBundle and MonologBundle are not in the main repository:
{ | |
... lines 2 - 41 | |
"require-dev": { | |
... lines 43 - 48 | |
"symfony/maker-bundle": "^1.0", | |
"symfony/monolog-bundle": "^3.0", | |
... lines 51 - 53 | |
}, | |
... lines 55 - 102 | |
} |
If you're not sure, you can search Packagist.org for symfony/symfony
. That package lists all of the packages that make up this "main" repository I keep talking about.
Update phpunit-bridge
, leave the profile-pack
version and update var-dumper
:
{ | |
... lines 2 - 41 | |
"require-dev": { | |
... lines 43 - 50 | |
"symfony/phpunit-bridge": "4.4.*", | |
... line 52 | |
"symfony/var-dumper": "4.4.*" | |
}, | |
... lines 55 - 102 | |
} |
Perfect! We have 4.4.*
everywhere up here and 4.4.*
for extra.symfony.require
so that everything matches and we get that performance boost in Composer.
Let's do this! Find your terminal and run:
Tip
We need this for our course CI, just ignore this note and follow the tutorial without executing these commands :)
sed -i 's/"4.3.*"/"4.4.*"/g' ./composer.json
sed -i 's/"^4.0"/"4.4.*"/g' ./composer.json
sed -i 's/"^3.3|^4.0"/"4.4.*"/g' ./composer.json
composer update "symfony/*"
And... yea! It's upgrading the last few libraries that were previously locked to 4.3
. Congratulations! You just upgraded all Symfony packages to 4.4.
Before we move on, I noticed a small problem in composer.json
: the symfony/dotenv
package is in my require-dev
section:
{ | |
... lines 2 - 41 | |
"require-dev": { | |
... lines 43 - 47 | |
"symfony/dotenv": "4.4.*", | |
... lines 49 - 53 | |
}, | |
... lines 55 - 102 | |
} |
When we put something in require-dev
, we're saying:
This package is not needed when I run my code on production.
It was true that when Symfony 4.0 was released, the DotEnv component was used in the development environment only - as a way to help set environment variables more easily. That's not true anymore: Symfony apps now always load the .env
files.
The symfony/monolog-bundle
package - which gives us the logger
service - should also live under require
- along with its supporting package: easy-log-handler
:
{ | |
... lines 2 - 41 | |
"require-dev": { | |
... line 43 | |
"easycorp/easy-log-handler": "^1.0.2", | |
... lines 45 - 49 | |
"symfony/monolog-bundle": "^3.0", | |
... lines 51 - 53 | |
}, | |
... lines 55 - 102 | |
} |
Logging is something we always want.
Let's fix these. Copy the symfony/dotenv
package name, find your terminal, and remove these three packages:
composer remove --dev symfony/dotenv symfony/monolog-bundle easycorp/easy-log-handler
An easy way to move a package from require-dev
to require
and make sure that Composer notices, is to remove the package and re-add it.
When we do that... our code explodes! No problem: our app totally needs the DotEnv component... so it's temporarily freaking out. You'll also notice that, if you run:
git status
Removing these packages also removed their recipes. Re-add the libraries by using that same command, but replacing remove
with require
and getting rid of the --dev
flag:
composer require symfony/dotenv symfony/monolog-bundle easycorp/easy-log-handler
Tip
The easycorp/easy-log-handler
package is abandoned, so it's probably even better
to remove it from this list and leave it out of your app
This should add those back under the require
section - yep, here is one - and it will reinstall the latest version of their recipes... which means that the recipe could be slightly newer than the one we had before:
{ | |
... lines 2 - 3 | |
"require": { | |
... lines 5 - 7 | |
"easycorp/easy-log-handler": "^1.0", | |
... lines 9 - 23 | |
"symfony/dotenv": "4.4.*", | |
... lines 25 - 29 | |
"symfony/monolog-bundle": "^3.5", | |
... lines 31 - 43 | |
}, | |
... lines 45 - 102 | |
} |
This is... accidentally... the first example of upgrading a recipe. Run:
git status
Cool. Should we commit all of these changes? Not so fast. When a recipe is updated, you need to selectively add each change. Let's learn how next.
Hey there!
First of all, you need to figure out if there's something that you're using directly or if it's an indirect usage. If *you* are using those components - then yes, avoid using it and consider switching to the packages it recommends instead. For this, you may need to rewrite your code in spots where you're using them. But if it's an indirect usage - don't worry too much about it. Most probably, the latest version (most probably the next major version) of the package you use will switch from the abandoned packages to the new packages. So, in this case you need nothing to do, well, your job will be to upgrade your dependencies to the new major version.
To know *why* you have that package in the vendor/ directory in case you don't know - you can ask Composer! Just run "composer why" command and pass the package name as an argument, e.g.:
$ composer why zendframework/zend-code
Composer will explain you why you have this in your vendor/, i.e. what package is using (requiring) it.
Cheers!
Hi there !
I have upgraded Symfony 5.1 to 5.2, everything is working fine.
When I run
composer update "symfony/*" --with-all-dependencies
I get this
`Your requirements could not be resolved to an installable set of packages.
Problem 1
- doctrine/orm is locked to version 2.8.1 and an update of this package was not requested.
- doctrine/orm 2.8.1 requires doctrine/common ^3.0 -> found doctrine/common[3.0.0, ..., 3.1.0] but it conflicts with another require.
Problem 2
- doctrine/orm 2.8.1 requires doctrine/common ^3.0 -> found doctrine/common[3.0.0, ..., 3.1.0] but it conflicts with another require.
- hautelook/alice-bundle 2.8.0 requires doctrine/orm ^2.5.11 -> satisfiable by doctrine/orm[2.8.1].
- hautelook/alice-bundle is locked to version 2.8.0 and an update of this package was not requested.`
Should I worry about that ? What does it mean please ?
Hey Stileex,
It seems some dependencies are not going to updated with that command but to be able to upgrade symfony/* packages you have to update them as well. Updating all the dependencies, i.e. running "composer update" should help I think.
Cheers!
The EasyLogHandler was archived / abandoned, so it's probably not a good idea to install it anymore. https://github.com/symfony/...
Hey cristi-contiu!
Yea, I'm glad that package is gone - nice idea, but it's hard to implement that sort of thing, and so it was never done well. I've just added a note to the script (and we'll add a note to the video also) to tell people to just leave this "removed".
Cheers!
// composer.json
{
"require": {
"php": "^7.3.0",
"ext-iconv": "*",
"antishov/doctrine-extensions-bundle": "^1.4", // v1.4.2
"aws/aws-sdk-php": "^3.87", // 3.110.11
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/doctrine-bundle": "^2.0", // 2.0.6
"doctrine/doctrine-migrations-bundle": "^1.3|^2.0", // 2.1.2
"doctrine/orm": "^2.5.11", // v2.7.2
"doctrine/persistence": "^1.3.7", // 1.3.8
"easycorp/easy-log-handler": "^1.0", // v1.0.9
"http-interop/http-factory-guzzle": "^1.0", // 1.0.0
"knplabs/knp-markdown-bundle": "^1.7", // 1.8.1
"knplabs/knp-paginator-bundle": "^5.0", // v5.0.0
"knplabs/knp-snappy-bundle": "^1.6", // v1.7.0
"knplabs/knp-time-bundle": "^1.8", // v1.11.0
"league/flysystem-aws-s3-v3": "^1.0", // 1.0.23
"league/flysystem-cached-adapter": "^1.0", // 1.0.9
"league/html-to-markdown": "^4.8", // 4.8.2
"liip/imagine-bundle": "^2.1", // 2.3.0
"nexylan/slack-bundle": "^2.1", // v2.2.1
"oneup/flysystem-bundle": "^3.0", // 3.3.0
"php-http/guzzle6-adapter": "^2.0", // v2.0.1
"sensio/framework-extra-bundle": "^5.1", // v5.5.3
"symfony/asset": "5.0.*", // v5.0.2
"symfony/console": "5.0.*", // v5.0.2
"symfony/dotenv": "5.0.*", // v5.0.2
"symfony/flex": "^1.0", // v1.17.6
"symfony/form": "5.0.*", // v5.0.2
"symfony/framework-bundle": "5.0.*", // v5.0.2
"symfony/mailer": "5.0.*", // v5.0.2
"symfony/messenger": "5.0.*", // v5.0.2
"symfony/monolog-bundle": "^3.5", // v3.5.0
"symfony/security-bundle": "5.0.*", // v5.0.2
"symfony/sendgrid-mailer": "5.0.*", // v5.0.2
"symfony/serializer-pack": "^1.0", // v1.0.2
"symfony/twig-bundle": "5.0.*", // v5.0.2
"symfony/twig-pack": "^1.0", // v1.0.0
"symfony/validator": "5.0.*", // v5.0.2
"symfony/webpack-encore-bundle": "^1.4", // v1.7.2
"symfony/yaml": "5.0.*", // v5.0.2
"twig/cssinliner-extra": "^2.12", // v2.12.0
"twig/extensions": "^1.5", // v1.5.4
"twig/inky-extra": "^2.12" // v2.12.0
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0", // 3.3.0
"fzaninotto/faker": "^1.7", // v1.8.0
"symfony/browser-kit": "5.0.*", // v5.0.2
"symfony/debug-bundle": "5.0.*", // v5.0.2
"symfony/maker-bundle": "^1.0", // v1.14.3
"symfony/phpunit-bridge": "5.0.*", // v5.0.2
"symfony/profiler-pack": "^1.0", // v1.0.4
"symfony/var-dumper": "5.0.*" // v5.0.2
}
}
Any guidance regarding:
Package symfony/inflector is abandoned, you should avoid using it. Use use
EnglishInflectorfrom the String component instead instead.<br />Package zendframework/zend-code is abandoned, you should avoid using it. Use laminas/laminas-code instead.<br />Package zendframework/zend-eventmanager is abandoned, you should avoid using it. Use laminas/laminas-eventmanager instead.