Your SlideShare is downloading. ×
0
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Composer
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Composer

863

Published on

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.

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
863
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • 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
  • Transcript

    • 1. Tom Corrigan Melbourne PHP Users Grouprostercloud.com October 2012 @t_corrigan
    • 2. 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]
    • 3. What does that mean?
    • 4. What does that mean?• Scope is per project, not global
    • 5. What does that mean?• Scope is per project, not global• Resolves dependencies
    • 6. What does that mean?• Scope is per project, not global• Resolves dependencies• Runs installation tasks
    • 7. Who’s using Composer?
    • 8. Packagist
    • 9. Packagist
    • 10. Packagist • Composer’s default repository
    • 11. Packagist • Composer’s default repository • Put your open source libraries here
    • 12. Packagist • Composer’s default repository • Put your open source libraries here • Great resource for well maintained PHP libraries
    • 13. Statistics[https://packagist.org/statistics]
    • 14. Statistics• Over 4000 packages listed on packagist.org [https://packagist.org/statistics]
    • 15. Statistics• Over 4000 packages listed on packagist.org• More than 4,500,000 package installations over the last 6 months [https://packagist.org/statistics]
    • 16. Installing Composer
    • 17. Installing ComposerLocally:
    • 18. Installing ComposerLocally: $ cd /project/path $ curl -s https://getcomposer.org/installer | php
    • 19. Installing ComposerLocally: $ cd /project/path $ curl -s https://getcomposer.org/installer | phpGlobally:
    • 20. Installing ComposerLocally: $ cd /project/path $ curl -s https://getcomposer.org/installer | phpGlobally: $ sudo mv composer.phar /usr/local/bin/composer
    • 21. Staying current
    • 22. Staying currentLocally:
    • 23. Staying currentLocally: $ cd /project/path $ php composer.phar self-update
    • 24. Staying currentLocally: $ cd /project/path $ php composer.phar self-updateGlobally:
    • 25. Staying currentLocally: $ cd /project/path $ php composer.phar self-updateGlobally: $ composer self-update
    • 26. Using Composer
    • 27. Using Composer• Define project dependencies
    • 28. Using Composer• Define project dependencies• Install them
    • 29. Using Composer• Define project dependencies• Install them• Bootstrap the autoloader
    • 30. Define your dependencies
    • 31. Define your dependenciescomposer.json
    • 32. 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" }}
    • 33. Install
    • 34. Install$ composer install
    • 35. Install$ composer installvendor/ .composer/ phpmelb/ project1/ project2/ project3/ project4/ autoload.php
    • 36. Using the autoloader<?phprequire vendor/autoload.php;$foo = new PHPMelbProject1Foo();$bar = new PHPMelb_Project2_Bar();...
    • 37. { "name": "symfony/framework-standard-edition", "description": "The "Symfony Standard Edition" distribution",
    • 38. { "name": "symfony/framework-standard-edition", "description": "The "Symfony Standard Edition" distribution", "autoload": { "psr-0": { "": "src/" } },
    • 39. { "name": "symfony/framework-standard-edition", "description": "The "Symfony Standard Edition" distribution", "autoload": { "psr-0": { "": "src/" } },
    • 40. { "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.*" },
    • 41. { "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" ] },
    • 42. { "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" },
    • 43. { "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",
    • 44. { "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",
    • 45. { "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" }
    • 46. Composer: Killer Features
    • 47. Composer: Killer Features• composer.lock
    • 48. Composer: Killer Features• composer.lock• Satis - Your private repository
    • 49. Composer: Killer Features• composer.lock• Satis - Your private repository• composer installers
    • 50. Composer: Killer Features• composer.lock• Satis - Your private repository• composer installers• Get started with a new framework project directly from composer
    • 51. composer.lock
    • 52. composer.lock• Used when you call composer install
    • 53. composer.lock• Used when you call composer install• Updated by composer update
    • 54. composer.lock• Used when you call composer install• Updated by composer update• Everybody runs the exact same version of dependencies
    • 55. Satis
    • 56. Satis• Your very own packagist for your proprietary code
    • 57. Satis• Your very own packagist for your proprietary code• Eases deployment
    • 58. Satis• Your very own packagist for your proprietary code• Eases deployment• Composer will connect to it securely
    • 59. Satis• Your very own packagist for your proprietary code• Eases deployment• Composer will connect to it securely • HTTPS -Public key
    • 60. Satis• Your very own packagist for your proprietary code• Eases deployment• Composer will connect to it securely • HTTPS -Public key • SSH
    • 61. 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
    • 62. 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
    • 63. 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
    • 64. 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
    • 65. 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
    • 66. 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
    • 67. ?
    • 68. ThankyouFurther Reading:http://getcomposer.orghttp://packagist.orghttp://symfony.com/video/26/in-depth-with-composer/EnglishSlides available at https://speakerdeck.com/u/tommygnr

    ×