2017年4月23日 11:14:09 星期日
PHP的composer可以类比 java的maven, node的npm, 或者linux centos的yum
1. 要先到国外的composer官网下载install文件
2. 用PHP执行该install 文件, 检查一下当前PHP配置, 没啥问题的话这个install 会自动下载composer.phar到当前目录下边
注: 这里提示了, 需要安装开启PHP的zlib扩展, 随后在运行的时候还会提示xdebug会影响效率, 而且不能一root权限去运行composer命令
3. composer.phar是PHP的一个包, 类似java的jar包, 它是个可执行文件, 文件第一行指明了需要PHP命令执行他自己, 因此可以直接运行该文件
先将它复制到PHP的bin下边, 保证可以被全局访问到, 然后命令行输入 composer
1 cp composer.phar /usr/local/web/php/bin/composer 2 3 composer -v 4 You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug 5 Do not run Composer as root/super user! See https://getcomposer.org/root for details 6 ______ 7 / ____/___ ____ ___ ____ ____ ________ _____ 8 / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ 9 / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / 10 \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ 11 /_/ 12 Composer version 1.4.1 2017-03-10 09:29:45 13 14 Usage: 15 command [options] [arguments] 16 17 Options: 18 -h, --help Display this help message 19 -q, --quiet Do not output any message 20 -V, --version Display this application version 21 --ansi Force ANSI output 22 --no-ansi Disable ANSI output 23 -n, --no-interaction Do not ask any interactive question 24 --profile Display timing and memory usage information 25 --no-plugins Whether to disable plugins. 26 -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. 27 -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
4. 因为composer不能以root权限运行, 所以一些写操作不能执行, 因此, 在安装项目的时候, 一定要先把项目目录的权限设置为可写可执行的
sudo chmod -R 777 composer/
否则会报写失败(file_put_contents...失败):
composer install Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 0 removals - Installing monolog/monolog (1.0.2): Downloading (100%) [ErrorException] file_put_contents(./composer.lock): failed to open stream: Permission denied install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...
时间: 2024-10-12 19:56:53