Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🚀 Composer template for Drupal projects. Quick installation via "composer create-project drupal-composer/drupal-project"

License

NotificationsYou must be signed in to change notification settings

drupal-composer/drupal-project

Repository files navigation

CILICENSE

This project template provides a starter kit for managing your sitedependencies withComposer.

Important

Drupal 11 branch is available!

What does the template do?

  • Drupal will be installed in theweb directory.
  • Generated composer autoloadervendor/autoload.php is used instead ofweb/vendor/autoload.php provided by Drupal core.
  • Modules (packages of typedrupal-module) will be placed inweb/modules/contrib directory.
  • Themes (packages of typedrupal-theme) will be placed inweb/themes/contrib directory.
  • Profiles (packages of typedrupal-profile) will be placed inweb/profiles/contrib directory.
  • Creates default writable versions ofsettings.php andservices.yml.
  • Createsweb/sites/default/files directory.
  • Drush is installed for use asvendor/bin/drush.
  • Provides anexample of the.env file.

Installing

Note

The instructions below refer to theglobal Composer installation.You might need to replacecomposer withphp composer.phar (or similar)for your setup.

Create your project:

composer create-project drupal-composer/drupal-project:10.x-dev some-dir --no-interaction

Thecomposer create-project command passes ownership of all files to theproject that is created. You should create a new Git repository, and commitall files not excluded by the.gitignore file.

Usage

Adding new dependencies

Usecomposer require to include and download dependencies for your project.

cd some-dircomposer require drupal/devel

By default, this project is set to install only stable releases of dependencies,as specified by"minimum-stability": "stable" incomposer.json. If you needto use non-stable releases (e.g.,alpha,beta,RC), you can modify theversion constraint to allow for such versions. For instance, to require a betaversion of a module:

composer require drupal/devel:1.0.0-beta1

Alternatively, you can globally adjust the stability settings by modifyingcomposer.json to include the desired stability level and explicitly allow it:

{"minimum-stability":"beta","prefer-stable":true}

This configuration ensures that stable releases are preferred, but allows theinstallation of non-stable packages when necessary.

Adding libraries

You can manage front-end asset libraries with Composer thanks to theasset-packagist repository. Composer will detectand install new versions of a library that meet the stated constraints.

composer require bower-asset/dropzone

Custom installation paths for libraries

The installation path of a specific library can be controlled by adding it totheextra.installer-paths configuration precedingweb/libraries/{$name}.For example, thechosen Drupal module expects thechosen library to belocated onweb/libraries/chosen, butcomposer require npm-asset/chosen-jsinstalls the library intoweb/libraries/chosen-js. The following configurationoverrides installation it into the expected directory:

{"extra": {"installer-paths": {"web/libraries/chosen": ["npm-asset/chosen-js"            ],"web/libraries/{$name}": ["type:drupal-library","type:npm-asset","type:bower-asset"            ]        }    }}

For more details, seehttps://asset-packagist.org/site/about

Updating Drupal Core

This project will attempt to keep all of your Drupal Core files up-to-date; theprojectdrupal/core-composer-scaffoldis used to ensure that your scaffold files are updated every timedrupal/coreis updated.

If you customize any of the "scaffolding" files (commonly.htaccess),you may need to merge conflicts if any of your modified files are updated in anew release of Drupal core.

Follow the steps below to update your Drupal core files.

  1. Runcomposer update "drupal/core-*" --with-dependencies to update Drupal Core and its dependencies.
  2. Rungit diff to determine if any of the scaffolding files have changed.Review the files for any changes and restore any customizations to.htaccess orrobots.txt.
  3. Commit everything all together in a single commit, soweb will remain insync with thecore when checking out branches or runninggit bisect.
  4. In the event that there are non-trivial conflicts in step 2, you may wishto perform these steps on a branch, and usegit merge to combine theupdated core files with your customized files. This facilitates the useof athree-way merge tool such as kdiff3. This setup is not necessary if your changes are simple;keeping all of your modifications at the beginning or end of the file is agood strategy to keep merges easy.

FAQs

Should I commit the contrib modules I download?

Composer recommendsno. They provideargumentation against but alsoworkarounds if a project decides to do it anyway.

Should I commit the scaffolding files?

TheDrupal Composer Scaffoldplugin can download the scaffold files (likeindex.php,update.php etc.) totheweb directory of your project. If you have not customized those files youcould choose to not check them into your version control system (e.g. git).If that is the case for your project, it might be convenient to automaticallyrun the drupal-scaffold plugin after every install or update of your project.You can achieve that by registering@composer drupal:scaffold aspost-installandpost-update command in yourcomposer.json:

"scripts": {"post-install-cmd": ["@composer drupal:scaffold","..."    ],"post-update-cmd": ["@composer drupal:scaffold","..."    ]},

How can I apply patches to included dependencies?

If you need to apply patches, you can do so with thecomposer-patches plugin includedin this project.

To add a patch to Drupal modulefoobar, insert thepatches section in theextra section ofcomposer.json:

"extra": {"patches": {"drupal/foobar": {"Patch description":"URL or local path to patch"        }    }}

How do I specify a PHP version?

There are 2 places where Composer will be looking for PHP version requirementswhen resolving dependencies:

  1. Therequire.php version value incomposer.json.
  2. Theconfig.platform version value incomposer.json.

The purpose ofrequire.php is to set the minimum PHP language requirementsfor a package. For example, the minimum version required for Drupal 10.0 is8.0.2 or above, which can be specified as>=8.

The purpose ofconfig.platform is to set the PHP language requirements for thespecific instance of the package running in the current environment. Forexample, while the minimum version required for Drupal 10 is8.0.2 or above,the actual PHP version on the hosting provider could be8.1.0. The value ofthis field should provide your exact version of PHP with all 3 parts of theversion.

Which versions to specify in my Drupal site?

This project includesdrupal/core which already hasrequire.php added. Yourwould inherit that constraint. There is no need to addrequire.php to yourcomposer.json.

config.platform is a platform-specific. It is recommended to specifyconfig.platform as aspecific version (e.g.8.1.19) constraint to ensurethat only the package versions supported by your current environment are used.

"config": {"platform": {"php":"8.1.19"    }},

About

🚀 Composer template for Drupal projects. Quick installation via "composer create-project drupal-composer/drupal-project"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors55

Languages


[8]ページ先頭

©2009-2025 Movatter.jp