PHP¹ÜÀíÒÀÀµ(dependency)¹Øϵ¹¤¾ß Composer °²×°ÓëʹÓÃ

5年以前  |  阅读数:492 次  |  编程语言:PHP 

PHP Composer °²×°

ϵͳÐeÇo£º

Composer ÐeÒªPHP5.3.2+ ÒÔÉϵĻ¾³À´ÔËÐС£Óм¸¸oÃo¸ÐµÄPHPÉeÖúͱaÒe±eÖ¾Ò²ÊDZØÐeµÄ£¬µ«°²×°³ÌÐo»a¢³o¾¯¸aeµ±´aeÔÚÈκβ»¼aeÈݵÄÇe¿o¡£

±ÈÈçPHPµÄÀ(C)Õ¹µÄÒªÇoÊÇ£¬°²×°»oÖØбaÒephp without ¨Cdisable-phar

ΪÁË´ÓÔ´µØÖ*°²×°Èi¼þ°u£¬¶ø²»ÊǼoµ¥µÄѹËoÎļþ°u£¬Äu½«ÐeÒª°²×°Èi¼þ°uµÄ°ae±¾¿ØÖƹ¤¾ß£¬±ÈÈçgit¡¢svn»ohgµÈ¡£

Composer ÊǼaeÈݶaƽ̨µÄ£¬ÆaÔËÐÐÊÊÓÃÓÚWindows£¬LinuxºÍOSX¡£

°²×°Ê§°ÜµÄ´iÎoÏuÏ¢£º


    curl -sS https://getcomposer.org/installer | PHP 
    #!/usr/bin/env php 
    some settings on your machine make Composer unable to work properly. 
    Make sure that you fix the issues listed below and run this script again:

    The phar extension is missing. 
    Install it or recompile php without ¨Cdisable-phar

    Your PHP (5.2.9) is too old, you must upgrade to PHP 5.3.2 or higher.

Îҵı¾µØĬÈÏ¿ª¢»¾³ÊÇPHP 5.2.9£¬µ±ÎÒ³¢ÊÔÔÚPHP 5.2.9ÉÏ°²×°Ê±£¬Ìaʾ°ae±¾¹ýµÍ£¬ÐeÒªÉý¼¶µ½PHP 5.3.2 »oÕ߸u¸ßµÄ°ae±¾¡£

ÓÚÊÇÎÒÏÂÔØXAMPP 1.7.7 usb lite °ae±¾¡£


    E:\USB\Dropbox\phpstorm\php53>E:\USB\xampp_177\php\php.exe -v 
    PHP 5.3.8 (cli) (built: Aug 23 2011 11:50:20) 
    Copyright (c) 1997-2011 The PHP Group 
    Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies

XAMPP 1.7.7 ϵÄPHP»¾³ÊÇ5.3.8¡£ÈÈÏÎÒµÄPHP»*¾³´oÓÚµÈÓÚPHP5.3.2ºo¡£

PHP 5.3 °²×° Composer


    E:\USB\Dropbox\phpstorm\php53>curl -sS https://getcomposer.org/installer | E:\USB\xampp_177\php\php.exe 
    #!/usr/bin/env php 
    Some settings on your machine may cause stability issues with Composer. 
    If you encounter issues, try to change the following:

    The openssl extension is missing, which will reduce the security and stability o 
    f Composer. 
    If possible you should enable it or recompile php with ¨Cwith-openssl

    Downloading¡­

    Composer successfully installed to: E:\USB\Dropbox\phpstorm\php53\composer.phar 
    Use it: php composer.phar

×¢Òa£º

