一,optimize创建的文件在哪里?
执行optimize:
$ php artisan optimizeINFO Caching framework bootstrap, configuration, and metadata. config ................................................................ 57.67ms DONEevents ................................................................ 4.73ms DONEroutes ................................................................ 71.55ms DONEviews ................................................................. 50.69ms DONE
可以看到optimize处理了四类缓存: config/events/routes/views
查看目录:
$ ls bootstrap/cache/
config.php events.php packages.php routes-v7.php services.php
二,cache与clear
缓存命令:
php artisan config:cache
上面命令会生成文件 bootstrap/cache/config.php,
用以下命令来取消配置信息缓存:
php artisan config:clear
此命令做的事情就是把 bootstrap/cache/config.php 文件删除。
其他三项的操作与之相同:
route(路由信息)
event (事件信息)
view (视图信息)
三,统一的优化命令:
optimize命令:
$ php artisan optimize
会生成 bootstrap/cache/packages.php 和 bootstrap/cache/services.php 两个文件
清除生成的两个文件:
$ php artisan clear-compiledINFO Compiled services and packages files removed successfully.
四,清除所有缓存:
$ ls bootstrap/cache/
config.php events.php packages.php routes-v7.php services.php
$ php artisan config:clearINFO Configuration cache cleared successfully. $ php artisan event:clearINFO Cached events cleared successfully. $ php artisan route:clearINFO Route cache cleared successfully. $ ls bootstrap/cache/
packages.php services.php
$ php artisan clear-compiledINFO Compiled services and packages files removed successfully. $ ls bootstrap/cache/
五,php artisan package:discover也会生成packages.php和services.php两个文件
$ ls bootstrap/cache/
$ php artisan package:discoverINFO Discovering packages. laravel/sail ................................................................................................................................ DONElaravel/sanctum ............................................................................................................................. DONElaravel/tinker .............................................................................................................................. DONElaravel/ui .................................................................................................................................. DONEnesbot/carbon ............................................................................................................................... DONEnunomaduro/collision ........................................................................................................................ DONEnunomaduro/termwind ......................................................................................................................... DONE$ ls bootstrap/cache/
packages.php services.php