Composer这里/都有介绍,不要看我的;
Composer 2.0 支持 PHP 5.3.2+
WINDOWS 安装
将PHP添加到系统环境变量中,切换PHP工程目录并执行
php -r “readfile(‘/installer’);” | php
C:\>cd C:\projectPHP\myphpC:\projectPHP\myphp>php -r "readfile('/installer');" | phpDownloading...Composer (version 2.1.3) successfully installed to: C:\projectPHP\myphp\composer.pharUse it: php composer.pharSome settings on your machine may cause stability issues with Composer.If you encounter issues, try to change the following:The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.Upgrade your PHP (5.6.26) to use this location with Composer.C:\projectPHP\myphp>
上面告诉我们 Composer(版本2.1.3)已成功安装到:C:\projectPHP\myphp\Composer.phar,如果有稳定性的问题,可尝试升级PHP
执行 php composer.phar init 按提示填写
C:\projectPHP\myphp>php composer.phar initWelcome to the Composer config generatorThis command will guide you through creating your composer.json config.Package name (<vendor>/<name>) [mmpc/myphp]: vphp/nphpDescription []: testAuthor [, n to skip]: nMinimum Stability []:Package Type (e.g. library, project, metapackage, composer-plugin) []:License []:Define your dependencies.Would you like to define your dependencies (require) interactively [yes]?Search for a package:Would you like to define your dev dependencies (require-dev) interactively [yes]?Search for a package:Add PSR-4 autoload mapping? Maps namespace "Vphp\Nphp" to the entered relative path. [src/, n to skip]:{"name": "vphp/nphp","description": "myphp","autoload": {"psr-4": {"Vphp\\Nphp\\": "src/"}},"require": {}}Do you confirm generation [yes]?Generating autoload filesGenerated autoload filesPSR-4 autoloading configured. Use "namespace Vphp\Nphp;" in src/Include the Composer autoloader with: require 'vendor/autoload.php';C:\projectPHP\myphp>
这样Composer 就创建好了。
接下来就是将vendor/autoload.php添加到项目中;
这里/都有介绍,不要看我的;