Managing your Drupal project with Composer

Download Managing your Drupal project with Composer

Post on 16-Jan-2017




1 download

Embed Size (px)


<p>Managing Your Drupal Project with Composermatt glaman | @nmdmatt | mglaman</p> <p>Matt GlamanSenior Drupal Consultant @ Commerce GuysCo-maintainer of Drupal CommerceAuthor of Drupal 8 Development Cookbook</p> <p>DependencyManagementIt ain't new.</p> <p>PIP</p> <p>Dependency management is not a new concept.</p> <p>NodeJS: npmFrontend JS/CSS: BowerRuby: Bundler/GemsPython: pipJava: MavenC#/.NET: nugetGo: theres like 10. cocoapods</p> <p>composerThe de facto dependency management tool for PHP</p> <p>Inspired by npm and bundlerProvides a way to easily share and use librariesNot like PEAR - which installed to global includes directory and didnt use PSR standards for autoloading.</p> <p>composer.jsondefines metadata about the project and dependencies for the project</p> <p>Package informationDependenciesDeveloper dependenciesAdditional metadata</p> <p>composer.lockcomputed information about dependencies and expected install state</p> <p>See Gemfile.lockContains installable package informationProvides a repeatable install across instances</p> <p>composer installdownloads and installs dependencieswill install off of lock fileif no lock file, acts as update</p> <p>downloads and installs dependencies, builds the class autoloader. If a .lock file is available it will install based off of the metadata. Otherwise it will calculated and resolve the download information for dependencies.</p> <p>composer updateupdates defined dependenciesrebuilds the lock filegenerates autoloader</p> <p>composer requireadds a new dependency, updates the JSON and .lock file.updates autoloader</p> <p>composer removeremoves a dependency, updates the JSON and .lock fileupdates autoloader</p> <p>New to DrupalDrupal never had dependency management. Drush kind of helped.Still a little rocky</p> <p>Drush en -y panels_ipe thx Drush for downloading and enabling everything.Everything isnt worked out yet for working with Drupal and Composer</p> <p>Installing Drupal</p> <p>Install from packaged has a packaging system which provides zip and tar archives. These archives come with all third party dependencies downloaded.</p> <p>Install via Composer templatecomposer create-project drupal-composer/drupal-project:8.x-dev some-dir --stability dev --no-interactionCreates your project in some-dirContains vendor and web directoryFollows current standard application structure</p> <p>Adding dependencies to Drupal</p> <p>Without Composer (or any tools.)</p> <p>Wanted hunt and peck but this was more suitable.</p> <p>With Composercomposer require drupal/panels</p> <p>"require": { "drupal/panels": "3.0-beta4",}</p> <p>Use Composer require command to add the dependencyYour composer.json should have the followingBUT WAIT. Theres currently a catch.</p> <p> Composer Faade endpoints provide provides a repository endpoint (beta)Allows projects to be installed via composerAllows projects to specify 3rd party librariesInitial community initative:</p> <p>Matt Glaman () - How do we know what the packages are named and available on Glaman () - but with ... it's hard to know what is available.Matt Glaman () - version naming</p> <p>Adding the endpoint to composer.jsoncomposer config repositories.drupal composer composer.json will now have "repositories": { "drupal": { "type": "composer", "url": "" } },</p> <p>Version constraints</p> <p>~8.2.1: &gt;=8.2.1 =8.2 =8.2.1 </p>