How to modify the concrete5 core with Composer patches

Sometimes you want to change something in concrete5, but it can't be done easily via a package or with some custom code. What can we do in such a case? Well, of course we don't want to modify the core concrete5 files. Unless...?

Yes, unless there is a proper way to do so of course! I came across a solution watching the concrete5 Github repository where mlocati posted an interesting approach I had not heard of before. Important, you need a Composer based installation of concrete5 for this approach.

How does it work?

Here's how you can apply a patch to the concrete5 core:

  1. Fork the concrete5 repository, if you haven't yet.
  2. Commit your changes to the core in your local fork.
  3. Create a patch file:
# The -1 is the number of commits that should be included in the patch file.
git format-patch --stdout -1 > your-patch-file.patch


If you need a patch from an existing commit, you can use 'git format-patch -1 THE_SHA_HASH'.

  1. Copy the file to your repository, e.g. to 'patches/your-patch-file.patch'.
  2. Add this section to your composer.json file:
"extra": {
  "patches": { 
      "concrete5/core": { 
          "A descriptive title of your patch": "patches/your-patch-file.patch"


  1. Make sure you add cweagans/composer-patches to your Composer dependencies via:
composer require "cweagans/composer-patches:~1.0"

7. Run 'composer install' to apply to patch(es).

When do I need this approach?

It can be handy in case:

  • concrete5 hasn't merged your pull request, but you really need the change.
  • a certain file or class can't be overridden easily.
  • you need a small tweak / customization in the core, but you don't want to maintain a fork, and you don't think concrete5 will merge a pull request with the change.

Need help?

Make sure you join Slack via and ask your question in the #dev channel.