0
Composer

Dependency Management in PHP
Presentation by: Bradley Jacobs / @crazyjaco

@crazyjaco
Some assumptions

WordPress directory structure
JSON
Working with multiple WordPress sites
Talking Points

Goals
What is Dependency Management
Introduction to Composer
The composer.json file
The composer.lock file...
TLDR;

Getting to a better workflow through Composer
Goal:
Rapidly create a WordPress server setup that can be replicated
...
WordPress Skeleton

https://github.com/markjaquith/WordPress-Skeleton
. w/
/p
.w/pamn
/pw-di/
.w/pcnet
/pw-otn/
.w/picue/
...
Dependency/Package
Management
What is a package?
A package is just a bunch of files in a folder
Dependencies are a type of...
Why Package/Dependency Management?

Modern day web pages are rarely self-contained.
Frameworks
Libraries
Scripts
Dependency Management vs
Package Management
Introducing Composer
http://getcomposer.org
Demo 1 - PHPUnit

{

}

" ae: " rz j c/ hu i- e t,
nm" cayaoppntts"
" ecito" " ts o uigcmoe wt ppnt,
dsrpin: A et f sn ops...
Installation

Mac/Linux

$cr -Shts/gtopsrogisalr |pp
ul s tp:/ecmoe.r/ntle
h
$m cmoe.hr/s/oa/i/opsr
v opsrpa urlclbncmoe

