{"componentChunkName":"component---src-templates-drupal-node-article-js","path":"/en/blog/installing-drupal-7-composer","result":{"data":{"drupal":{"blogDetail":{"__typename":"Drupal_NodeArticle","entityId":"5","nid":5,"title":"Installing Drupal 7 with Composer","body":"<p>There are many roads that lead to Rome, and there are as many ways to install Drupal.</p>\n\n<p>You can use the command line and Drush, download it separately, use an installation profile and now use Composer to install. The main benifit is that you can incorporate any number of command line tools.</p>\n\n<p>In this example I'll combine installation through an installation profile with Composer.</p>\n\n<h3>What is Composer?</h3>\n\n<blockquote>\n<p>\"Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.\"</p>\n<cite>http://getcomposer.org/doc/00-intro.md</cite></blockquote>\n\n<p><strong>What is a dependency manager?</strong></p>\n\n<p>Using a dependency manager, you can download third party libraries in your project. The Symphony framework uses this extensively with e.g. Doctrine, Twig, Swiftmailer, etc. The dependency manager checks compatible versions and downloads the right ones. It'll also check if there are other components (dependencies) that need to be downloaded when installing a component or module.</p>\n\n<p>Composer isn't really used as a dependency manager in this example, but more as a useful tool to simplify installation.</p>\n\n<h3>Installing Composer</h3>\n\n<p>The easiest way to download Composer is using curl:</p>\n\n<p><code>curl -sS https://getcomposer.org/installer | php</code></p>\n\n<p>If you don't have curl installed, you could also use:</p>\n\n<p><code>php -r \"eval('?&gt;'.file_get_contents('https://getcomposer.org/installer'));\"</code></p>\n\n<p>After executing the curl command the terminal displays:</p>\n\n<p><code>#!/usr/bin/env php All settings correct for using Composer Downloading... Composer successfully installed to: /Users/MacBookPro/Sites/www.patrickkannekens.nl/composer.phar Use it: php composer.phar</code></p>\n\n<p>And that's it. Composer is now installed.</p>\n\n<h3>Composer JSON</h3>\n\n<p>The next step is to create a composer.json file. This contains all the command that we want to execute.</p>\n\n<p>The JSON I use is as follows:</p>\n\n<p><code>{ \"name\":\"Installation profile\", \"description\":\"Install\", \"scripts\": { \"pre-install-cmd\":[ \"drush make --no-cache /var/www/html/installation-profile/installation-profile.make -y\", \"mkdir sites/default/files\", \"cp sites/default/default.settings.php sites/default/settings.php\", \"chmod 777 sites/default/files\", \"chmod 777 sites/default/settings.php\", \"drush site-install installation-profile --db-url=mysql://[db-username]:[db-password]@[servername]/[databasename] --account-name=[admin-account] --account-pass=[admin-account-password] --site-name='[site-name]' -y\", \"rm sites/default/default.settings.php\", \"chmod 444 sites/default/settings.php\" ] } } </code></p>\n\n<p>In the JSON file you can define commands that need to be executed prior to or after the installation of Drupal.</p>\n\n<p><strong>Step by step</strong></p>\n\n<p><code>drush make --no-cache /var/www/html/installation-profile/installation-profile.make -y</code></p>\n\n<p>Execute the installation profile. With this the latest version of Drupal and predefined modules will be downloaded.</p>\n\n<p><code>mkdir sites/default/files</code></p>\n\n<p>Create a folder for the files.</p>\n\n<p><code>cp sites/default/default.settings.php sites/default/settings.php</code></p>\n\n<p>Copy the default.settings.php to settings.php</p>\n\n<p><code>chmod 777 sites/default/files<br />\nchmod 777 sites/default/settings.php</code></p>\n\n<p>Change the file permissions so they'll be writeable during installation.</p>\n\n<p><code>drush site-install installation-profile --db-url=mysql://[db-username]:[db-password]@[servername]/[databasename] --account-name=[admin-account] --account-pass=[admin-account-password] --site-name='[site-name]' -y</code></p>\n\n<p>Installing the site with drush..</p>\n\n<p><code>chmod 444 sites/default/settings.php</code></p>\n\n<p>After completing the installation, the settings file is set read only.</p>\n\n<h3>Uitvoeren</h3>\n\n<p>Executing is easy as pie; run \"composer install\" (or \"php composer.phar install\") and let it run.</p>","internalId":5,"path":{"alias":"/blog/installing-drupal-7-composer"},"langcode":"en","url":{"__typename":"Drupal_EntityCanonicalUrl","metatags":[{"tag":"meta","attributes":[{"key":"name","value":"title"},{"key":"content","value":"Drupal 7 installeren met Composer | Web-Beest"}]},{"tag":"meta","attributes":[{"key":"name","value":"description"},{"key":"content","value":"Er zijn vele wegen die naar Rome leiden en zo is het ook met Drupal. Zo zijn er om te beginnen ook al verschillende manieren op Drupal te installeren."}]},{"tag":"link","attributes":[{"key":"rel","value":"canonical"},{"key":"href","value":"https://backend.web-beest.nl/nl/blog/drupal-7-installeren-met-composer"}]}]}}}},"pageContext":{"id":"5","language":"EN"}},"staticQueryHashes":["216485925","3051411397","830027947"]}