眾所周知,在國內的PHP領域,thinkphp框架 占據著大半江山,既然我們聊composer,那么就從最權威的框架thinkphp這里著手開始講!
我們通過 `composer create-project topthink/think tp` 命令來安裝


```
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)
```