JSON

composer.json ¼Ü¹¹(3)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2018-07-05 16:12 ÎÒÒªÆÀÂÛ( )

Example: {autoload: {psr-4: { MyLibrary\\: src/ }},autoload-dev: {psr-4: { MyLibrary\\Tests\\: tests/ }}}include-path ²»½¨Ò飺ÕâÊÇĿǰΨһ֧³Ö´«Í³ÏîÄ¿µÄ×ö·¨£¬ËùÓÐеĴúÂ붼½¨ÒéʹÓÃ×Ô¶¯¼ÓÔØ¡£ÕâÊÇÒ»¸ö

Example:

{ "autoload": { "psr-4": { "MyLibrary\\": "src/" } }, "autoload-dev": { "psr-4": { "MyLibrary\\Tests\\": "tests/" } } } include-path

²»½¨Ò飺ÕâÊÇĿǰΨһ֧³Ö´«Í³ÏîÄ¿µÄ×ö·¨£¬ËùÓÐеĴúÂ붼½¨ÒéʹÓÃ×Ô¶¯¼ÓÔØ¡£ ÕâÊÇÒ»¸ö¹ýʱµÄ×ö·¨£¬µ« Composer ½«ÈÔÈ»±£ÁôÕâ¸ö¹¦ÄÜ¡£

Ò»¸ö×·¼Óµ½ PHP include_path ÖеÄÁÐ±í¡£

ʵÀý£º

{ "include-path": ["lib/"] }

¿ÉÑ¡¡£

target-dir

DEPRECATED: 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)

ÏÂÃæµÄÕâÒ»×éÑ¡Ï½öÓÃÓÚÏîÄ¿¡£

Ö§³ÖÒÔÏÂÑ¡Ï

  • github-oauth: Ò»¸öÓòÃûºÍ oauth keys µÄÁÐ±í¡£ ÀýÈ磺ʹÓà {"github.com": "oauthtoken"} ×÷Ϊ´ËÑ¡ÏîµÄÖµ£¬ ½«Ê¹Óà oauthtoken À´·ÃÎÊ github ÉϵÄ˽È˲ֿ⣬²¢Èƹý low IP-based rate µÄ API ÏÞÖÆ¡£ ¹ØÓÚÈçºÎ»ñÈ¡ GitHub µÄ OAuth token¡£
  • optimize-autoloader Defaults to false. Always optimize when dumping the autoloader.
  • ʵÀý£º

    { "config": { "bin-dir": "bin" } } scripts (root-only)

    Composer ÔÊÐíÄãÔÚ°²×°¹ý³ÌÖеĸ÷¸ö½×¶Î¹Ò½Ó½Å±¾¡£

    ¸ü¶àϸ½ÚºÍ°¸ÀýÇë²é¿´ ½Å±¾¡£

    extra

    ÈÎÒâµÄ£¬¹© scripts ʹÓõĶîÍâÊý¾Ý¡£.

    Õâ¿ÉÒÔÊǼ¸ºõÈκζ«Î÷¡£ÈôÒª´Ó½Å±¾Ê¼þ·ÃÎÊ´¦Àí³ÌÐò£¬Äã¿ÉÒÔÕâÑù×ö£º

    $extra = $event->getComposer()->getPackage()->getExtra();

    ¿ÉÑ¡¡£

    bin

    ¸ÃÊôÐÔÓÃÓÚ±ê×¢Ò»×éÓ¦±»ÊÓΪ¶þ½øÖƽű¾µÄÎļþ£¬ËûÃǻᱻÈíÁ´½Óµ½£¨config ¶ÔÏóÖеģ©bin-dir ÊôÐÔËù±ê×¢µÄĿ¼£¬ÒÔ¹©ÆäËûÒÀÀµ°üµ÷Óá£

    ÏêϸÇë²é¿´ Vendor Binaries¡£

    ¿ÉÑ¡¡£

    archive

    ÕâЩѡÏîÔÚ´´½¨°ü´æµµÊ±Ê¹Óá£

    ¡¡

    1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

    Ïà¹ØÎÄÕÂ
    • ÊÊÓÃÓÚPHP³õѧÕßµÄѧϰÏß·ºÍ½¨Òé

      ÊÊÓÃÓÚPHP³õѧÕßµÄѧϰÏß·ºÍ½¨Òé

      2018-06-20 08:08

    • phpÓïÑÔÖÐjsonÓëÊý×éÖ®¼äµÄÏ໥ת»»

      phpÓïÑÔÖÐjsonÓëÊý×éÖ®¼äµÄÏ໥ת»»

      2018-04-23 17:00

    • php¶ÁÈ¡±¾µØjsonÎļþµÄʵÀý,php¶ÁÈ¡±¾µØjsonÎļþ,php ¶ÁÈ¡json,j

      php¶ÁÈ¡±¾µØjsonÎļþµÄʵÀý,php¶ÁÈ¡±¾µØjsonÎļþ,php ¶ÁÈ¡json,j

      2018-03-10 18:01

    • ÓžÍÒµPHPѧԺ

      ÓžÍÒµPHPѧԺ

      2018-01-27 08:04

    ÍøÓѵãÆÀ
    ±