Selectively Committing Recipe Updates

Video not working?

It looks like your browser may not support the H264 codec. If you're using Linux, try a different browser or try installing the gstreamer0.10-ffmpeg gstreamer0.10-plugins-good packages.

Thanks! This saves us from needing to use Flash or encode videos in multiple formats. And that let's us get back to making more videos :). But as always, please feel free to message us.

We just... sort of... accidentally updated the MonologBundle recipe by removing that package and reinstalling it. Doing that modified several files.

Let's add the changes we know we want to keep to git:

git add composer.json composer.lock symfony.lock

For the other changes - the ones the recipe made - we need to be very careful. Why? Because recipes don't really "upgrade" in some clean way. Nope, when we removed the packages, some config files we deleted... which means any custom code we had in those was removed. When we reinstalled the packages, the recipes re-added these files... but any custom code we had is gone.

So, we do want to "accept" any new, cool changes to these files that a newer version of the recipe may have added. But we do not want our custom code to disappear.

Changeset Swiss Army Knife: git add -p

My favorite way to sort all of this out is to run:

git add -p

This interactive command looks at every change one-by-one and asks whether or not you want to add it. For bundles.php... this isn't a file that we usually add custom code to - so it should be safe. It looks like it's removing MonologBundle, but it actually just moved this line. Hit y to add this change. And... yep! Here is the line being added-back. Hit y again. That change was meaningless.

The next change is in config/packages/dev/monolog.yaml: it wants to remove a markdown_logging handler. Hey! No! This is our custom code. Say n to not add this change.

Updated Recipes Show New Features

Finally, in the production monolog.yaml file, it changed excluded_404s to excluded_http_codes. This is awesome. The excluded_http_codes - which is basically a way to help you log errors... but not things like 404 errors - is a relatively new feature that didn't exist when we originally installed MonologBundle. The updated recipes is telling us about a feature that we may not know about it!

Should we accept this change? It's up to you. Do you like this new way of filtering logs? I do: because I don't like having 405 errors in my logs: that's when someone, for example, makes a GET request to a URL that only allows POST requests. Sometimes a bot will do that. Let's hit "y" to add this change.

And... it's done! Run:

git status

to see what it did. Cool. All the changes we do want are up in the "staged" area and ready for commit. The one change that is not staged - down here in red - was the one change that we did not want to commit.

Removing Unwanted Changes

To undo that change - so it goes back to the way it was before - run:

git checkout config/packages/dev/monolog.yaml

Now you can safely commit these changes however you want, like:

git commit -m "moving packages into require"

I'll let you make that commit.

Congrats! You just got your first experience upgrading a recipe. Was it necessary? Not really. The newer version of MonologBundle would have worked fine if we had kept our existing config files exactly like they were. But it did teach us about a new feature... which was kind of awesome.

Next: let's start updating our recipes for real. We'll learn about some new commands that Flex adds to composer to help with this.

Leave a comment!

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
        "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
        "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.6.2
        "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
    }
}