0
Composing Project  Dependencies          Derek Gallo          @derekgallo    http://github.com/drock
Problem•Projects use many libs or frameworks•Most libs have several dependencies•Different projects need different versions
An Example          Project A                   Project B          PHPUnit                     PHPUnit            3.7     ...
PearProject A             Project B                                  Single shared                                  depend...
Submodules          Project A                       Project B          Symfony     PHPUnit             Symfony     PHPUnit...
Composer!          Project A                   Project B          PHPUnit                     PHPUnit            3.7      ...
Composer! •Autoloading • Dependency Management • Per project dependencies • Part of build
Composer is a tool fordependency managementin PHP. It allows you todeclare the dependentlibraries your project needsand it...
Installation  •Locally   • curl -sS https://getcomposer.org/      installer | php  •Globally   • sudo mv composer.phar /us...
Silex Sample  •Create empty project   folder  •   Create composer.json
Silex Sample
Silex Sample• >composer install
Silex Sample  • include autoloader  • write controller
Silex Sample  • add monolog
Silex Sample  • >composer update
Silex Sample  • add logging code
DefiningDependencies        Vendor/Package                           Version                           Stability          ...
InstallingDependencies•   >composer install• downloads dependencies to vendor folder•generates autoloader
Using Dependencies  •PSR-0 - Standards   defining naming   conventions for   autoloading.  •Use composer generated   autol...
UpdatingDependencies •>composer update • upgrades packages to  latest version based on  rules in composer.json
Install vs Update •composer.lock  •tracks versions of    dependencies used  •commit it •install-looks for composer.lock   ...
Working in a Team•Elect a dependency manager •  manages and commits    composer files•add vendor folder to git/svn ignore
Finding Packages  •Packagist   • >composer search ...  • Github   • look for composer.json
Older Packages                         Define a package                        repository in your                          ...
Bleeding Edge         Version Tag                       Version Branch                         Other Branch
Custom Forks • Fork on Github • Add your repo • Specify your branch
Bootstrapping>composer create-project -s dev fabpot/silex-skeleton .
More? • http://getcomposer.org • http://packagist.org • https://github.com/php-fig/fig-   standards/blob/master/accepted/ ...
Upcoming SlideShare
Loading in...5
×

Composing Project Dependencies

1,203

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,203
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Composing Project Dependencies"

  1. 1. Composing Project Dependencies Derek Gallo @derekgallo http://github.com/drock
  2. 2. Problem•Projects use many libs or frameworks•Most libs have several dependencies•Different projects need different versions
  3. 3. An Example Project A Project B PHPUnit PHPUnit 3.7 3.6Symfony PHPUnit Symfony PHPUnit YAML Mocks ... YAML Mocks ... 2.2 1.3 1.02 1.1
  4. 4. PearProject A Project B Single shared dependency PHPUnit No autoloading 3.7 Not part of build Symfony PHPUnit YAML Mocks ... 2.2 1.3
  5. 5. Submodules Project A Project B Symfony PHPUnit Symfony PHPUnitPHPUnit PHPUnit YAML Mocks YAML Mocks 3.7 3.6 2.2 1.3 1.02 1.1 No autoloading No dependency management
  6. 6. Composer! Project A Project B PHPUnit PHPUnit 3.7 3.6Symfony PHPUnit Symfony PHPUnit YAML Mocks ... YAML Mocks ... 2.2 1.3 1.02 1.1
  7. 7. Composer! •Autoloading • Dependency Management • Per project dependencies • Part of build
  8. 8. Composer is a tool fordependency managementin PHP. It allows you todeclare the dependentlibraries your project needsand it will install them inyour project for you.
  9. 9. Installation •Locally • curl -sS https://getcomposer.org/ installer | php •Globally • sudo mv composer.phar /usr/local/bin/ composer • composer selfupdate <- Do regularly
  10. 10. Silex Sample •Create empty project folder • Create composer.json
  11. 11. Silex Sample
  12. 12. Silex Sample• >composer install
  13. 13. Silex Sample • include autoloader • write controller
  14. 14. Silex Sample • add monolog
  15. 15. Silex Sample • >composer update
  16. 16. Silex Sample • add logging code
  17. 17. DefiningDependencies Vendor/Package Version Stability Requirements
  18. 18. InstallingDependencies• >composer install• downloads dependencies to vendor folder•generates autoloader
  19. 19. Using Dependencies •PSR-0 - Standards defining naming conventions for autoloading. •Use composer generated autoloader
  20. 20. UpdatingDependencies •>composer update • upgrades packages to latest version based on rules in composer.json
  21. 21. Install vs Update •composer.lock •tracks versions of dependencies used •commit it •install-looks for composer.lock then composer.json •update-looks straight at composer.json and updates composer.lock
  22. 22. Working in a Team•Elect a dependency manager • manages and commits composer files•add vendor folder to git/svn ignore
  23. 23. Finding Packages •Packagist • >composer search ... • Github • look for composer.json
  24. 24. Older Packages Define a package repository in your composer.json Specify locations of sources Instruct autoloader• Hopefully its PSR-0 compliant
  25. 25. Bleeding Edge Version Tag Version Branch Other Branch
  26. 26. Custom Forks • Fork on Github • Add your repo • Specify your branch
  27. 27. Bootstrapping>composer create-project -s dev fabpot/silex-skeleton .
  28. 28. More? • http://getcomposer.org • http://packagist.org • https://github.com/php-fig/fig- standards/blob/master/accepted/ Thanks Derek Gallo @derekgallo http://github.com/drock
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×