Slide 1

Slide 1 text

“joind.in” => “twitter” => “#phpcon2015_3” https://m.joind.in/talk/ 6f314

Slide 2

Slide 2 text

$PNQPTFSͰ͸͡ΊΔ ΞϓϦέʔγϣϯ։ൃ 1)1$POGFSFODFCZ!TJ[VIJLP Photo by A.Munich on GATAG

Slide 3

Slide 3 text

,FOJDIJSP,JTIJEB 5PLZP +"1"/ TJ[VIJLP!HNBJMDPN !TJ[VIJLP IUUQTHJUIVCDPNTJ[VIJLP IUUQCMPHPQFOUPLZPKQ +1POMZ

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

from 1999 pear2/pyrus from 2006 from 2008

Slide 6

Slide 6 text

%FQFOEFODZ.BOBHFNFOU •Not Yum or Apt •inspired by node’s npm and ruby’s bundler •Manage libs on per-project

Slide 7

Slide 7 text

https://twitter.com/s_bergmann/status/458265980150767616

Slide 8

Slide 8 text

Photo by hbp_pix on GATAG https://github.com/sebastianbergmann/phpunit/wiki/End-of-Life-for-PEAR-Installation-Method

Slide 9

Slide 9 text

Before Composer pear channel-discover pear.phpunit.de pear channel-discover components.ez.no pear channel-discover pear.symfony-project.com pear channel-discover pear.symfony.com pear install pear.symfony.com/Yaml pear update-channels pear upgrade-all pear clear-cache pear install -f -a phpunit/PHPUnit phpunit --version

Slide 10

Slide 10 text

After Composer composer require phpunit/phpunit or composer install

Slide 11

Slide 11 text

PHP The Right Way. http://ja.phptherightway.com/

Slide 12

Slide 12 text

1)1FS͕޾ͤʹͳΔͨΊͷಓඪ The way on happiness for PHPer

Slide 13

Slide 13 text

wίʔσΟϯάελΠϧ $PEJOH4UZMF • PSR-0, PSR-1, PSR-2, PSR-4, Zend, Symfony w໊લۭؒ /BNFTQBDFT • PSR-0, PSR-4

Slide 14

Slide 14 text

autoloading •require΍require_once͸ඞཁͳ͘ͳΔ No needed require / require_once •__autoload >= PHP5.0 •spl_autoload_register >= 5.1.2

Slide 15

Slide 15 text

Demo

Slide 16

Slide 16 text

curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer https://getcomposer.org/doc/00-intro.md

Slide 17

Slide 17 text

composer init

Slide 18

Slide 18 text

composer install

Slide 19

Slide 19 text

composer dumpautoload

Slide 20

Slide 20 text

Α͘࢖͏ίϚϯυ commonly-used commands

Slide 21

Slide 21 text

require composer require phpunit/phpunit composer require --dev phpunit/ph...

Slide 22

Slide 22 text

remove composer remove phpunit/phpunit composer remove --dev phpunit/ph...

Slide 23

Slide 23 text

update composer update phpunit/phpunit composer update --with-dependencies\ phpunit/phpunit

Slide 24

Slide 24 text

list / help composer list composer help require

Slide 25

Slide 25 text

config composer config --editor --global { "config": { "github-oauth": { "github.com": "abcd18397ef6547df" } } }

Slide 26

Slide 26 text

ࠔͬͨΒhelp me

Slide 27

Slide 27 text

-v | -vv | -vvv composer -vvv install

Slide 28

Slide 28 text

νʔϜͰ࢖͏ for the team Photo by StartupStockPhotos on GATAG

Slide 29

Slide 29 text

init composer.json require update remove /vendor/* composer.lock install /vendor/*

Slide 30

Slide 30 text

ߋ৽VQEBUF • όʔδϣϯΛݻఆ͢Δɺ*ͳͲΛ࢖Θͳ͍ recommend use fix version. no use * or dev- master • update࣌ʹύοέʔδ໊Λࢦఆ͢Δ using composer update with package and option -- with-dependencies

Slide 31

Slide 31 text

িಥDPOqJDU 1.ϦϞʔτͷcomposer.lockΛ࠾༻ checkout remote composer.json and .lock 2.composer installͳͲΛ࠶࣮ߦ rerun composer install,require,update or etc.. 3.git add / git commit Photo by Seattle Municipal Archives on GATAG

Slide 32

Slide 32 text

More Tips Photo by meridican on GATAG

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Repositories { "repositories": [{ "type": "vcs", "url": "git://github.com/sizuhiko/Bdd.git" },{ "type": "pear", "url": "https://pear2.php.net" },{ "type": "package", "package": { "name": "smarty/smarty", "version": "3.1.7", "source": { "url": "https://smarty-php.googlecode.com/svn/", "type": "svn", } }

Slide 38

Slide 38 text

Script { "scripts": { "post-update-cmd": "MyVendor\\MyClass::postUpdate", "post-install-cmd": [ "MyVendor\\MyClass::warmCache", "phpunit -c app/" ] } }

Slide 39

Slide 39 text

Public Library composer.json Proxy post-xxxx-cmd Project A Project B

Slide 40

Slide 40 text

Create Project • ϑϨʔϜϫʔΫͳͲΛ࡞ͬͨͱ͖ʹ༗༻ convenience for creation framework • composer create-project --prefer-dist cakephp/app app • create-projectͷίʔϧόοΫΛݺͼग़͢ composer call script of create-project when defined "post-create-project-cmd": [ "php -r \"copy('config/local-example.php', 'config/local.php');\"" ]

Slide 41

Slide 41 text

Photo by A.Munich on GATAG ·ͱΊ wΞϓϦέʔγϣϯ΍ϥΠϒϥϦͷ આ໌Λهड़ wґଘύοέʔδͷ؅ཧ wΦʔτϩʔυ wϦϙδτϦͷ؅ཧ wεΫϦϓτͷ࣮ߦ

Slide 42

Slide 42 text

WJTJUNZCMPHHJUIVC https://github.com/sizuhiko 5IBOLZPV http://blog.open.tokyo.jp