How to change Drupal core files

4
(1)

I will say right away that this is a very, very bad idea. Making changes to the drupal core is necessary only when there is no other way to solve the problem. Any drupal update can break all your edits.

  1. Create a repository in the core git folder
cd /path/to/drupal/core
git init
git add .
git commit -am 'Initial commit'

  1. Make changes to the core files.
  2. Create a patch in the patches folder:
mkdir /path/to/drupal/patches
cd /path/to/drupal/core
git diff > /path/to/drupal/patches/my-drupal-core-hacks.patch

It is important that the patches folder is located next to the main composer.json

  1. Install the cweagans/composer-patches package:
cd /path/to/drupal
composer require cweagans/composer-patches

We add information about the patch to the main composer.json:

{
    ...
    "extra": {
        "patches": {
            "drupal/core": {
                "My drupal core hacks": "patches/my-drupal-core-hacks.patch"
            }
        }
    }
}

6.Remove the git repository from core:

rm -rf /path/to/drupal/core/.git

A patch will now be applied automatically when updating the drupal core. Similarly, you can make changes to other modules in this way.

Similar Posts:

607

How useful was this post?

Click on a star to rate it!

Average rating 4 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top