ÎҹرÕÁËXAMPP 1.7.7 ApacheµÄSSLÄ£¿e£¬ËuÒÔComposerÌaʾÎÒ¾¯¸ae£¬ÎªÁË°²È«ÒoËؽ¨ÒeÎÒ¿ªÆoSSLÄ£¿e¡£²»¿ªÆoÒ²²»Ó°ÏiʹÓá£
°²×°Ê±µÄ²ÎÊý | PHP£¬Ò»¶¨Òª¸u¸ÄΪÕaeʵµÄPHP»¾³Â¾¶£¬±ÈÈç | E:\USB\xampp_177\php\php.exe
ʹÓÃComposerΪPHP¾¶ + ÃuÁi£¬ÔÚÎÒÃÇ°²×°µÄ»¾³ÖУ¬Ê¹Óý¨Îª£ºE:\USB\xampp_177\php/php.exe composer.phar ÃuÁi¡£
ÎÒ°²×°µÄ»¾³ÊÇÔÚWindowsÏ£¬Èç¹uÔÚLinuxÏ£¬¶øPHP 5.3 »¾³Ò²²»ÔÚĬÈÏPHPÃuÁiÏÂʱ£¬Ó¦¸Ã²ÉÓà | /usr/php/53/usr/bin/php£¬ÀýÈ磺


    curl -sS https://getcomposer.org/installer | /usr/php/53/usr/bin/php

°²×°Íe³Éºo£¬¼i²e°²×°°ae±¾¡£


    E:\USB\Dropbox\phpstorm\php53>E:\USB\xampp_177\php/php.exe composer.phar -V 
    Composer version 0209bd31a0ac3aeb2a68fc81e2d03c71072bef33

¼i²ePHP ComposerÃuÁi£º


    E:\USB\Dropbox\phpstorm\php53>E:\USB\xampp_177\php/php.exe composer.phar 
      ______ 
     / ____/___ ____ ___ ____ ____ ________ _____ 
    / /  / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ 
    / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / 
    \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ 
              /_/ 
    Composer version 0209bd31a0ac3aeb2a68fc81e2d03c71072bef33

    Usage: 
     [options] command [arguments]

    Options: 
     ¨Chelp      -h Display this help message. 
     ¨Cquiet     -q Do not output any message. 
     ¨Cverbose    -v Increase verbosity of messages. 
     ¨Cversion    -V Display this application version. 
     ¨Cansi       Force ANSI output. 
     ¨Cno-ansi      Disable ANSI output. 
     ¨Cno-interaction -n Do not ask any interactive question. 
     ¨Cprofile      Display timing and memory usage information 
     ¨Cworking-dir  -d If specified, use the given directory as working directory 
    .

    Available commands: 
     about      Short information about Composer 
     archive     Create an archive of this composer package 
     config      Set config options 
     create-project  Create new project from a package into given directory. 
     depends     Shows which packages depend on the given package 
     diagnose     Diagnoses the system to identify common errors. 
     dump-autoload  Dumps the autoloader 
     dumpautoload   Dumps the autoloader 
     help       Displays help for a command 
     init       Creates a basic composer.json file in current directory. 
     install     Installs the project dependencies from the composer.lock file 
    if present, or falls back on the composer.json. 
     list       Lists commands 
     require     Adds required packages to your composer.json and installs the 
    m 
     run-script    Run the scripts defined in composer.json. 
     search      Search for packages 
     self-update   Updates composer.phar to the latest version. 
     selfupdate    Updates composer.phar to the latest version. 
     show       Show information about packages 
     status      Show a list of locally modified packages 
     update      Updates your dependencies to the latest version according to 
    composer.json, and updates the composer.lock file. 
     validate     Validates a composer.json

ÕaÑuÎÒÃÇÔÚPHP5.3»*¾³ÏµÄComposerÒѾ­°²×°Íe³É¡£

ÀaËƵĽ¨ÎÒÃÇÒ²¿ÉÒÔ°²×°PHP 5.4µÄ»*¾³ÉÏ¡£

PHP 5.4 °²×° Composer

ÏÂÔØXAMPP 1.8.1 usb lite °ae±¾£¬½«µÃµ½PHP5.4.7»*¾³¡£


    E:\USB\Dropbox\phpstorm\php53>E:\USB\xampp_181\php\php.exe -v 
    PHP 5.4.7 (cli) (built: Sep 12 2012 23:48:31) 
    Copyright (c) 1997-2012 The PHP Group 
    Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

