Make hyperf2.0 load faster by only caching file anotations in the vendor directory.
```bash
composer require hectorqin/hyperf-fastloader
```
This component only take effect when the configure scan_cache_vendor_only
is turned on and the configure scan_cacheable
is turned off.
-
Init composer classMap (Very important! If you delete PHP class file in the app dirctory or add/remove composer packages, you need to run this command again).
composer dump-autoload -o
-
Replace
Hyperf\Di\ClassLoader::init();
withHector\FastLoader\ClassLoader::init();
-
Add the configure below to the config file
config/config.php
// is only caching file anotations in the vendor directory 'scan_cache_vendor_only' => env('SCAN_CACHE_VENDOR_ONLY', false),
-
Add the configure below to the env file
.env
SCAN_CACHE_VENDOR_ONLY=true
-
Turn off
scan_cacheable