Example:
{ "autoload": { "psr-4": { "MyLibrary\\": "src/" } }, "autoload-dev": { "psr-4": { "MyLibrary\\Tests\\": "tests/" } } } include-path²»½¨Ò飺ÕâÊÇĿǰΨһ֧³Ö´«Í³ÏîÄ¿µÄ×ö·¨£¬ËùÓÐеĴúÂ붼½¨ÒéʹÓÃ×Ô¶¯¼ÓÔØ¡£ ÕâÊÇÒ»¸ö¹ýʱµÄ×ö·¨£¬µ« Composer ½«ÈÔÈ»±£ÁôÕâ¸ö¹¦ÄÜ¡£
Ò»¸ö×·¼Óµ½ PHP include_path ÖеÄÁÐ±í¡£
ʵÀý£º
{ "include-path": ["lib/"] }¿ÉÑ¡¡£
target-dirDEPRECATED: This is only present to support legacy PSR-0 style autoloading, and all new code should preferably use PSR-4 without target-dir and projects using PSR-0 with PHP namespaces are encouraged to migrate to PSR-4 instead.
¶¨Ò嵱ǰ°ü°²×°µÄÄ¿±êÎļþ¼Ð¡£
Èôij¸ö°üµÄ¸ùĿ¼£¬ÔÚËüÉêÃ÷µÄÃüÃû¿Õ¼ä֮ϣ¬½«²»ÄÜÕýÈ·µÄʹÓÃ×Ô¶¯¼ÓÔØ¡£¶ø target-dir ½â¾öÁËÕâ¸öÎÊÌâ¡£
Symfony ¾ÍÊÇÒ»¸öÀý×Ó¡£ËüÓÐһЩ¶ÀÁ¢µÄ°ü×÷Ϊ×é¼þ¡£Yaml ×é¼þ¾Í·ÅÔÚ Symfony\Component\Yaml Ŀ¼Ï£¬È»¶øÕâ¸ö°üµÄ¸ùĿ¼ʵ¼ÊÉÏÊÇ Yaml¡£ÎªÁËʹ×Ô¶¯¼ÓÔسÉΪ¿ÉÄÜ£¬ÎÒÃÇÐèҪȷ±£Ëü²»»á±»°²×°µ½ vendor/symfony/yaml£¬¶øÊÇ°²×°µ½ vendor/symfony/yaml/Symfony/Component/Yaml£¬´Ó¶øʹ Symfony ¶¨ÒåµÄ autoloader ¿ÉÒÔ´Ó vendor/symfony/yaml ¼ÓÔØËü¡£
Òª×öµ½ÕâÒ»µã autoload ºÍ target-dir Ó¦¸Ã¶¨ÒåÈçÏ£º
{ "autoload": { "psr-0": { "Symfony\\Component\\Yaml\\": "" } }, "target-dir": "Symfony/Component/Yaml" }¿ÉÑ¡¡£
minimum-stability (root-only)ÕⶨÒåÁËͨ¹ýÎȶ¨ÐÔ¹ýÂË°üµÄĬÈÏÐÐΪ¡£Ä¬ÈÏΪ stable£¨Îȶ¨£©¡£Òò´ËÈç¹ûÄãÒÀÀµÓÚÒ»¸ö dev£¨¿ª·¢£©°ü£¬ÄãÓ¦¸ÃÃ÷È·µÄ½øÐж¨Òå¡£
¶Ôÿ¸ö°üµÄËùÓа汾¶¼»á½øÐÐÎȶ¨ÐÔ¼ì²é£¬¶øµÍÓÚ minimum-stability ËùÉ趨µÄ×îµÍÎȶ¨ÐԵİ汾£¬½«ÔÚ½â¾öÒÀÀµ¹Øϵʱ±»ºöÂÔ¡£¶ÔÓÚ¸ö±ð°üµÄÌØÊâÎȶ¨ÐÔÒªÇ󣬿ÉÒÔÔÚ require »ò require-dev ÖÐÉ趨£¨Çë²Î¿¼ £©¡£
¿ÉÓõÄÎȶ¨ÐÔ±êʶ£¨°´×ÖĸÅÅÐò£©£ºdev¡¢alpha¡¢beta¡¢RC¡¢stable¡£
prefer-stable (root-only)µ±´ËÑ¡Ïî±»¼¤»îʱ£¬Composer ½«ÓÅÏÈʹÓøüÎȶ¨µÄ°ü°æ±¾¡£
ʹÓà "prefer-stable": true À´¼¤»îËü¡£
repositories (root-only)ʹÓÃ×Ô¶¨ÒåµÄ°ü×ÊÔ´¿â¡£
ĬÈÏÇé¿öÏ composer ֻʹÓà packagist ×÷Ϊ°üµÄ×ÊÔ´¿â¡£Í¨¹ýÖ¸¶¨×ÊÔ´¿â£¬Äã¿ÉÒÔ´ÓÆäËûµØ·½»ñÈ¡×ÊÔ´°ü¡£
Repositories ²¢²»Êǵݹéµ÷Óõģ¬Ö»ÄÜÔÚ¡°Root°ü¡±µÄ composer.json Öж¨Òå¡£¸½Êô°üÖÐµÄ composer.json ½«±»ºöÂÔ¡£
Ö§³ÖÒÔÏÂÀàÐ͵İü×ÊÔ´¿â£º
¸ü¶àÏà¹ØÄÚÈÝ£¬Çë²é¿´ ×ÊÔ´¿â¡£
ʵÀý£º
{ "repositories": [ { "type": "composer", "url": "" }, { "type": "composer", "url": "https://packages.example.com", "options": { "ssl": { "verify_peer": "true" } } }, { "type": "vcs", "url": "https://github.com/Seldaek/monolog" }, { "type": "pear", "url": "" }, { "type": "package", "package": { "name": "smarty/smarty", "version": "3.1.7", "dist": { "url": "", "type": "zip" }, "source": { "url": "", "type": "svn", "reference": "tags/Smarty_3_1_7/distribution/" } } } ] }×¢Ò⣺ ˳ÐòÊǷdz£ÖØÒªµÄ£¬µ± Composer ²éÕÒ×ÊÔ´°üʱ£¬Ëü»á°´ÕÕ˳Ðò½øÐС£Ä¬ÈÏÇé¿öÏ Packagist ÊÇ×îºó¼ÓÈëµÄ£¬Òò´Ë×Ô¶¨ÒåÉèÖý«¿ÉÒÔ¸²¸Ç Packagist Éϵİü¡£
config (root-only)ÏÂÃæµÄÕâÒ»×éÑ¡Ï½öÓÃÓÚÏîÄ¿¡£
Ö§³ÖÒÔÏÂÑ¡Ï
ʵÀý£º
{ "config": { "bin-dir": "bin" } } scripts (root-only)Composer ÔÊÐíÄãÔÚ°²×°¹ý³ÌÖеĸ÷¸ö½×¶Î¹Ò½Ó½Å±¾¡£
¸ü¶àϸ½ÚºÍ°¸ÀýÇë²é¿´ ½Å±¾¡£
extraÈÎÒâµÄ£¬¹© scripts ʹÓõĶîÍâÊý¾Ý¡£.
Õâ¿ÉÒÔÊǼ¸ºõÈκζ«Î÷¡£ÈôÒª´Ó½Å±¾Ê¼þ·ÃÎÊ´¦Àí³ÌÐò£¬Äã¿ÉÒÔÕâÑù×ö£º
$extra = $event->getComposer()->getPackage()->getExtra();¿ÉÑ¡¡£
bin¸ÃÊôÐÔÓÃÓÚ±ê×¢Ò»×éÓ¦±»ÊÓΪ¶þ½øÖƽű¾µÄÎļþ£¬ËûÃǻᱻÈíÁ´½Óµ½£¨config ¶ÔÏóÖеģ©bin-dir ÊôÐÔËù±ê×¢µÄĿ¼£¬ÒÔ¹©ÆäËûÒÀÀµ°üµ÷Óá£
ÏêϸÇë²é¿´ Vendor Binaries¡£
¿ÉÑ¡¡£
archiveÕâЩѡÏîÔÚ´´½¨°ü´æµµÊ±Ê¹Óá£
¡¡