Apply a patch

We’re going to see today how to apply a patch. A patch or fix is a section of code added to an application/site/etc. to make modifications, such as fixing a bug.

In the context of our work, we use solutions like Ibexa DXP, and sometimes before the release of a higher version, it can happen that a bug is detected. Here, we have the choice, depending on the severity of the bug, to either wait for the new version and perform an update or apply the provided patch.

We’ll give an example of a component named ezplatform-graphql.

Before applying the patch locally, it’s advisable to test it using the –dry-run parameter.

The command is launched from the concerned component

  • vendor/ezsystems/ezplatform-graphql
  • patch -p1 –dry-run -i /PATH_TO_THE_PATCH_FILE_EZP-322.patch

If the test is successful, and you don’t encounter any ‘hunk failed’ errors, then apply the patch using the following command

  • patch -p1 -i /PATH_TO_THE_PATCH_FILE_EZP-322.patch

You can always revert back using the command

  • patch -p1 -R -i /PATH_TO_THE_PATCH_FILE_EZP-322.patch

Now, let’s imagine that you want to apply the patch on the staging or production server, considering that the folders in the vendor directory are read-only. In this case, the solution is to use the Composer Patch Plugin. Therefore, you need to install cweagans/composer-patches.

All of this will be done in the composer.json file

    "extra": {
        "symfony": {
            "allow-contrib": true,
            "require": "5.3.*",
            "endpoint": ""
        "patches": {
            "ezsystems/ezplatform-graphql": {
                "FIX IBX-657": "../patchs/IBX-657.patch",
                "FIX IBX-659": "../patchs/IBX-659.patch"

With this piece of code, the patches will be applied during the build of your application

After applying the patch, don’t forget to clear the cache.