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!
09.
Updating the TwigBundle Recipe
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!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
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
}
}
17 Comments
Hello, I'm trying to update some of the recipes and similar to the comment below I have an error when I try to execute composer recipes:update symfony/console: [Symfony\Component\Console\Exception\RuntimeException] Cannot run "sync-recipes --force": git not found.
I'm working on a Symfony 4.4 project, with docker wsl2 local setup using Ubuntu 20.04, the git it's initialized on my project, but in the php container seems it's missing, but I'm not sure how to fix this, any ideas?
symfony/flex -> "version": "v1.18.5"
Hey Tatiana,
Looks like there's no "git" command in the terminal when you run that command, do you have Git installed in your system? Behind the scene, recipes:update command leverages Git power to apply the change in your project. If you don't have Git - please, install it first, it's required for that command. If you do have Git installed - most probably you don't have "git" command available in the terminal where you run that command. E.g. on windows you probably have Git bash, try to run that recipe:update command from that Git bash terminal where "git" command should be available.
For the Docker container - it depends on what OS it's based on. Try to find the Dockerfile of that image on hub.docker.com and then search over the internet how to install Git in that OS. Otherwise, you can try to run that command upstream in case you have PHP installed in your Ubuntu you mentioned, or in case you have it's installed locally - run that command locally then.
Cheers!
Hello !! ..While trying to upgrade my project from symfony 4.2 to symfony 5 I couldn't update recipes for exple
when I run composer recipes:install "symfony/twig-bundle" --force -v
I got the error:
[Symfony\Component\Console\Exception\RuntimeException]
Cannot run "sync-recipes --force": git not found.
Exception trace:
() at D:\doc\test\quick_tour\vendor\symfony\flex\src\Command\InstallRecipesCommand.php:54
Symfony\Flex\Command\InstallRecipesCommand->execute() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Command/Command.php:245
Symfony\Component\Console\Command\Command->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:835
Symfony\Component\Console\Application->doRunCommand() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:185
Symfony\Component\Console\Application->doRun() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Console/Application.php:258
Composer\Console\Application->doRun() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:117
Symfony\Component\Console\Application->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Console/Application.php:104
Composer\Console\Application->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/bin/composer:61
require() at C:\ProgramData\ComposerSetup\bin\composer.phar:24
I googled a little and tried execute this command composer sync-recipes --force
but still getting the same error [Symfony\Component\Console\Exception\RuntimeException]
Cannot run "sync-recipes --force": git not found.
Hey hanen
I'm wondering it's telling you that git was not found. My first guess is that you haven't initialized git in your project. Let me know if that's not the case so we can figure this out
Cheers!
I run
git init
git satus
modified: composer.json
modified: composer.lock
modified: config/bundles.php
modified: symfony.lock
git add .
>composer recipes:install "symfony/twig-bundle" --force -v
Could not open input file: D:\doc\test\quick_tour\composer.phar
Hello hanen
I think it might be related with your environment. Probably not all paths are registered in Windows environment. It's quite difficult to advice something. Which shell and Windows version do you use?
BTW for best work behavior I would recommend to use WSL shell with Windows 10
Cheers.
I use cmder terminal on wind 7
Ok, lets try another way, try to upgrade flex package with
composer upgrade symfony/flexHi, SymfonyCasts team !
I <i>dockerized</i> my own app which works great, but the Symfony code lies in the
/app/directory of my Git project. I think that's why I got the annoying confirmation messages according to <a href="https://github.com/symfony/flex/blob/master/src/Options.php#L68-L72">this source code</a>.But using the wonderful process of
git add -pandgit checkoutI surely wanted to overwrite and then check which changes to commit. I used the--no-interactionoption but it did not modify the files as I expected, only created new ones. Is this normal ? I don't know if it worths opening an issue on GitHub.Here is the complete command I executed (
docker exec -it apptells docker to execute a command in the container) and its output:`
$> docker exec -it app composer recipes:install --no-interaction symfony/twig-bundle --force -v
Symfony operations: 1 recipe (a163a92832df72d8c7b4f86bf8da9837)
Enabling the package as a Symfony bundle
Copying files from recipe
`
<b>EDIT:</b> I don't think that's a file permission issue as it correctly modifies file when I answer the interactive overwrite questions using the same command without the
--no-interactionoption.Cheers !
Hey AymDev,
Well, it depends on changes :) Why do you think the command works incorrectly? From the output, I see it does work properly, its output is totally valid. Well, IIRC it always says "Created ..." but technically it may create a new file or *modify* existent :)
Cheers!
Hi Victor,
I updated the Twig recipe, and saw that id did not modify
./templates/base.html.twigor./config/packages/twig.yamlas shown on this video at <b>1:25</b>, it only created the./config/packages/test/twig.yaml.I understood by following this tutorial (for the 2nd time, by the way) that it modifies file even if it says "Created", but my base template was not modified, and my twig.yaml neither, that's why I think it is working incorrectly.
Maybe it is normal to not overwrite existing files in non-interactive mode when no git repository has been found but I found it counter-intuitive. Maybe I should dig more in the source code, haha !
Hey AymDev,
Hm, difficult to day more about it. You could try to do the same but locally (not in your Docker container). It should behave the same. I don't think it should be any different behavior in for interactive and non-interactive mode, but I'm not 100% sure.
The only possible reason I see is that your project just does not have any changes in those existent files.
Cheers!
Hi Victor,
I re-updated the recipe in Git <i>detached HEAD state</i> by executing the command locally and you were right, it works nice :-)
The issue must come from the container, sad I can't use the
--no-interactionoption but hopefully that's not for an everyday command !Sorry for your time and thanks again for your answers !
Hey AymDev,
Hm, probably there's a reason that it works slightly different with --no-interaction option. But as I understand, you can kind of "jump" into container and execute that some command but without --no-interaction option now. Probably it would help.
Anyway, glad you found a workaround!
Cheers!
You should've tried 'e' (edit) option in [y,n,q,a,d,s,e,?] set when accepting git patch. You can selectively accept changes.
And another handy thing for new git files. You can just add file to git stage but not its contents with git add -N /path/to/file. And after that you can add its contents via git add -p /path/to/file.
Hey Xiro!
You're right! I've never really "gotten into" some of the other options inside "git patch" :). I do use the split "s" when possible - but not edit. I'll have to try that!
Thanks for the tip - and cheers :)
weaverryan No problem, love your tuts. Save me tons of time in real projects. Thank you and your team for your work! :)
And one more thing about git commits. Standartisation for...
* Capitalized
* In imperative present tense
Naming convention git commit messages
It should be read like "If applied it will"... 'Update symfony/twig-bundle'
"Houston: no signs of life"
Start the conversation!