Chapters
29 Chapters
|
3:14:24
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.1.3
Subscribe to download the code!Compatible PHP versions: ^7.1.3
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
06.
Recipe Upgrade: symfony/console & bootstrap.php
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
What PHP libraries does this tutorial use?
// 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/annotations": "^1.0", // 1.10.1
"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
"phpdocumentor/reflection-docblock": "^3.0|^4.0", // 4.3.4
"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.21.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/property-access": "4.4.*|5.0.*", // v5.0.2
"symfony/property-info": "4.4.*|5.0.*", // v5.0.2
"symfony/security-bundle": "5.0.*", // v5.0.2
"symfony/sendgrid-mailer": "5.0.*", // v5.0.2
"symfony/serializer": "4.4.*|5.0.*", // v5.0.2
"symfony/twig-bundle": "5.0.*", // v5.0.2
"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/extra-bundle": "^2.12|^3.0", // v3.0.1
"twig/inky-extra": "^2.12", // v2.12.0
"twig/twig": "^2.12|^3.0" // v2.14.4
},
"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/stopwatch": "4.4.*|5.0.*", // v5.0.2
"symfony/var-dumper": "5.0.*", // v5.0.2
"symfony/web-profiler-bundle": "4.4.*|5.0.*" // v5.0.2
}
}
19 Comments
is config/bootstrap.php no longer part of a recipe?
Hey Kieran B.
Yes it's so. It was dropped in Symfony 5.1 IIRC
Cheers!
Thanks Vladimir,
When updating recipes, does flex not remove files that are no longer used. Seems that the bootstrap file I had integrated with an older version of dotenv. The site worked file but when I installed phpunit then it would check to see if the bootstrap file was there and try to include it causing an issue. Removing the file manually worked but it did make me wonder what other cleanup I need to do.
Yeah that's a bummer! I also faced this issue when updated some projects. Honestly I don't know good approach to find such cases, I think the only way is to check recipes while updating stuff.
Cheers!
Trying to perform a "minor" version upgrade <b>[ 5.2 to 5.3 ]</b>
on a fresh/clean symfony 5.2 project
(i.e.
`composer create-project symfony/website-skeleton:"5.2.*" s5test` )Then i just add a home page for testing purposes (https://symfony.com/doc/current/page_creation.html)
In composer.json: i change:
"symfony/...": "5.2." to "symfony/...": "5.3."
"symfony/...": "^5.2 to "symfony/...": "^5.3"
[
composer update "symfony/*" --with-all-dependencies] runs okTo complete the upgrade i need to install 6 recipes
recipes: [symfony/routing, symfony/security-bundle, symfony/translation, symfony/twig-bundle] install ok...
<i>But with these 2 recipes:</i>
<b>- symfony/console: </b>
after I install this one, when i run
composer update:i get:
Executing script cache:clear [KO] [KO] Script cache:clear returned with error code 255 !! Script @auto-scripts was called via post-update-cmdand
php bin/console cache:cleardoes not do anything along with any other console cmd<b>- symfony/framework-bundle:</b>
after I install this one i get an empty page on my browser
no debug toolbar and nothing at var/log/dev.log
<b>To sum it up:</b> after installing these 2 recipes:
anyone had this issue ? any hints?
installing runtime
`composer require symfony/runtime`
solves this issue...
for some reason at my setup the error did not hint a solution
while at an other setup it did.... found it at stackoverflow after posting a question there...
Hey Polychronis,
Good catch on that "symfony/runtime". Unfortunately, it's difficult to say what may goes wrong without seeing the exact errors. For the future, I'd recommend you too check logs - they may hind with some problems. And yeah, another way to search on StackOverflow is also a good idea, well done :)
Cheers!
Doing this moved my .env.dist to .env and created the bootstrap.php + some additional .env.local and .env.test...
I really do not want to use .env files, I have for example 10 clients on the same machine, each of them has different db credentials, so the parameters should be different... The old good parameters.yaml, untracked from git, was perfect... is it possible to use symfony 5 without the dotenv component?
You should also read this
you should open an issue on github :)
It seems I can't because the bin/console now has hardcoded references to dotenv... I'll leave it even if the variables inside the .env are not used anywhere
Hey Trafficmanagertech ,
It still should be possible to use old-known parameters.yaml instead of env vars in Symfony. I'm not sure 100% if it works out of the box now (I think it should), but you may need to modify a few files in your project that link to the .env files. Also, for clarity, if you don't use env vars at all - I'd suggest to remove .env files completely from your project... or at least remove all env vars in those files. Unfortunately, if you use Symfony Flex - it will try to modify .env files on composer commands. If you want to continue using Symfony Flex - you would probably need to manually revert .env changes after each Composer installation.
About bin/console - you should be able to specify in what env you want to run the Symfony command with "--env" option, e.g:
"$ bin/console --env=prod"
Anyway, using parameters.yaml instead is still should be possible. Though, I'd recommend you to get used to .env files instead. Mostly, it's the same parameters but more flexible. I hope this helps!
Cheers!
Hi, thank you very much,
yes we are already phasing out the parameters.yaml and moving all the settings to a `settings` table in the db, the only one setting that will remain will be the db connection string and you're right, it could be moved to the .env... (ultimately we want to move also that to the db, using a different db_name depending on the HTTP_HOST... we have a SaaS platform with up to 50 clients on one machine and it would be much easier)
Hey Trafficmanagertech ,
Glad to hear you found a workaround! Yeah, it's up to you, but probably leaving as is using .env for DB connection is the simplest solution.
Cheers!
Hey Trafficmanagertech
That's a good question. If you don't want to manage your env vars in the Symfony way, you can totally do it. The first option would be to do what you did, just ignore the .env files and keep going. Or, you can modify the
config/bootstrap.phpto stop trying to use theDotEnvcomponent and implement your own logic to initialize your env vars. Does it makes sense to you?Cheers!
I fell at the first hurdle with
composer recipes symfony/consolethrowing:[Symfony\Component\Console\Exception\CommandNotFoundException] <br />Command "recipes" is not defined.Running
composer updatefixed it.Hey Nicholas,
Please, make sure you have the latest version of Composer. If not - try to upgrade to the latest. And if you still don't see the command - upgrade "symfony/flex" to the latest version as well. Let me know if after these steps you still don't have "recipes" command :)
Cheers!
Hey Ryan !
there's a little error here :
composer recipes install symfony/console --force -vIt's missing the
:between composer & recipes.By the way, thanks for your amazing work on symfonycasts :)
Hey Didier2l,
Thank you for reporting it! I just merged PR that fixes it: https://github.com/knpunive... . So now it's fixed :)
Cheers!
"Houston: no signs of life"
Start the conversation!