|
1 |
| -# Composer template for Drupal projects |
2 |
| - |
3 |
| -[](https://travis-ci.org/drupal-composer/drupal-project) |
4 |
| - |
5 |
| -This project template should provide a kickstart 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: |
| 1 | +# Composer template for Drupal projects. |
| 2 | + |
| 3 | +> Optimized to use with Docker and DrupalConsole. |
21 | 4 |
|
| 5 | +### Clone repository |
22 | 6 | ```
|
23 |
| -composer create-project weknowinc/drupal-project:8.x-dev some-dir --stability dev --no-interaction |
| 7 | +git clone https://github.com/weknowinc/drupal-project |
24 | 8 | ```
|
25 | 9 |
|
26 |
| -With `composer require ...` you can download new dependencies to your |
27 |
| -installation. |
28 |
| - |
| 10 | +### Copy and rename the `.env.dist` file |
29 | 11 | ```
|
30 |
| -cd some-dir |
31 |
| -composer require drupal/devel:~1.0 |
| 12 | +cp .env.dist .env |
32 | 13 | ```
|
33 | 14 |
|
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 |
| -* Autoloader is implemented to use the generated composer autoloader in `vendor/autoload.php`, |
44 |
| - instead of the one provided by Drupal (`web/vendor/autoload.php`). |
45 |
| -* Modules (packages of type `drupal-module`) will be placed in `web/modules/contrib/` |
46 |
| -* Theme (packages of type `drupal-theme`) will be placed in `web/themes/contrib/` |
47 |
| -* Profiles (packages of type `drupal-profile`) will be placed in `web/profiles/contrib/` |
48 |
| -* Creates default writable versions of `settings.php` and `services.yml`. |
49 |
| -* Creates `web/sites/default/files`-directory. |
50 |
| -* Latest version of drush is installed locally for use at `vendor/bin/drush`. |
51 |
| -* Latest version of DrupalConsole is installed locally for use at `vendor/bin/drupal`. |
52 |
| - |
53 |
| -## Updating Drupal Core |
54 |
| - |
55 |
| -This project will attempt to keep all of your Drupal Core files up-to-date; the |
56 |
| -project [drupal-composer/drupal-scaffold](https://github.com/drupal-composer/drupal-scaffold) |
57 |
| -is used to ensure that your scaffold files are updated every time drupal/core is |
58 |
| -updated. If you customize any of the "scaffolding" files (commonly .htaccess), |
59 |
| -you may need to merge conflicts if any of your modified files are updated in a |
60 |
| -new release of Drupal core. |
| 15 | +### Edit configuration |
| 16 | +Edit the copied `.env` file and make changes according to your project needs. |
61 | 17 |
|
62 |
| -Follow the steps below to update your core files. |
| 18 | +Example update default `HOST_NAME` from `drupal.develop` to `mysite.develop`. |
63 | 19 |
|
64 |
| -1. Run `composer update drupal/core webflo/drupal-core-require-dev symfony/* --with-dependencies` to update Drupal Core and its dependencies. |
65 |
| -1. Run `git diff` to determine if any of the scaffolding files have changed. |
66 |
| - Review the files for any changes and restore any customizations to |
67 |
| - `.htaccess` or `robots.txt`. |
68 |
| -1. Commit everything all together in a single commit, so `web` will remain in |
69 |
| - sync with the `core` when checking out branches or running `git bisect`. |
70 |
| -1. In the event that there are non-trivial conflicts in step 2, you may wish |
71 |
| - to perform these steps on a branch, and use `git merge` to combine the |
72 |
| - updated core files with your customized files. This facilitates the use |
73 |
| - of a [three-way merge tool such as kdiff3](http://www.gitshah.com/2010/12/how-to-setup-kdiff-as-diff-tool-for-git.html). This setup is not necessary if your changes are simple; |
74 |
| - keeping all of your modifications at the beginning or end of the file is a |
75 |
| - good strategy to keep merges easy. |
76 |
| - |
77 |
| -## Generate composer.json from existing project |
78 |
| - |
79 |
| -With using [the "Composer Generate" drush extension](https://www.drupal.org/project/composer_generate) |
80 |
| -you can now generate a basic `composer.json` file from an existing project. Note |
81 |
| -that the generated `composer.json` might differ from this project's file. |
82 |
| - |
83 |
| - |
84 |
| -## FAQ |
85 |
| - |
86 |
| -### Should I commit the contrib modules I download? |
| 20 | +### Starting the containers |
| 21 | +To start the containers you need to execute the following command docker-compose up -d, grab some coffee or a beer and be patient while the images are downloaded to your local computer. |
| 22 | +``` |
| 23 | +docker-compose up -d |
| 24 | +``` |
| 25 | +NOTE: We suggest provide the detached mode flag to run in background. |
87 | 26 |
|
88 |
| -Composer recommends **no**. They provide [argumentation against but also |
89 |
| -workrounds if a project decides to do it anyway](https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md). |
| 27 | +### Add hostname entry in your `/etc/hosts` file |
| 28 | +``` |
| 29 | +127.0.0.1 drupal.develop |
| 30 | +``` |
| 31 | +NOTE: Use your own domain if you make changes in the copied `.env` file. |
90 | 32 |
|
91 |
| -### Should I commit the scaffolding files? |
| 33 | +Open your browser and point to `http://drupal.develop/` or the hostname you entered on the `.env` file. |
92 | 34 |
|
93 |
| -The [drupal-scaffold](https://github.com/drupal-composer/drupal-scaffold) plugin can download the scaffold files (like |
94 |
| -index.php, update.php, …) to the web/ directory of your project. If you have not customized those files you could choose |
95 |
| -to not check them into your version control system (e.g. git). If that is the case for your project it might be |
96 |
| -convenient to automatically run the drupal-scaffold plugin after every install or update of your project. You can |
97 |
| -achieve that by registering `@drupal-scaffold` as post-install and post-update command in your composer.json: |
| 35 | +### Shutting down the containers |
| 36 | +``` |
| 37 | +docker-compose down |
98 | 38 |
|
99 |
| -```json |
100 |
| -"scripts": { |
101 |
| - "drupal-scaffold": "DrupalComposer\\DrupalScaffold\\Plugin::scaffold", |
102 |
| - "post-install-cmd": [ |
103 |
| - "@drupal-scaffold", |
104 |
| - "..." |
105 |
| - ], |
106 |
| - "post-update-cmd": [ |
107 |
| - "@drupal-scaffold", |
108 |
| - "..." |
109 |
| - ] |
110 |
| -}, |
| 39 | +docker-compose down -v |
111 | 40 | ```
|
112 |
| -### How can I apply patches to downloaded modules? |
| 41 | +NOTE: You can pass the -v flag to destroy the shared volumes as well. Be careful this will destroy any data on the shared volumes between the container and the local machine. |
113 | 42 |
|
114 |
| -If you need to apply patches (depending on the project being modified, a pull |
115 |
| -request is often a better solution), you can do so with the |
116 |
| -[composer-patches](https://github.com/cweagans/composer-patches) plugin. |
| 43 | +### Checking for used ports |
| 44 | +One common issue you'll likely run into while starting the containers, is finding the ports in use, this could mean an instance of Apache, Nginx, MySQL or other service is already running, so if you want to know what is using the ports you can run this commands on your terminal: |
117 | 45 |
|
118 |
| -To add a patch to drupal module foobar insert the patches section in the extra |
119 |
| -section of composer.json: |
120 |
| -```json |
121 |
| -"extra": { |
122 |
| - "patches": { |
123 |
| - "drupal/foobar": { |
124 |
| - "Patch description": "URL or local path to patch" |
125 |
| - } |
126 |
| - } |
127 |
| -} |
128 | 46 | ```
|
129 |
| -### How do I switch from packagist.drupal-composer.org to packages.drupal.org? |
| 47 | +# web (Apache, Nginx) |
| 48 | +lsof -i :80 |
130 | 49 |
|
131 |
| -Follow the instructions in the [documentation on drupal.org](https://www.drupal.org/docs/develop/using-composer/using-packagesdrupalorg). |
| 50 | +# db (MySQL, MariaDB) |
| 51 | +lsof -i :3306 |
| 52 | +``` |
132 | 53 |
|
133 |
| -### How do I specify a PHP version ? |
| 54 | +We based the docker configuration of this repository on the [Drupal4Docker](https://github.com/wodby/docker4drupal) project. |
134 | 55 |
|
135 |
| -Currently Drupal 8 supports PHP 5.5.9 as minimum version (see [Drupal 8 PHP requirements](https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements)), however it's possible that a `composer update` will upgrade some package that will then require PHP 7+. |
| 56 | +We based the composer configuration on the [drupal-composer/drupal-project](https://github.com/drupal-composer/drupal-project) project. |
136 | 57 |
|
137 |
| -To prevent this you can add this code to specify the PHP version you want to use in the `config` section of `composer.json`: |
138 |
| -```json |
139 |
| -"config": { |
140 |
| - "sort-packages": true, |
141 |
| - "platform": {"php": "5.5.9"} |
142 |
| -}, |
143 |
| -``` |
| 58 | +Click here for info about [composer](composer.md). |
0 commit comments