ComposerâmonologÌìÒÅ é@seldaekªú·éÆ¢¤±ÆÅA2016N722úÉPHP×ïÌÔOÒªJóêܵ½B
Ýȳܨæêlŵ½I #composer #php #phpstudy #eventdots pic.twitter.com/wvKHgpDNGp
| µß¶ (@TAKA_0411) 2016N722ú
®æ
@seldaek Ì\
\¿Í±¿ç: Composer in 2016
#phpstudy #eventdots pic.twitter.com/h4UeksQGvJ
| Hiraku (@Hiraku) 2016N722ú
Composerðg¢ñÅÈ¢Æí©çÈ¢àeà Á½Æv¤ÌÅAèÉâ«ðàµæ¤Æv¢Ü·B
composerÌGRVXeÉ¢Ä
ComposerÌ|WgEPackagistÌ»ÝÌXe[^XÉ¢ÄB
¨¨Ü©ÈàÌÍPackagist/statisticsÅÇßÜ·ªc
Started April 2011 (5 years!)
~400K visits / month
~200K unique visitors / month
100K packages
2.4 billion installs since April 2012
ÆPackagistÌO©çAComposer[U[Ì«ðWv·é±ÆªÅ«Ü·B
á¦ÎAPHPÌo[WðWv·éƱñÈ´¶B
PHP5.6ªêÔ½ÄAªPHP5.5BÅßPHP5.5ÍEOLÉÈÁ½ÌÅAܾgÁÄ¢élÍAbvf[gµÜµå¤ËB
êûAo^³ê½composer.jsonÌrequireÝèÉ©êÄ¢éPHPo[WÍA\5.3ª½¢ÍlB
¦CuªT|[gµÄ¢éPHPÌŬo[WðÓ¡µÜ·B
5.2 2.51%
5.3 45.26%
5.4 31.69%
5.5 15.48%
5.6 3.52%
7.0 1.54%
45.26%Í5.3ðT|[gµÄ¢ÄA5.3ðØèÌÄÄ5.4È~ÌÝεĢé̪31.69% »ë»ë5.3ÍØÁÄ¢ÁÄàÇ¢©È[Æ¢¤µÍCð´¶Ü·B
ComposerÌxXgvNeBXFX
platformÌÅè»
composer update
R}hðÅÁ½AftHgÅÍÀs³ê½Â«ÌPHPo[WðÇÝæÁÄA˶ÖWððµÜ·B
µ©µAá¦ÎMacÌPHPª5.5Å{Ô«ª5.4¾Á½êAcomposer updateµÄlockt@CðìÁ½_ÅÍ5.5pÌCuªCXg[³êĵܢAfvCµÄ©ç®©È¢IIÈñıÆÉÈé©àµêܹñB
»±ÅAcomposerÉÍ˶ÖWðÌîñðÅè»·éèiª èÜ·B
composer.jsonÉconfig.platformÆ¢¤ÚðÇÁµÜ·B
// composer.json
{
//...
"config": {
"platform": {
"php": "5.6.4",
"ext-mongo": "1.0.0"
}
}
//...
}
±ñÈÉ·éÆAcomposer updateR}hðÀsµ½Â«ªÇ±Å ë¤ÆAPHP5.6.4ü¯ÌCuðTµÄ«ÄêÜ·B±Ìá¾Æext-mongoª¢Ä èÜ·ªA»ÌGNXeVàCXg[³êÄ¢éàÌƩȵÄêÜ·B
¿ÈÝÉAconfigÍGfB^ÅÒWµÈÄàAconfigÆ¢¤TuR}hÅÒWÅ«éÌÅAo¦Ä¨ÆÖÅ·B
$ composer config -l #»ÝÌÝèðS\¦
$ composer config platform.php 5.6.4 #ÇÁ or ã«
$ composer config --unset platform.php #Á·
composer.lockt@CÍR~bgµÜµå¤
composer.lockÍupdateâinstallµ½ãÉìçêéjsont@CÅ·B±êÍo[WÇVXeÉR~bg·éæ¤ÉµÜµå¤B
updateâlockȵÌinstallÍA½ªCXg[³êé©ÛسêܹñBpackagist©çpbP[Wªí³êÄ¢ÄACXg[ɸs·éÂ\«¾ÁÄ èÜ·B
lockt@Cª êÎAjbgeXgµ½Æ«Æ¯¶pbP[WªÄxCXg[³êé±ÆªÛسêÜ·B
éÉCXg[
composerÍWÅ_E[hóµð\¦·éÌÅACIT[o[ÌOªÈé±Æª èÜ·B
--no-progress
IvVð¯éÆA_E[hÌóµð\¦µÈÈéÌÅãYíÉÈèÜ·B
ftHgÅÍAsuggest ( Á½çÖ¾æA§¾æjðCuªwèµÄ¢éêA±êðOÉo͵ܷBsvÅ êÎA--no-suggest
ÅÁ·±ÆªoÜ·B
ÆÊ|³¯êÎ--quiet
Æ¢¤IvVà èÜ·BCXg[OðSo͵ÈÈèÜ·B
I[g[_[̬»
PSR-4, PSR-0ÈÇÌI[g[_[ÍAñt@CpXÌÀÝêðð·éÌÅá±ÌI[o[wbhª èÜ·B--optimize-autoloader
IvVðg¤ÆPSR-4/PSR-0ðClassMapƵÄf«o·ÌÅAI[g[_[ª¬»³êÜ·B
# D«ÈR}hÉí¹Ät¯çêé
$ composer update --optimize-autoloader
$ composer install --optimize-autoloader
$ composer dump-autoload --optimize-autoloader
¿ÈÝÉȪ`ÆµÄ -o
Åà¯lÌøʪ èÜ·B
vWFNgKÍÉæÁÄͽԪ©©éÌÅAprodÅÌpbP[WA[JCuðìéÆ«Ép·éÆǢŵå¤B
why (depends) / why-not (prohibits)
ÅßÌV@\ / ÜèmçêÄÈ¢@\R[i[B
»ÝÌCXg[³êÄ¢épbP[WêÍshowR}hÅo¹éªAu êHÈñűÌpbP[WüÁÄéñ¾Á¯HvÆvÁ½ÉRð³¦Äêé̪why(depends)R}hB á¦Îphpspec/prophecyðrequireµ½o¦ªÈ¢ÌÉCXg[³êÄ¢éÈçA
$ composer why phpspec/prophecy
$ composer depends phpspec/prophecy # ±Á¿Åàӡͯ¶
phpunit/phpunit 4.8.27 requires phpspec/prophecy (^1.3.1)
Æ¢¤É³¦ÄêÜ·B--tree
-t
Åc[óÉ\¦µÄêÜ·B
$ composer depends phpspec/prophecy -t
phpspec/prophecy v1.6.1 Highly opinionated mocking framework for PHP 5.3+
¤phpunit/phpunit 4.8.26 (requires phpspec/prophecy ^1.3.1)
¤composer/composer dev-master (requires (for development) phpunit/phpunit ^4.5 || ^5.0.5)
why-not (prohibits) ÍtÅAȺ»Ìo[WªCXg[³êĢȢ©ð³¦ÄêÜ·B
Vµ¢o[WªoĢȢ©²×é
outdatedðg¤ÆApbP[WÌVµ¢à̪oÄ¢é©ðmF·é±ÆªÅ«Ü·B
composer update --dry-run
ÈÇà é¯ÇAoutdated¾ÆïÌIÉǤo[WªÏíéÌ©Ì\¦ªí©èⷢŷËB
$ composer outdated
prefer-distIvV
GitHubÈÇÅ|WgðzMµÄ¢éêAgit cloneÅ\[XðƵÄé(prefer-source)©AzipÅ_E[h·é(prefer-dist)©IԱƪūܷB
ÊíAprefer-distÅ_E[hµ½Ù¤ª¬Å·B½¾AANZXg[NÈÇÌFØîñðZbgµÄ¨Kvª éÌÅAÝèÅ«ÄÈ¢lͤܮ©È¢©àµêܹñB
»Ì½ß©AcomposerÍprivate|WgÌêAftHgÅgit cloneµæ¤ÆµÜ·B
±Ì®ðÏXµÄzip_E[hð§·é̪ --prefer-dist
IvVÅA composer install --prefer-dist
ÈÇÌæ¤Ég¢Ü·B
±êÍpbP[W²ÆÉdist©source©Ýèt@CɢĨ±ÆàÅ«Ü·B
{
"config": {
"preferred-install": {
"nelmio/*": "source",
"*": "dist"
}
},
"require": {
"nelmio/foo": "^1.2",
"other/package": "^1.4"
}
}
type=path|Wg (mono-repositoryÌT|[g)
composerÌ|WgÍvcsÈÇFX^Cvª èÜ·ªAÆÅߦ½Ìª path
Æ¢¤|Wg^CvÅ·B±êÍYpX©çV{bNNð£é¾¯Æ¢¤VvÈ@\Å·B
évWFNgªAÅÍsrc/
ȺÉSÌ\[XR[hðËÁñÅ¢½¯ÇAiXåÉÈÁĵܢA|Wg𪵽ÈÁ½ÆµÜ·B
composerÅ¢«ÈèÊÌpbP[WÉØèo»¤Æ·éÆAgit|WgðÊÉ·éKvª èܵ½B¹[ÌÅå«\[Xðڵ֦ȯêÎÈç¸Aå|©èÉÈ調ŵ½B
»±Åpath|WgBPÂÌfBNgÌÅ¡ÌcomposerpbP[Wð¼zIÉØèo·@\Å·Bá¦ÎlibÆ¢¤fBNgðØÁÄA»ÌÉcomposerpbP[WƵĬ§·éæ¤ÈfBNgðzuµA[gÉàcomposer.jsonðìèÜ·B
- lib/
- Date/
- src/...
- composer.json # acme/date pbP[WƵܷ
- Hash/
- src/...
- composer.json # acme/hash pbP[WƵܷ
- Date/
- composer.json # requireÉacme/dateÆacme/hashðüêĨ«Ü·
±ÌóÔÌ[gÅcomposer install
·éÆAvendor/zºÉV{bNNð£ÁÄAdateâhashÌpbP[WðCXg[µ½©Ìæ¤É©¹©¯ÄêÜ·B
\ªÀèµ½çlibȺÌ\[XR[hðÀÛÉ|Wgª·êÎæA»êÜÅÍPÂÌ|WgÌÅD«Èæ¤ÉJ·é±ÆªoÜ·B
¿ÈÝÉtype=pathÌ|WgÍAo[Wwèð"@dev"â"dev-master"ÈÇÉ·éKvª èÜ·B
ú{ÅÌCeVÉ¢Ä
outdatedR}hðú{ÉÄ©çµ½çAÑÁè·éÙÇx©Á½Æ¾ÁÄêܵ½I😃 `íÁ½ÁÛ¢I
ܳ©{lÌXChÉÚ¹Äàç¦éÆÍI ´®I
¿^
Composer©ÌÌo[WÁÄÅßÆAbvf[gª¬¢¯ÇAîÍZ}eBbNo[WjOÈÌH
=> yes. MAJOR.MINOR.PATCHÅA oOtBbNXÈçPATCHðã°ÄA Ý·«ðó³È¢@\ÇÁÈçMINORðã°ÄA å«ÈÏXÍMAJORðã°éB
composerÌvWFNgÅÅà¢ï¾Á½Í½Åµå¤©H
=> `x[VÌÛÆACt[NoXB
composerÌPêÌÓ¡ÍìÈÒÈÌÉASªwöÒÈÌͽÌÈÌH
=> ³ÙÇ[¢RÍÈ¢¯ÇAGoogleæõŲ×ÄàAÆwöÒªoÄéµAÜ ¢¢ñ¶áÈ¢ÌBBÆ̱Æ
composer.lockðR~bg·é×µAÉεÄAmonologÆ©Ílockt@CðR~bgµÄÈ¢¯ÇAǤµÄH
¦@seldaekÍmonologÌìÒÅà èÜ·
=> CuƵÄñ·éi»êPÌÅR}hƵÄgíêé±ÆÍÈ¢jêAÅIIÉrequireµ½vWFNg¤Åcomposer.lockðìéÌÅA»êÅÇ¢ÌÅÍBdvÈÌÍAfvC³êémÉ.lockt@Cª¾mÉè`³êÄ¢é±Æ¾Æv¤B
¼Ì¾êÅcomposerðÄÀ·éÆ¢¤ACfAÍǤv¤H
=> á¦ÎÀñ¾¯l¦êÎGoÈÇÅÀµ½ûªãYíÉìêéÆv¤¯ÇAPHP[U[ªuPHPÅvOCð¢Äg£Å«éæ¤É·évÆ¢¤ªªå«¢ÌÅAPHPÅÀ·é׫¾Æv¤B
ÀñNGXgÌPullRequestÉ¢Ä
Parallel downloader by hirak E Pull Request #5293 E composer/composer
pêí©çÈ¢ÈèÉðµÄðµ½Æ±ëƵÄÍA
- ^f[^Ì_E[h¤ÉÅK»ªüÁÄȢ̪s
- »êüê½çàÁÆPull RequestªåÉÈÁ¿á¤ÌÅA ¦ÄOµÄéñÅ·æcB
- î{IÉcomposerÍeiXtF[YÅ ÁÄAå«ÈPull RequestÍó¯üêÃç¢
- +990sÍå«¢
- RemoteFilesystemÍhackðÏÝdËÄ«½ªÅAèðüêÃ碵AµÁ©èÝ·«ðmFµÈ¯êÎÈçÈ¢
- Èà®ç¢É}[Wl¦éæIÆ̱Æ
Æè ¦¸A¦ÍÍɵÜÈ¢æ¤Éµ½¢B