È*¶¨°ae±¾¸ßÓÚPHP 5.3.2 ºo£¬¿ªÊ¼°²×°£º


    E:\USB\Dropbox\phpstorm\php54>curl -sS https://getcomposer.org/installer | E:\USB\xampp_181\php\php.exe 
    #!/usr/bin/env php 
    Some settings on your machine may cause stability issues with Composer. 
    If you encounter issues, try to change the following:

    The openssl extension is missing, which will reduce the security and stability o 
    f Composer. 
    If possible you should enable it or recompile php with ¨Cwith-openssl

    Downloading¡­

    Composer successfully installed to: E:\USB\Dropbox\phpstorm\php54\composer.phar 
    Use it: php composer.phar

°²×°Íe³Éºo£¬¼i²e°²×°°ae±¾¡£


    E:\USB\Dropbox\phpstorm\php54>E:\USB\xampp_181\php/php.exe composer.phar -V 
    Composer version 0209bd31a0ac3aeb2a68fc81e2d03c71072bef33

ÕaÑu£¬PHP 5.4 »*¾³ÏµÄComposerÒ²°²×°³É¹¦ÁË¡£

PHP Composer ʹÓÃ

ÕaÀiÎÒÖ»¼oµ¥ÑÝʾʹÓÃPHP Composer°²×°Symfony¿o¼Ü¡£

Ê×ÏÈ´o¸Å½²½aÒ»ÏÂÃuÁiµÄ±e×¼¸ñʽ£º


    php composer.phar create-project symfony/framework-standard-edition path/ 2.2.1

µÚÒ»¸o²ÎÊýPHPΪ±¾µØPHP¿ª¢»¾³£¬Ö¸ÏoPHPÔËÐÐÃuÁi¡£
µÚ¶þ¸o²ÎÊý£¬Îªcomposer.phar*½Ê½ÏÂÔØ¡£
µÚÈý¸o²ÎÊý£¬Îª¶¯×÷ÃuÁi£¬ÀýÈçcreate-project£¬Ä¿µÄÊÇΪÁË´´½¨Ò»¸oеÄÏiÄ¿´ÓÒ»¸oÈi¼þ°uµ½Ö¸¶¨Ä¿Â¼¡£
µÚËĸo²ÎÊý£¬Îª±¾µØ°²×°µÄĿ¼¡£
µÚÎa¸o²ÎÊý£¬Îª°²×°Èi¼þ°uµÄ°ae±¾¡£

¸u¾ÝÉÏÊoÎÒÃÇÔÚPHP5.4»*¾³Ï°²×°µÄComposer£¬ÎÒÃǵݲװÃuÁiΪ£º


    E:\USB\Dropbox\phpstorm\php54>E:\USB\xampp_181\php/php.exe composer.phar create-project symfony/framework-standard-edition E:\USB\xampp_181\htdocs\Symfony 2.2.1

