Skip to content

Commit b262924

Browse files
committed
Committing initial copy of files from https://github.com/drupal-composer/drupal-project/tree/7.x
0 parents  commit b262924

9 files changed

+791
-0
lines changed

.gitignore

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Ignore directories generated by Composer
2+
/vendor/
3+
/web/sites/all/drush/
4+
/web/sites/all/modules/contrib/
5+
/web/sites/all/themes/contrib/
6+
/web/sites/all/libraries/
7+
8+
# Ignore Drupal 7 core files.
9+
/web/*
10+
!/web/*/
11+
/web/includes/
12+
/web/misc/
13+
/web/modules/
14+
/web/profiles/README.txt
15+
/web/profiles/minimal/
16+
/web/profiles/standard/
17+
/web/profiles/testing/
18+
/web/scripts/
19+
/web/sites/README.txt
20+
/web/sites/all/*/README.txt
21+
/web/sites/example.sites.php
22+
/web/themes/
23+
24+
# Ignore configuration files that may contain sensitive information.
25+
/web/sites/*/*.settings.php
26+
/web/sites/*/settings*.php
27+
28+
# Ignore paths that contain user-generated content.
29+
/web/sites/*/files
30+
/web/sites/*/private
31+
32+
# Ignore files generated by PhpStorm
33+
/.idea/

.travis.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
language: php
2+
dist: trusty
3+
sudo: false
4+
5+
php:
6+
- 5.6
7+
8+
env:
9+
global:
10+
- SIMPLETEST_DB=sqlite://tmp/site.sqlite
11+
- SIMPLETEST_BASE_URL="http://127.0.0.1:8080"
12+
matrix:
13+
- RELEASE=stable COMPOSER_CHANNEL=stable
14+
- RELEASE=dev COMPOSER_CHANNEL=stable
15+
- RELEASE=stable COMPOSER_CHANNEL=snapshot
16+
17+
before_install:
18+
- echo 'sendmail_path = /bin/true' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
19+
- phpenv config-rm xdebug.ini
20+
- composer --verbose self-update --$COMPOSER_CHANNEL
21+
- composer --version
22+
23+
install:
24+
- composer --verbose validate
25+
- composer --verbose install
26+
27+
script:
28+
- if [[ $RELEASE = dev ]]; then composer --verbose update; fi;
29+
- cd $TRAVIS_BUILD_DIR/web
30+
- ./../vendor/bin/drush site-install --verbose --yes --db-url=sqlite://tmp/site.sqlite
31+
- ./../vendor/bin/drush runserver $SIMPLETEST_BASE_URL &
32+
- until curl -s $SIMPLETEST_BASE_URL; do true; done > /dev/null
33+
- ./../vendor/bin/drush

LICENSE

+339
Large diffs are not rendered by default.

README.md

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Composer template for Drupal projects
2+
3+
[![Build Status](https://travis-ci.org/drupal-composer/drupal-project.svg?branch=7.x)](https://travis-ci.org/drupal-composer/drupal-project)
4+
5+
This project template provides a starter kit for managing your site
6+
dependencies with [Composer](https://getcomposer.org/).
7+
8+
If you want to know how to use it as replacement for
9+
[Drush Make](https://github.com/drush-ops/drush/blob/8.x/docs/make.md) visit
10+
the [Documentation on drupal.org](https://www.drupal.org/node/2471553).
11+
12+
## Usage
13+
14+
First you need to [install composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx).
15+
16+
> Note: The instructions below refer to the [global composer installation](https://getcomposer.org/doc/00-intro.md#globally).
17+
You might need to replace `composer` with `php composer.phar` (or similar)
18+
for your setup.
19+
20+
After that you can create the project:
21+
22+
```
23+
composer create-project drupal-composer/drupal-project:7.x-dev some-dir --no-interaction
24+
```
25+
26+
With `composer require ...` you can download new dependencies to your
27+
installation.
28+
29+
```
30+
cd some-dir
31+
composer require drupal/devel:~1.0
32+
```
33+
34+
The `composer create-project` command passes ownership of all files to the
35+
project that is created. You should create a new git repository, and commit
36+
all files not excluded by the .gitignore file.
37+
38+
## What does the template do?
39+
40+
When installing the given `composer.json` some tasks are taken care of:
41+
42+
* Drupal will be installed in the `web`-directory.
43+
* Modules (packages of type `drupal-module`) will be placed in `web/sites/all/modules/contrib/`
44+
* Theme (packages of type `drupal-module`) will be placed in `web/sites/all/themes/contrib/`
45+
* Profiles (packages of type `drupal-profile`) will be placed in `web/profiles/`
46+
* Libraries (packages of type `drupal-library`) will be placed in `web/sites/all/libraries/` (See Libraries)
47+
* Helps for using other PHP packages almost similar to the Drupal 8 version
48+
* Creates default writable versions of `settings.php`.
49+
* Creates `web/sites/default/files`-directory.
50+
* Latest version of drush is installed locally for use at `vendor/bin/drush`.
51+
52+
## Generate composer.json from existing project
53+
54+
With using [the "Composer Generate" drush extension](https://www.drupal.org/project/composer_generate)
55+
you can now generate a basic `composer.json` file from an existing project. Note
56+
that the generated `composer.json` might differ from this project's file.
57+
58+
## How to enable the Composer autoloader in your Drupal 7 website
59+
60+
The skeleton already installs the `composer_autoloader` module. Just enable it in the website before enabling
61+
any possible module that have dependencies various packages.
62+
63+
## Libraries
64+
65+
Libraries normally would be extra packages that need to be public available (CSS and JS).
66+
Normally this are not maintained using Composer, but if you want to have a 100% Composer deployment and benefit from patches you can use in `composer.json` this example, changing the `repositories` section and adding in `require` section:
67+
```
68+
69+
"repositories": [
70+
...
71+
{
72+
"type": "package",
73+
"package": {
74+
"name": "kenwheeler/slick",
75+
"version": "1.6.0",
76+
"dist": {
77+
"url": "https://github.com/kenwheeler/slick/archive/1.6.0.zip",
78+
"type": "zip"
79+
},
80+
"source": {
81+
"url": "https://github.com/kenwheeler/slick.git",
82+
"type": "git",
83+
"reference": "1.6.0"
84+
},
85+
"type": "drupal-library"
86+
}
87+
}
88+
],
89+
"require": {
90+
...
91+
"kenwheeler/slick": "~1.6.0"
92+
},
93+
```
94+
After this run `composer update --lock` to install just the manually managed package.
95+
_(You may run `composer require "kenwheeler/slick:~1.6.0"` as well if you add just the package definition)_
96+
97+
## FAQ
98+
99+
### Should I commit the contrib modules I download?
100+
101+
Composer recommends **no**. They provide [argumentation against but also
102+
workrounds if a project decides to do it anyway](https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md).
103+
104+
### How can I apply patches to downloaded modules?
105+
106+
If you need to apply patches (depending on the project being modified, a pull
107+
request is often a better solution), you can do so with the
108+
[composer-patches](https://github.com/cweagans/composer-patches) plugin.
109+
110+
To add a patch to drupal module foobar insert the patches section in the extra
111+
section of composer.json:
112+
```json
113+
"extra": {
114+
"patches": {
115+
"drupal/foobar": {
116+
"Patch description": "URL or local path to patch"
117+
}
118+
}
119+
}
120+
```
121+
### How do I switch from packagist.drupal-composer.org to packages.drupal.org?
122+
123+
Follow the instructions in the [documentation on drupal.org](https://www.drupal.org/docs/develop/using-composer/using-packagesdrupalorg).
124+
125+
### How do I specify a PHP version ?
126+
127+
This project supports PHP 5.3 as minimum version (see [Drupal 7 PHP requirements](https://www.drupal.org/docs/7/system-requirements/php-requirements)), however it's possible that a `composer update` will upgrade some package that will then require PHP 7+.
128+
129+
To prevent this you can add this code to specify the PHP version you want to use in the `config` section of `composer.json`:
130+
```json
131+
"config": {
132+
"sort-packages": true,
133+
"platform": {
134+
"php": "5.3.3"
135+
}
136+
},
137+
```

composer.json

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"name": "drupal-composer/drupal-project",
3+
"description": "Project template for Drupal 7 projects with composer",
4+
"type": "project",
5+
"license": "GPL-2.0-or-later",
6+
"authors": [
7+
{
8+
"name": "",
9+
"role": ""
10+
}
11+
],
12+
"repositories": [
13+
{
14+
"type": "composer",
15+
"url": "https://packages.drupal.org/7"
16+
}
17+
],
18+
"require": {
19+
"php": ">=5.3.3",
20+
"ext-curl": "*",
21+
"ext-gd": "*",
22+
"ext-json": "*",
23+
"ext-openssl": "*",
24+
"ext-pdo": "*",
25+
"ext-xml": "*",
26+
"composer/installers": "^1.2",
27+
"composer/semver": "^1.4",
28+
"cweagans/composer-patches": "^1.6.5",
29+
"drupal-composer/preserve-paths": "^0.1",
30+
"drupal/composer_autoloader": "^1.0",
31+
"drupal/drupal": "^7.62",
32+
"drush/drush": "^8.0",
33+
"symfony/filesystem": "~2.7|^3",
34+
"webflo/drupal-finder": "^1.0.0"
35+
},
36+
"conflict": {
37+
"drupal/core": "8.*"
38+
},
39+
"minimum-stability": "dev",
40+
"prefer-stable": true,
41+
"config": {
42+
"sort-packages": true
43+
},
44+
"autoload": {
45+
"classmap": [
46+
"scripts/composer/ScriptHandler.php"
47+
]
48+
},
49+
"scripts": {
50+
"pre-install-cmd": [
51+
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
52+
],
53+
"pre-update-cmd": [
54+
"DrupalProject\\composer\\ScriptHandler::checkComposerVersion"
55+
],
56+
"post-install-cmd": [
57+
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
58+
],
59+
"post-update-cmd": [
60+
"DrupalProject\\composer\\ScriptHandler::createRequiredFiles"
61+
],
62+
"post-create-project-cmd": [
63+
"DrupalProject\\composer\\ScriptHandler::removeInternalFiles"
64+
]
65+
},
66+
"extra": {
67+
"installer-paths": {
68+
"web/": ["type:drupal-core"],
69+
"web/profiles/{$name}/": ["type:drupal-profile"],
70+
"web/sites/all/drush/{$name}/": ["type:drupal-drush"],
71+
"web/sites/all/libraries/{$name}/": ["type:drupal-library"],
72+
"web/sites/all/modules/contrib/{$name}/": ["type:drupal-module"],
73+
"web/sites/all/themes/contrib/{$name}/": ["type:drupal-theme"]
74+
},
75+
"patches": {
76+
"cweagans/composer-patches": {
77+
"Call the preserve paths hooks" : "https://github.com/SebCorbin/composer-patches/commit/1cb9bacba51f8bba0c5f3f322c3bb61e4ceae974.patch"
78+
}
79+
},
80+
"preserve-paths": [
81+
"web/sites"
82+
]
83+
}
84+
}

drush/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This directory contains commands, configuration and site aliases for Drush. See https://packagist.org/search/?type=drupal-drush for a directory of Drush commands installable via Composer.

drush/policy.drush.inc

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
/*
4+
* Customize this file as desired. See https://github.com/drush-ops/drush/blob/8.x/examples/policy.drush.inc for documentation.
5+
*/
6+
7+
/**
8+
* Implements drush_hook_COMMAND_validate().
9+
*
10+
* Encourage folks to use `composer` instead of Drush pm commands
11+
*/
12+
function drush_policy_pm_updatecode_validate() {
13+
return _deny_message();
14+
}
15+
16+
function drush_policy_pm_update_validate() {
17+
return _deny_message();
18+
}
19+
20+
function drush_policy_pm_download_validate() {
21+
return _deny_message();
22+
}
23+
24+
function _deny_message() {
25+
if (!drush_get_option('pm-force')) {
26+
$msg = 'This codebase is assembled with Composer instead of Drush. Use `composer update` and `composer require` instead of `drush pm-updatecode` and `drush pm-download`. You may override this error by using the --pm-force option.';
27+
return drush_set_error('POLICY_PM_DENY', dt($msg));
28+
}
29+
}
30+
31+
/**
32+
* Implements hook_drush_help_alter().
33+
*/
34+
function policy_drush_help_alter(&$command) {
35+
if (in_array($command['command'], array('pm-updatecode', 'pm-update', 'pm-download'))) {
36+
$command['options']['pm-force'] = 'Override site policy and allow Drush codebase management (pm-* commands)';
37+
}
38+
}

phpunit.xml.dist

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="vendor/autoload.php"
8+
verbose="true"
9+
>
10+
<testsuites>
11+
<testsuite name="drupal-composer-project tests">
12+
<directory>./test/</directory>
13+
</testsuite>
14+
</testsuites>
15+
</phpunit>

0 commit comments

Comments
 (0)