Project template for developing Drupal core with a git clone.

Overview

Drupal Core Development Composer Project

This is a Composer project template for developing Drupal core.

It allows:

  • a clean git clone of Drupal core.
  • Composer dependencies of Drupal core are installed, so Drupal can be installed and run as normal.
  • other Composer packages you might want, such as Drush, Devel module, and Admin Toolbar module, can be installed too, but don't affect the composer files that are part of Drupal core.

Installation

To install a Drupal project for working on Drupal core:

$ composer create-project joachim-n/drupal-core-development-project

Composer will clone Drupal core into a 'repos/drupal' directory within the project, and then symlink that into the project when it installs Drupal core.

Once the installation is complete, you can install Drupal as normal, either with drush si or with the web UI.

Limitations

Most Drush commands work, but drush cr does not. To rebuild the Drupal container and clear caches, install Devel module and use its menu items instead.

A fix is being worked on: see https://www.drupal.org/project/drupal/issues/1792310.

Developing Drupal core

You can use the Drupal core git clone at 'repos/drupal/' in any way you like: create feature branches, clone from drupal.org issue forks, and so on. Changes you make to files in the git clone affect the project, since the git clone is symlinked into it.

Managing the Composer project

You can install any Composer packages you like, including Drupal contrib modules, without affecting the git clone of Drupal core. To work with Composer, you need to be in the root directory of the project.

Changes to the git clone's composer.json will be taken into account by Composer. So for example, if pulling from the main branch of Drupal core changes Composer dependencies, you should run Composer on the project to install these.

Running tests

The following are required to run tests.

PHPUnit configuration

The simplest way to run tests with this setup is to put the phpunit.xml file in the project root and then run tests from there:

$ vendor/bin/phpunit web/core/PATH-TO-TEST-FILE/TestFile.php

To set this up, copy Drupal core's sample phpunit.xml file to the project root:

$ cp web/core/phpunit.xml.dist phpunit.xml

Then change the bootstrap attribute so the path is correct:

Technical details

The rest of this document is gory technical details you only need to know if you're working on this project template or debugging it.

How it works

The composer.json at the project root uses a Composer path repository so that when the drupal/drupal package is installed, it's symlinked in from the Drupal core git clone, at the branch that the clone has checked out.

Drupal core itself defines path repositories in its top-level composer.json. These need to be overridden in the project root composer.json so they point to inside the Drupal core git clone.

Manual Installation

Clone the repository for this template into, say, 'drupal-dev'.

$ cd drupal-dev

# Create a folder in which to store git clones, which Composer will symlink in.
$ mkdir repos
$ cd repos

# Clone Drupal core, to whatever branch you like.
$ git clone --branch 9.2.x https://git.drupalcode.org/project/drupal.git

# Go back to the project root.
$ cd ..

# Install packages with Composer.
$ composer install

The Drupal core git clone will be clean apart from:

	sites/default/settings.php
	vendor

Since it doesn't have a .gitignore at the top level, you can add one to ignore those files if you like.

Project template development installation

To test how Composer creates a new project from the template, you need a git clone of the template repository.

In a separate location, do:

$ composer create-project joachim-n/drupal-core-development-project NEW_PROJECT_DIRECTORY --stability=dev --repository='{"url": "/path/to/git/clone/of/project/template/", "type": "vcs"}'

Workarounds

Several workarounds are necessary to make Drupal core work correctly when symlinked into the project. These are all taken care of by Composer scripts during installation. Details are below.

Vendor folder

The vendor folder has to be symlinked into the Drupal core repository, because otherwise code in core that expects to find a Composer autoloader fails.

This is done by a Composer script after initial installation. The manual command is:

ln -s ../../vendor ./repos/drupal/vendor

App root index.php patch

The index.php scaffold file has to be patched after it has been copied to web/index.php, because otherwise DrupalKernel guesses the Drupal app root as incorrectly being inside the Drupal core git clone, which means it can't find the settings.php file.

This is done by a Composer script after initial installation. The manual command is:

cd web && patch -p1 <../scaffold/scaffold-patch-index-php.patch

See https://www.drupal.org/project/drupal/issues/3188703 for more detail.

Simpletest folder

When running browser tests, the initial setup of Drupal in FunctionalTestSetupTrait::prepareEnvironment() creates a site folder using the real file locations with symlinks resolved, thus repos/drupal/sites/simpletest, but during the request to the test site, Drupal looks in /web/sites/simpletest.

Additionally, the HTML files output from Browser tests are written into the Drupal core git clone, and so the URLs shown in PHPUnit output are incorrect.

The fix for both of these is to create the simpletest site folder in the web root and symlink it into the Drupal core git clone.

This is done by a Composer script after initial installation. The manual command is:

