• Save
Composer
Upcoming SlideShare
Loading in...5
×
 

Composer

on

  • 1,173 views

Abstract: Composer is a tool for managing dependencies in PHP projects. This talk will introduce Composer and its associated package repository Packagist. The key features and benefits of using ...

Abstract: Composer is a tool for managing dependencies in PHP projects. This talk will introduce Composer and its associated package repository Packagist. The key features and benefits of using Composer will be explored and through practical demonstrations you will gain a working knowledge of using Composer for dependency management.

Statistics

Views

Total Views
1,173
Views on SlideShare
1,170
Embed Views
3

Actions

Likes
2
Downloads
0
Comments
0

2 Embeds 3

http://bshare.dev 2
http://mania.net.pl 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Abstract: Composer is a tool for managing dependencies in PHP projects. This talk will introduce Composer and its associated package repository Packagist. The key features and benefits of using Composer will be explored and through practical demonstrations you will gain a working knowledge of using Composer for dependency management.\n
  • \n
  • Similar to Bundler for Ruby or npm for node. Per project\n
  • Similar to Bundler for Ruby or npm for node. Per project\n
  • Similar to Bundler for Ruby or npm for node. Per project\n
  • plus many more\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Global is better, don’t have to run self-update in each project\n
  • Global is better, don’t have to run self-update in each project\n
  • Global is better, don’t have to run self-update in each project\n
  • Global is better, don’t have to run self-update in each project\n
  • Define, install, autoload(optional)\nexamine each step in detail\n
  • Define, install, autoload(optional)\nexamine each step in detail\n
  • Define, install, autoload(optional)\nexamine each step in detail\n
  • 2 parts - package name & package version\npackage name has two parts, vendor name & project nameFirst example, Tag name in git\n
  • 2 parts - package name & package version\npackage name has two parts, vendor name & project nameFirst example, Tag name in git\n
  • \n
  • \n
  • DIR structure, composer.lock, \nAutoloader is designed for PSR-0 only, there are workarounds for other approaches. PHP-FIG\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Dev, prod, test, staging, Jim, Bob\n
  • Dev, prod, test, staging, Jim, Bob\n
  • Dev, prod, test, staging, Jim, Bob\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Official extension\n
  • Official extension\n
  • Official extension\n
  • Official extension\n
  • \n
  • \n
  • \n

