企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
众所周知,在国内的PHP领域,thinkphp框架 占据着大半江山,既然我们聊composer,那么就从最权威的框架thinkphp这里着手开始讲! 我们通过 `composer create-project topthink/think tp` 命令来安装 ![](https://img.kancloud.cn/95/8f/958f4b9e6927084e2e40c93bf7252ac4_800x340.png) ![](https://img.kancloud.cn/22/49/2249ca123f945e09b419691677fdbaa4_800x340.png) ``` E:\code-thinkphp>composer create-project topthink/think tp Installing topthink/think (v6.0.3) - Installing topthink/think (v6.0.3): Loading from cache Created project in tp Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 16 installs, 0 updates, 0 removals - Installing psr/container (1.0.0): Loading from cache - Installing topthink/think-helper (v3.1.4): Loading from cache - Installing psr/log (1.1.3): Loading from cache - Installing psr/simple-cache (1.0.1): Loading from cache - Installing topthink/think-orm (v2.0.33): Loading from cache - Installing symfony/polyfill-php80 (v1.18.1): Loading from cache - Installing symfony/polyfill-php72 (v1.18.1): Loading from cache - Installing symfony/polyfill-mbstring (v1.18.1): Loading from cache - Installing symfony/var-dumper (v4.4.13): Downloading (100%) - Installing opis/closure (3.5.7): Downloading (100%) - Installing psr/cache (1.0.1): Loading from cache - Installing league/mime-type-detection (1.4.0): Downloading (100%) - Installing league/flysystem (1.1.3): Downloading (100%) - Installing league/flysystem-cached-adapter (1.1.0): Loading from cache - Installing topthink/framework (v6.0.3): Loading from cache - Installing topthink/think-trace (v1.3): Loading from cache symfony/var-dumper suggests installing symfony/console (To use the ServerDumpCommand and/or the bin/var-dump-server script) league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem) league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files) league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage) league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage) league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2) league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3) league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage) league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications) league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib) league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter) league/flysystem-cached-adapter suggests installing ext-phpredis (Pure C implemented extension for PHP) Writing lock file Generating autoload files > @php think service:discover Succeed! > @php think vendor:publish Succeed! ``` 上边罗列了所有安装过程,我们可以看到,总共用了以下十六个依赖包。 细心的开发人员会说:这些依赖包真好啊!但为什么用这么多包呢?这些包都在我的系统中干了些什么? 粗心的开发人员会说:这些依赖包真好啊!我又可以懒一阵子了! ``` psr/container (1.0.0) topthink/think-helper (v3.1.4) psr/log (1.1.3) psr/simple-cache (1.0.1) topthink/think-orm (v2.0.33) symfony/polyfill-php80 (v1.18.1) symfony/polyfill-php72 (v1.18.1) symfony/polyfill-mbstring (v1.18.1) symfony/var-dumper (v4.4.13) opis/closure (3.5.7) psr/cache (1.0.1) league/mime-type-detection (1.4.0) league/flysystem (1.1.3) league/flysystem-cached-adapter (1.1.0) topthink/framework (v6.0.3) topthink/think-trace (v1.3) ``` 这些是怎么互相依赖的呢?我们接下来会一一分析一下! 我们总结这16个库,一共可以分为5类,分别为 psr、topthink、symfony、 opis、 league ### (一)PSR,共4个库 ``` psr/container (1.0.0) psr/log (1.1.3) psr/simple-cache (1.0.1) psr/cache (1.0.1) ``` ### (二)topthink,共4个库 ``` topthink/think-helper (v3.1.4) topthink/think-orm (v2.0.33) topthink/framework (v6.0.3) topthink/think-trace (v1.3) ``` ### (三)symfony,共4个库 ``` symfony/polyfill-php80 (v1.18.1) symfony/polyfill-php72 (v1.18.1) symfony/polyfill-mbstring (v1.18.1) symfony/var-dumper (v4.4.13) ``` ### (四)opis,共1个库 ``` opis/closure (3.5.7) ``` ### (五)league,共3个库 ``` league/mime-type-detection (1.4.0) league/flysystem (1.1.3) league/flysystem-cached-adapter (1.1.0) ```