...
composer.json
Schema Documentation
File acts as both a consumer and provider
{
" ae: " rd e /y ol rj c "
n m" ba ly mc o po et,
" ec it o" " hs p oe td e co s uf,
d s rp in : Ti r jc os ol t f"
" ew ...
{

" ae:"rde/yolrjc"
nm" balymcopoet,
" ecito" "hspoetde co suf,
dsrpin: Ti rjc os ol tf"
" ewrs:[wrcm" "otn,"ol]
kyod" "o...
Composer.lock
Autoloading

*** All dependencies are loaded into the '/vendor' folder ***

rqie'edratla.h'
eur vno/uoodpp;

This one line...
Package Repositories

Where do we find and get the packages for composer to install?
Packagist.org
Packagist.org
Using Composer w/
WordPress
custom installers, WPackagist.org
WPackagist.org
Custom Installers

It will be necessary for additional actions on occasion, like
installing something outside the /vendor ...
Hosted Plugin
{
" ae: " op i cc op ui "
n m" om hn /o l lg n,
" ye: " od r s- lg n,
t p" wr pe sp u i"
" eu r" {
r q ie :
...
Demo 2

Using the Custom Installer for WordPress Plugins
{
" ae: " rz j c/ od rs - op sr ts "
n m" ca ya ow r pe sc mo e- ...
Final Demo - WordPress Endgame
Goal: Generate the WordPress Skeleton
. w/
/p
.w/pamn
/pw-di/
.w/pcnet
/pw-otn/
.w/picue/
/...
{
" ae: " rz j c/ pf l- e o,
nm" cayaow-uldm"
" ecito" "ulWrPesIsalDm"
dsrpin: Fl odrs ntl eo,
" ewrs:[WrPes,"hm" "lgn,"op...
Where do we go from here
Integration of Source Control (SVN, Git, Hg)
Pre/Post install hooks
WP-CLI commands
Wrapping Up

Goals
What is Dependency Management
Introduction to Composer
The composer.json file
The composer.lock file
Au...
Resources:
Composer Documentation
http://composer.rarst.net/
Trac ticket #23912 - Add composer support to WordPress
Thank You!

@crazyjaco | github.com/crazyjaco
Upcoming SlideShare
Loading in...5
×

An Introduction to PHP Dependency Management With Composer

3,306

Published on

Bradley Jacob's talk from WordCamp Boston 2013

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

  • Be the first to like this

No Downloads
Views
Total Views
3,306
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "An Introduction to PHP Dependency Management With Composer"

  1. 1. Composer Dependency Management in PHP Presentation by: Bradley Jacobs / @crazyjaco @crazyjaco
  2. 2. Some assumptions WordPress directory structure JSON Working with multiple WordPress sites
  3. 3. Talking Points Goals What is Dependency Management Introduction to Composer The composer.json file The composer.lock file Auto-loading Package Repositories Using Composer with WordPress Wrap up Demo
  4. 4. TLDR; Getting to a better workflow through Composer Goal: Rapidly create a WordPress server setup that can be replicated quickly and consistently
  5. 5. WordPress Skeleton https://github.com/markjaquith/WordPress-Skeleton . w/ /p .w/pamn /pw-di/ .w/pcnet /pw-otn/ .w/picue/ /pw-nlds . w-otn/ /pcnet .idxhm /ne.tl .w-ofgpp /pcni.h
  6. 6. Dependency/Package Management What is a package? A package is just a bunch of files in a folder Dependencies are a type of package.
  7. 7. Why Package/Dependency Management? Modern day web pages are rarely self-contained. Frameworks Libraries Scripts
  8. 8. Dependency Management vs Package Management
  9. 9. Introducing Composer http://getcomposer.org
  10. 10. Demo 1 - PHPUnit { } " ae: " rz j c/ hu i- e t, nm" cayaoppntts" " ecito" " ts o uigcmoe wt ppnt, dsrpin: A et f sn opsr ih hui" " ies" "rpitr" lcne: poreay, " eur" { rqie: "hui/hui"".." ppntppnt: 37* }
  11. 11. Installation Mac/Linux $cr -Shts/gtopsrogisalr |pp ul s tp:/ecmoe.r/ntle h $m cmoe.hr/s/oa/i/opsr v opsrpa urlclbncmoe Windows: Download and run the Composer-Setup.exe
  12. 12. composer.json Schema Documentation File acts as both a consumer and provider
  13. 13. { " ae: " rd e /y ol rj c " n m" ba ly mc o po et, " ec it o" " hs p oe td e co s uf, d s rp in : Ti r jc os ol t f" " ew rs: [w rc m" " ot n,"o l ] k y od" "o da p , b s o" c o" , " oe ae: " t p/ gt u. o /r zj c/ yo l rj c" h m pg" ht :/ i hb cm ca ya o mc op oe t, " ye: " ir r " t p" lb ay, " ie s" " I" l c ne : M T, " uh r" [ a t os : { " ae : "r de J cb " nm " Ba l y a o s, " mi " "j c b@ op ic cm , ea l: b ao so m hn .o " " oe a e: "t p/ o mh n. o" hm pg " h t: /o pi cc m } ] , " eo io is: r p st re"{ " ye : "o ps r , tp " cm o e" " r " " tp / cs o- eo og ul : ht :/ ut m rp .r " } , " eu r" { r q ie : "op /r m wr " ". " om hf ae ok : 32 , "ic ma y ai lb ay : "4 0 bg op n/ p- i rr " >. " } , " eu r- e" { r q ie dv : "ut mr p /n tt se " ". ." cs o- eo ui - et r: 2 3* , "og rl g e " " .. " lg e/ og r : 1 7* , "eu /o l " " 2 0 db gt os : ~. " } , " ug s" { s g et : "ol op n /x es o " " lo e tn in t te c r p or m co cm ay et n in : Al w x e so o h o e rg a" } }
  14. 14. { " ae:"rde/yolrjc" nm" balymcopoet, " ecito" "hspoetde co suf, dsrpin: Ti rjc os ol tf" " ewrs:[wrcm" "otn,"ol] kyod" "odap, bso" co", " oeae:"tp/gtu.o/rzjc/yolrjc" hmpg" ht:/ihbcmcayaomcopoet, " ye:"irr" tp" lbay, " ies" "I" lcne: MT, " uhr" [ atos: { "ae:"rde Jcb" nm" Baly aos, "mi " "jcb@opiccm, eal: baosomhn.o" "oeae:"tp/omhn.o" hmpg " ht:/opiccm } ] , " eoiois: rpstre"{ "ye:"opsr, tp" cmoe" "r" "tp/cso-eoog ul : ht:/utmrp.r" } , " eur" { rqie:
  15. 15. Composer.lock
  16. 16. Autoloading *** All dependencies are loaded into the '/vendor' folder *** rqie'edratla.h' eur vno/uoodpp; This one line gives you access to all of the classes in your dependencies.
  17. 17. Package Repositories Where do we find and get the packages for composer to install?
  18. 18. Packagist.org Packagist.org
  19. 19. Using Composer w/ WordPress custom installers, WPackagist.org
  20. 20. WPackagist.org
  21. 21. Custom Installers It will be necessary for additional actions on occasion, like installing something outside the /vendor folder. http://composer.github.io/installers/ - An installer for packages that need special installation based on package type
  22. 22. Hosted Plugin { " ae: " op i cc op ui " n m" om hn /o l lg n, " ye: " od r s- lg n, t p" wr pe sp u i" " eu r" { r q ie : "op sr i sa lr " "" cm oe /n tl e s: * } } Your Project { " ae: " rz j c/ od rs - op sr ts " n m" ca ya ow r pe sc mo e- e t, " ec it o" " t s o u i gc mo e wt W rP es, d s rp in : A e t f sn o ps r ih o dr s " " ie s" " rp it r " l c ne : p o re ay , " eo io is: [ r p st re" { " ye : "o ps r , tp " cm o e" " r " " tp / wa kg s. r" ul : ht :/ pc a it og } ] , " eu r" { r q ie : "pc ai t yt ao hr r lt dp ss pu i "" " wa kg s/ e- n te -e ae -o t -l gn :* , "pc ai t w- ue -a h "" " wa kg s/ ps p rc ce :* , "pc ai t jt ak :* wa kg s/ ep c "" " } , " eu r- e" { r q ie dv : "pc ai t dv lp r :* wa kg s/ ee o e """ } }
  23. 23. Demo 2 Using the Custom Installer for WordPress Plugins { " ae: " rz j c/ od rs - op sr ts " n m" ca ya ow r pe sc mo e- e t, " ec it o" " t s o u i gc mo e wt W rP es, d s rp in : A e t f sn o ps r ih o dr s " " ie s" " rp it r " l c ne : p o re ay , " eo io is: [ r p st re" { " ye : "o ps r , tp " cm o e" " r " " tp / wa kg s. r" ul : ht :/ pc a it og } ] , " eu r" { r q ie : "pc ai t yt ao hr r lt dp ss pu i "" " wa kg s/ e- n te -e ae -o t -l gn :* , "pc ai t w- ue -a h "" " wa kg s/ ps p rc ce :* , "pc ai t jt ak :* wa kg s/ ep c "" " } , " eu r- e" { r q ie dv : "pc ai t dv lp r :* wa kg s/ ee o e """ } }
  24. 24. Final Demo - WordPress Endgame Goal: Generate the WordPress Skeleton . w/ /p .w/pamn /pw-di/ .w/pcnet /pw-otn/ .w/picue/ /pw-nlds . w-otn/ /pcnet .idxhm /ne.tl .w-ofgpp /pcni.h
  25. 25. { " ae: " rz j c/ pf l- e o, nm" cayaow-uldm" " ecito" "ulWrPesIsalDm" dsrpin: Fl odrs ntl eo, " ewrs:[WrPes,"hm" "lgn,"op" , kyod" "odrs" tee, pui" Omh] " oeae:"tp/omhn.o/, hmpg" ht:/opiccm" " ye:"rjc" tp" poet, " ies" "rpitr" lcne: poreay, " uhr" [ atos: { "ae:"rde Jcb -Omh, nm" Baly aos op" "mi " "jcb@opiccm, eal: baosomhn.o" "oeae:"tp/omhn.o" hmpg " ht:/opiccm } ] , " eoiois:[ rpstre" { "ye:"opsr, tp" cmoe" "r" "tp/wakgs.r" ul : ht:/pcaitog } , {
  26. 26. Where do we go from here Integration of Source Control (SVN, Git, Hg) Pre/Post install hooks WP-CLI commands
  27. 27. Wrapping Up Goals What is Dependency Management Introduction to Composer The composer.json file The composer.lock file Auto-loading Package Repositories Using Composer with WordPress Wrap up Demo
  28. 28. Resources: Composer Documentation http://composer.rarst.net/ Trac ticket #23912 - Add composer support to WordPress
  29. 29. Thank You! @crazyjaco | github.com/crazyjaco
  1. A particular slide catching your eye?

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

×