Composer Composer Presentation Transcript

  • Tom Corrigan Melbourne PHP Users Grouprostercloud.com October 2012 @t_corrigan
  • What is Composer?“Composer is a tool for dependency management. It allows you todeclare the dependent libraries your project needs and it will installthem in your project for you.”[http://getcomposer.org/doc/00-intro.md]
  • What does that mean?
  • What does that mean?• Scope is per project, not global
  • What does that mean?• Scope is per project, not global• Resolves dependencies
  • What does that mean?• Scope is per project, not global• Resolves dependencies• Runs installation tasks
  • Who’s using Composer?
  • Packagist
  • Packagist
  • Packagist • Composer’s default repository
  • Packagist • Composer’s default repository • Put your open source libraries here
  • Packagist • Composer’s default repository • Put your open source libraries here • Great resource for well maintained PHP libraries
  • Statistics[https://packagist.org/statistics]
  • Statistics• Over 4000 packages listed on packagist.org [https://packagist.org/statistics]
  • Statistics• Over 4000 packages listed on packagist.org• More than 4,500,000 package installations over the last 6 months [https://packagist.org/statistics]
  • Installing Composer
  • Installing ComposerLocally:
  • Installing ComposerLocally: $ cd /project/path $ curl -s https://getcomposer.org/installer | php
  • Installing ComposerLocally: $ cd /project/path $ curl -s https://getcomposer.org/installer | phpGlobally:
  • Installing ComposerLocally: $ cd /project/path $ curl -s https://getcomposer.org/installer | phpGlobally: $ sudo mv composer.phar /usr/local/bin/composer
  • Staying current
  • Staying currentLocally:
  • Staying currentLocally: $ cd /project/path $ php composer.phar self-update
  • Staying currentLocally: $ cd /project/path $ php composer.phar self-updateGlobally:
  • Staying currentLocally: $ cd /project/path $ php composer.phar self-updateGlobally: $ composer self-update
  • Using Composer
  • Using Composer• Define project dependencies
  • Using Composer• Define project dependencies• Install them
  • Using Composer• Define project dependencies• Install them• Bootstrap the autoloader
  • Define your dependencies
  • Define your dependenciescomposer.json
  • Define your dependenciescomposer.json{ "require": { "phpmelb/project1": "1.0.2" "phpmelb/project2": "1.0.*" "phpmelb/project3": ">=1.0,<2.0" "phpmelb/project4": "4d3fe5feaf" "phpmelb/project5": "dev-master" }}
  • Install
  • Install$ composer install
  • Install$ composer installvendor/ .composer/ phpmelb/ project1/ project2/ project3/ project4/ autoload.php
  • Using the autoloader<?phprequire vendor/autoload.php;$foo = new PHPMelbProject1Foo();$bar = new PHPMelb_Project2_Bar();...
  • { "name": "symfony/framework-standard-edition", "description": "The "Symfony Standard Edition" distribution",
  • { "name": "symfony/framework-standard-edition", "description": "The "Symfony Standard Edition" distribution", "autoload": { "psr-0": { "": "src/" } },
  • { "name": "symfony/framework-standard-edition", "description": "The "Symfony Standard Edition" distribution", "autoload": { "psr-0": { "": "src/" } },
  • { "name": "symfony/framework-standard-edition", "description": "The "Symfony Standard Edition" distribution", "autoload": { "psr-0": { "": "src/" } }, "require": { "php": ">=5.3.3", "symfony/symfony": "2.1.*", "doctrine/orm": ">=2.2.3,<2.4-dev", "doctrine/doctrine-bundle": "1.0.*", "twig/extensions": "1.0.*", "symfony/assetic-bundle": "2.1.*", "symfony/swiftmailer-bundle": "2.1.*", "symfony/monolog-bundle": "2.1.*", "sensio/distribution-bundle": "2.1.*", "sensio/framework-extra-bundle": "2.1.*", "sensio/generator-bundle": "2.1.*", "jms/security-extra-bundle": "1.2.*", "jms/di-extra-bundle": "1.1.*" },
  • { "name": "symfony/framework-standard-edition", "description": "The "Symfony Standard Edition" distribution", "autoload": { "psr-0": { "": "src/" } }, "require": { "php": ">=5.3.3", "symfony/symfony": "2.1.*", "doctrine/orm": ">=2.2.3,<2.4-dev", "doctrine/doctrine-bundle": "1.0.*", "twig/extensions": "1.0.*", "symfony/assetic-bundle": "2.1.*", "symfony/swiftmailer-bundle": "2.1.*", "symfony/monolog-bundle": "2.1.*", "sensio/distribution-bundle": "2.1.*", "sensio/framework-extra-bundle": "2.1.*", "sensio/generator-bundle": "2.1.*", "jms/security-extra-bundle": "1.2.*", "jms/di-extra-bundle": "1.1.*" }, "scripts": { "post-install-cmd": [ "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap", "SensioBundleDistributionBundleComposerScriptHandler::clearCache", "SensioBundleDistributionBundleComposerScriptHandler::installAssets", "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile" ], "post-update-cmd": [ "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap", "SensioBundleDistributionBundleComposerScriptHandler::clearCache", "SensioBundleDistributionBundleComposerScriptHandler::installAssets", "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile" ] },
  • { "name": "symfony/framework-standard-edition", "description": "The "Symfony Standard Edition" distribution", "autoload": { "psr-0": { "": "src/" } }, "require": { "php": ">=5.3.3", "symfony/symfony": "2.1.*", "doctrine/orm": ">=2.2.3,<2.4-dev", "doctrine/doctrine-bundle": "1.0.*", "twig/extensions": "1.0.*", "symfony/assetic-bundle": "2.1.*", "symfony/swiftmailer-bundle": "2.1.*", "symfony/monolog-bundle": "2.1.*", "sensio/distribution-bundle": "2.1.*", "sensio/framework-extra-bundle": "2.1.*", "sensio/generator-bundle": "2.1.*", "jms/security-extra-bundle": "1.2.*", "jms/di-extra-bundle": "1.1.*" }, "scripts": { "post-install-cmd": [ "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap", "SensioBundleDistributionBundleComposerScriptHandler::clearCache", "SensioBundleDistributionBundleComposerScriptHandler::installAssets", "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile" ], "post-update-cmd": [ "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap", "SensioBundleDistributionBundleComposerScriptHandler::clearCache", "SensioBundleDistributionBundleComposerScriptHandler::installAssets", "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile" ] }, "config": { "bin-dir": "bin" },
  • { "name": "symfony/framework-standard-edition", "description": "The "Symfony Standard Edition" distribution", "autoload": { "psr-0": { "": "src/" } }, "require": { "php": ">=5.3.3", "symfony/symfony": "2.1.*", "doctrine/orm": ">=2.2.3,<2.4-dev", "doctrine/doctrine-bundle": "1.0.*", "twig/extensions": "1.0.*", "symfony/assetic-bundle": "2.1.*", "symfony/swiftmailer-bundle": "2.1.*", "symfony/monolog-bundle": "2.1.*", "sensio/distribution-bundle": "2.1.*", "sensio/framework-extra-bundle": "2.1.*", "sensio/generator-bundle": "2.1.*", "jms/security-extra-bundle": "1.2.*", "jms/di-extra-bundle": "1.1.*" }, "scripts": { "post-install-cmd": [ "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap", "SensioBundleDistributionBundleComposerScriptHandler::clearCache", "SensioBundleDistributionBundleComposerScriptHandler::installAssets", "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile" ], "post-update-cmd": [ "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap", "SensioBundleDistributionBundleComposerScriptHandler::clearCache", "SensioBundleDistributionBundleComposerScriptHandler::installAssets", "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile" ] }, "config": { "bin-dir": "bin" }, "minimum-stability": "dev",
  • { "name": "symfony/framework-standard-edition", "description": "The "Symfony Standard Edition" distribution", "autoload": { "psr-0": { "": "src/" } }, "require": { "php": ">=5.3.3", "symfony/symfony": "2.1.*", "doctrine/orm": ">=2.2.3,<2.4-dev", "doctrine/doctrine-bundle": "1.0.*", "twig/extensions": "1.0.*", "symfony/assetic-bundle": "2.1.*", "symfony/swiftmailer-bundle": "2.1.*", "symfony/monolog-bundle": "2.1.*", "sensio/distribution-bundle": "2.1.*", "sensio/framework-extra-bundle": "2.1.*", "sensio/generator-bundle": "2.1.*", "jms/security-extra-bundle": "1.2.*", "jms/di-extra-bundle": "1.1.*" }, "scripts": { "post-install-cmd": [ "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap", "SensioBundleDistributionBundleComposerScriptHandler::clearCache", "SensioBundleDistributionBundleComposerScriptHandler::installAssets", "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile" ], "post-update-cmd": [ "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap", "SensioBundleDistributionBundleComposerScriptHandler::clearCache", "SensioBundleDistributionBundleComposerScriptHandler::installAssets", "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile" ] }, "config": { "bin-dir": "bin" }, "minimum-stability": "dev",
  • { "name": "symfony/framework-standard-edition", "description": "The "Symfony Standard Edition" distribution", "autoload": { "psr-0": { "": "src/" } }, "require": { "php": ">=5.3.3", "symfony/symfony": "2.1.*", "doctrine/orm": ">=2.2.3,<2.4-dev", "doctrine/doctrine-bundle": "1.0.*", "twig/extensions": "1.0.*", "symfony/assetic-bundle": "2.1.*", "symfony/swiftmailer-bundle": "2.1.*", "symfony/monolog-bundle": "2.1.*", "sensio/distribution-bundle": "2.1.*", "sensio/framework-extra-bundle": "2.1.*", "sensio/generator-bundle": "2.1.*", "jms/security-extra-bundle": "1.2.*", "jms/di-extra-bundle": "1.1.*" }, "scripts": { "post-install-cmd": [ "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap", "SensioBundleDistributionBundleComposerScriptHandler::clearCache", "SensioBundleDistributionBundleComposerScriptHandler::installAssets", "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile" ], "post-update-cmd": [ "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap", "SensioBundleDistributionBundleComposerScriptHandler::clearCache", "SensioBundleDistributionBundleComposerScriptHandler::installAssets", "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile" ] }, "config": { "bin-dir": "bin" }, "minimum-stability": "dev", "extra": { "symfony-app-dir": "app", "symfony-web-dir": "web" }
  • Composer: Killer Features
  • Composer: Killer Features• composer.lock
  • Composer: Killer Features• composer.lock• Satis - Your private repository
  • Composer: Killer Features• composer.lock• Satis - Your private repository• composer installers
  • Composer: Killer Features• composer.lock• Satis - Your private repository• composer installers• Get started with a new framework project directly from composer
  • composer.lock
  • composer.lock• Used when you call composer install
  • composer.lock• Used when you call composer install• Updated by composer update
  • composer.lock• Used when you call composer install• Updated by composer update• Everybody runs the exact same version of dependencies
  • Satis
  • Satis• Your very own packagist for your proprietary code
  • Satis• Your very own packagist for your proprietary code• Eases deployment
  • Satis• Your very own packagist for your proprietary code• Eases deployment• Composer will connect to it securely
  • Satis• Your very own packagist for your proprietary code• Eases deployment• Composer will connect to it securely • HTTPS -Public key
  • Satis• Your very own packagist for your proprietary code• Eases deployment• Composer will connect to it securely • HTTPS -Public key • SSH
  • Satis• Your very own packagist for your proprietary code• Eases deployment• Composer will connect to it securely • HTTPS -Public key • SSH• See https://github.com/composer/satis
  • Composer Installers •CakePHP •lithium-source •cakephp-plugin •Magento •CodeIgniter •magento-library •codeigniter-library •magento-skin •codeigniter-third-party •magento-theme •codeigniter-module •Mako •Drupal •mako-package •drupal-module •MediaWiki •drupal-theme •mediawiki-extension •drupal-profile •phpBB •drupal-drush •phpbb-extension •FuelPHP •PPI •fuelphp-module •ppi-module •Joomla •SilverStripe •joomla-component •silverstripe-module •joomla-module •silverstripe-theme •joomla-template •symfony1 •joomla-plugin •symfony1-plugin •joomla-library •WordPress •Kohana •wordpress-plugin •kohana-module •wordpress-theme •Laravel •Zend •laravel-library •zend-library •Lithium •zend-extra •lithium-library
  • Composer Installers •CakePHP •lithium-source •cakephp-plugin •Magento• Bring the power and ease •CodeIgniter •codeigniter-library •codeigniter-third-party •magento-library •magento-skin •magento-theme of Composer to your •codeigniter-module •Mako •Drupal •mako-package framework/CMS •drupal-module •MediaWiki •drupal-theme •mediawiki-extension •drupal-profile •phpBB •drupal-drush •phpbb-extension •FuelPHP •PPI •fuelphp-module •ppi-module •Joomla •SilverStripe •joomla-component •silverstripe-module •joomla-module •silverstripe-theme •joomla-template •symfony1 •joomla-plugin •symfony1-plugin •joomla-library •WordPress •Kohana •wordpress-plugin •kohana-module •wordpress-theme •Laravel •Zend •laravel-library •zend-library •Lithium •zend-extra •lithium-library
  • Composer Installers •CakePHP •lithium-source •cakephp-plugin •Magento• Bring the power and ease •CodeIgniter •codeigniter-library •codeigniter-third-party •magento-library •magento-skin •magento-theme of Composer to your •codeigniter-module •Mako •Drupal •mako-package framework/CMS •drupal-module •MediaWiki •drupal-theme •mediawiki-extension •drupal-profile •phpBB• Magically installs packages/ •drupal-drush •FuelPHP •fuelphp-module •phpbb-extension •PPI •ppi-module plugins to the correct •Joomla •SilverStripe •joomla-component •silverstripe-module location for framework •joomla-module •silverstripe-theme •joomla-template •symfony1 •joomla-plugin •symfony1-plugin •joomla-library •WordPress •Kohana •wordpress-plugin •kohana-module •wordpress-theme •Laravel •Zend •laravel-library •zend-library •Lithium •zend-extra •lithium-library
  • Composer Installers •CakePHP •lithium-source •cakephp-plugin •Magento• Bring the power and ease •CodeIgniter •codeigniter-library •codeigniter-third-party •magento-library •magento-skin •magento-theme of Composer to your •codeigniter-module •Mako •Drupal •mako-package framework/CMS •drupal-module •MediaWiki •drupal-theme •mediawiki-extension •drupal-profile •phpBB• Magically installs packages/ •drupal-drush •FuelPHP •fuelphp-module •phpbb-extension •PPI •ppi-module plugins to the correct •Joomla •SilverStripe •joomla-component •silverstripe-module location for framework •joomla-module •silverstripe-theme •joomla-template •symfony1 •joomla-plugin •symfony1-plugin• See https://github.com/ •joomla-library •Kohana •kohana-module •WordPress •wordpress-plugin •wordpress-theme composer/installers •Laravel •Zend •laravel-library •zend-library •Lithium •zend-extra •lithium-library
  • Setup a new project• Symfony2 composer create-project symfony/framework-standard-edition path/to/install• Zend Framework 2 composer create-project --repository-url="http:// packages.zendframework.com" zendframework/skeleton-application path/to/ install
  • ?
  • ThankyouFurther Reading:http://getcomposer.orghttp://packagist.orghttp://symfony.com/video/26/in-depth-with-composer/EnglishSlides available at https://speakerdeck.com/u/tommygnr