°²×°½a¹u£º


    Installing symfony/framework-standard-edition (v2.2.1) 
     ¨C Installing symfony/framework-standard-edition (v2.2.1) 
      Downloading: 100%
    Created project in E:\USB\xampp_181\htdocs\Symfony 
    Loading composer repositories with package information 
    Installing dependencies from lock file 
     ¨C Installing doctrine/lexer (v1.0) 
      Downloading: 100%
     ¨C Installing doctrine/annotations (v1.1) 
      Downloading: 100%
     ¨C Installing doctrine/cache (v1.0) 
      Downloading: 100%
     ¨C Installing doctrine/collections (v1.1) 
      Downloading: 100%
     ¨C Installing twig/twig (v1.12.2) 
      Downloading: 100%
     ¨C Installing psr/log (1.0.0) 
      Downloading: 100%
     ¨C Installing doctrine/inflector (v1.0) 
      Downloading: 100%
     ¨C Installing doctrine/common (2.4.0-RC1) 
      Downloading: 100%
     ¨C Installing symfony/symfony (v2.2.1) 
      Downloading: 100%
     ¨C Installing jdorn/sql-formatter (v1.2.0) 
      Downloading: 100%
     ¨C Installing doctrine/dbal (2.3.3) 
      Downloading: 100%
     ¨C Installing doctrine/doctrine-bundle (v1.2.0-beta1) 
      Downloading: 100%
     ¨C Installing doctrine/orm (2.3.3) 
      Downloading: 100%
     ¨C Installing jms/cg (1.0.0) 
      Downloading: 100%
     ¨C Installing phpoption/phpoption (1.2.0) 
      Downloading: 100%
     ¨C Installing jms/parser-lib (1.0.0) 
      Downloading: 100%
     ¨C Installing jms/metadata (1.3.0) 
      Downloading: 100%
     ¨C Installing jms/aop-bundle (1.0.0) 
      Downloading: 100%
     ¨C Installing jms/di-extra-bundle (1.3.0) 
      Downloading: 100%
     ¨C Installing jms/security-extra-bundle (1.4.0) 
      Downloading: 100%
     ¨C Installing sensio/distribution-bundle (v2.2.1) 
      Downloading: 100%
     ¨C Installing sensio/framework-extra-bundle (v2.2.1) 
      Downloading: 100%
     ¨C Installing sensio/generator-bundle (v2.2.1) 
      Downloading: 100%
     ¨C Installing kriswallsmith/assetic (v1.1.0-alpha4) 
      Downloading: 100%
     ¨C Installing symfony/assetic-bundle (v2.1.2) 
      Downloading: 100%
     ¨C Installing monolog/monolog (1.4.1) 
      Downloading: 100%
     ¨C Installing symfony/monolog-bundle (v2.2.0) 
      Downloading: 100%
     ¨C Installing swiftmailer/swiftmailer (v4.3.0) 
      Downloading: 100%
     ¨C Installing symfony/swiftmailer-bundle (v2.2.0) 
      Downloading: 100%
     ¨C Installing twig/extensions (v1.0.0) 
      Downloading: 100%

    kriswallsmith/assetic suggests installing leafo/lessphp (Assetic provides the integration with the lessphp LESS compiler) 
    kriswallsmith/assetic suggests installing leafo/scssphp (Assetic provides the integration with the scssphp SCSS compiler) 
    kriswallsmith/assetic suggests installing leafo/scssphp-compass (Assetic provides the integration with the SCSS compass plugin) 
    kriswallsmith/assetic suggests installing ptachoire/cssembed (Assetic provides the integration with phpcssembed to embed data uris) 
    monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server) 
    monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required)) 
    monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server) 
    monolog/monolog suggests installing mlehner/gelf-php (Allow sending log messages to a GrayLog2 server) 
    monolog/monolog suggests installing raven/raven (Allow sending log messages to a Sentry server) 
    Generating autoload files 
    Clearing the cache for the dev environment with debug true 
    Installing assets using the hard copy option 
    Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework 
    Installing assets for Acme\DemoBundle into web/bundles/acmedemo 
    Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution

´ÓÃuÁiÐнa¹u£¬ÎÒÃÇ¿´µ½ÁËÕu¸oSymfony¿o¼ÜµÄ°²×°¹ý³ÌÓe½a¹u¡£

PHP Composer ¶¨ÒaÒÀÀµ¹Øϵ

ComposerÔÚʹÓÃʱ»a×Ô¶¯Ñ°ÕÒcomposer.jsonÕa¸oÎļþ¡£ composer.json½«ÓÃÀ´¶¨ÒaÕu¸oÏiÄ¿µÄÒÀÀµ°u¡£ÀýÈ磺


    { 
      "require": { 
        "monolog/monolog": "1.2.*" 
      } 
    }

ÒÀÀµ°u¼oµ¥µÄ˵Ã÷£¬ÎÒÃǵÄÏiÄ¿ÐeÒªÒ»Ð(C)´Ó1.2¿ªÊ¼µÄÈκΰae±¾µÄmonolog/monolog°u¡£

ComposerÊÇPHPÖеÄÒ»¸oÒÀÀµ¹Øϵ¹ÜÀi¹¤¾ß¡£Í¨¹ýComposerÎÒÃÇ¿ÉÒÔÔÚ*¢²¼Èi¼þʱ½ÚÊ¡´oÁ¿µÄÎļþÊýÄ¿ºÍ¿ØÖÆÒÀÀµ°uµÄ°ae±¾¡£

PHP Composer ÏiÄ¿

Composer ÏiÄ¿¹Ù*½£ºhttp://getcomposer.org

Composer GithubÏiÄ¿£ºhttps://github.com/composer/composer

PHP ComposerÈi¼þ°uÁбi£ºhttps://packagist.org/

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例