mkdir -p web/sites/simpletest
ln -s ../../../web/sites/simpletest repos/drupal/sites
Issues
  • Error messages when running composer install, after switching from Drupal core 9.2.x to 9.1.x

    Error messages when running composer install, after switching from Drupal core 9.2.x to 9.1.x

    There is no issue running the steps below when starting a new project with git -

    1. git clone https://git.drupalcode.org/project/drupal.git
    2. cd drupal
    3. composer install (installs drupal 9.2.x by default)
    4. git checkout 9.1.x
    5. composer install

    The steps above, running both composer Install go smooth with no errors.


    But when running similar commands using this repo as a base, results in error - Steps to reproduce:

    1. composer create-project joachim-n/drupal-core-development-project (will install drupal 9.2.x by default)
    2. cd repos/drupal
    3. git checkout 9.1.x
    4. composer install

    error message:

    Generating autoload files
    Could not scan for classes inside "core/lib/Drupal.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Component/DependencyInjection/Container.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Component/FileCache/FileCacheFactory.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Component/Utility/Timer.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Component/Utility/Unicode.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Cache/Cache.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Cache/CacheBackendInterface.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Cache/CacheTagsChecksumInterface.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Cache/CacheTagsInvalidatorInterface.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Cache/DatabaseBackend.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Database/Connection.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Database/Database.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Database/Driver/mysql/Connection.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Database/Statement.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Database/StatementInterface.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/DependencyInjection/Container.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/DrupalKernel.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/DrupalKernelInterface.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Installer/InstallerRedirectTrait.php" which does not appear to be a file nor a folder
    Could not scan for classes inside "core/lib/Drupal/Core/Site/Settings.php" which does not appear to be a file nor a folder
    Class Drupal\Core\Composer\Composer is not autoloadable, can not call pre-autoload-dump script
    
    
      [RuntimeException]
      Could not scan for classes inside "core/lib/Drupal.php" which does not appear to be a file nor a fold
      er
    
    
    install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-scripts] [--no-progress] [--no-install] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>]...
    
    

    Running composer update instead of the last composer install, runs smoothly, no errors.

    opened by shaal 4
This is a simple example project demonstrating the Lupus Nuxt.js Drupal Stack.

Lupus Nuxt.js Drupal Stack - Example project This is a simple example project demonstrating the Lupus Nuxt.js Drupal Stack. Introduction Please refer

drunomics 6 Apr 16, 2021
A Laravel 5 package that switchs default Laravel scaffolding/boilerplate to AdminLTE template and Pratt Landing Page with Bootstrap 3.0

AdminLTE template Laravel package A Laravel package that switch default Laravel scaffolding / boilerplate to AdminLTE template with Bootstrap 3.0 and

Sergi Tur Badenas 1.8k May 22, 2021
:computer: :octocat: A hackathon/MVP boilerplate for laravel web applications. Start your hackathons without hassle.

Laravel Hackathon Starter - SUSUMU 進 If you have attended any hackathons in the past, then you know how much time it takes to get a project started: d

Prosper Otemuyiwa 1.6k Jun 14, 2021
Someline Starter is a PHP framework for quick building Web Apps and Restful APIs, with modern PHP design pattern foundation.

Someline Starter PHP Framework Tested and used in production by Someline Inc. Someline Starter is a PHP framework for quick building Web Apps and Rest

Someline 852 Jun 3, 2021
Start a new Laravel 8 project with the AdminLTE template installed.

AdminLTE template Laravel 8 package Start a new Laravel 8 project with the AdminLTE template installed. Installation Create database. Clone repository

Mairo Rodrigues 3 Jun 4, 2021
Laravel Vue SPA, Bulma themed. For demo login use `[email protected]` & `password` -

Laravel Enso Hit the ground running when building your new Laravel SPA project with boilerplate and extra functionality out of the box! click on the p

Laravel Enso 982 Jun 12, 2021
An example of Laravel app that runs in a docker container with RoadRunner

This repository contains an example of Laravel (PHP Framework) application that runs in a docker container with RoadRunner (high-performance PHP appli

Paramtamtam 14 Jun 17, 2021
PinteClone - Pinterest clone using Symfony 5

PinteClone PinteClone can be used: to find the best picture that you need. Programming languages & Frameworks used: PHP Javascript Twig Css (Bootstrap

Iliass Alami Qammouri 3 Apr 26, 2021
It's a template for using Temporal with Laravel

Temporal Integration with Laravel Make sure you have PHP 7.4 and laravel 8.* , or higher, installed. Temploral PHP SDK is available as composer packag

Improwised Technologies Pvt. Ltd. 5 Jun 13, 2021
Cipi is a Laravel based cloud server control panel that supports Digital Ocean, AWS, Vultr, Google Cloud, Linode, Azure and other VPS.

Cipi is a Laravel based cloud server control panel that supports Digital Ocean, AWS, Vultr, Google Cloud, Linode, Azure and other VPS. It comes with nginx, Mysql, multi PHP-FPM versions, multi users, Supervisor, Composer, npm, free Let's Encrypt certificates, Git deployment, backups, ffmpeg, fail2ban, Redis, API and with a simple graphical interface useful to manage Laravel, Codeigniter, Symfony, WordPress or other PHP applications. With Cipi you don’t need to be a Sys Admin to deploy and manage websites and PHP applications powered by cloud VPS.

Andrea Pollastri 443 Jun 19, 2021
🍪 A Cookiecutter template for a fresh Kirby site

Kirby Plainkit Cookiecutter A Cookiecutter template to start a fresh Kirby site with a public folder setup. Features A fresh, git(Hub)-ready plainkit

BESTE 4 Apr 30, 2021
Build and deploy Non-Fungible Algorand Tokens with Laravel & IPFS

Introduction Laravel is a web application framework with an expressive, elegant syntax designed to make developing web apps easier and faster through

Tomas Verhelst 4 May 30, 2021
Rest API boilerplate for Lumen micro-framework.

REST API with Lumen 5.5 A RESTful API boilerplate for Lumen micro-framework. Features included: Users Resource OAuth2 Authentication using Laravel Pas

Hasan Hasibul 471 Jun 2, 2021