本篇文章给大家分享的是有关如何自动加载一个文件后必须执行命令composer dump-autoload,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
一、自动加载一个文件后必须执行命令
{"name":"laravel/laravel","description":"The Laravel Framework.","keywords": ["framework","laravel"],"license":"MIT","require": {"laravel/framework":"4.2.*","pda/pheanstalk":"~2.0","doctrine/dbal":"2.4.*","guzzlehttp/guzzle":"5.3.1","firebase/php-jwt":"4.0","twilio/sdk":"5.7","ircmaxell/random-lib":"1.2","mjaschen/phpgeo":"1.3","dompdf/dompdf":"0.8.2","league/csv":"9.2"},"autoload": {#自动加载,方式分为files(files键对应的值是一个数组,数组元素是文件的路径,路径是相对于应用的根目录)和classmap(通过文件引入的方法虽然直观,但是很费劲,每个文件都得引入一次,实在不是好的解决办法,可以采用classmap,即兼容files,又可目录自动加载)"classmap": ["app/commands","app/controllers","app/models","app/database/migrations","app/database/seeds","app/tests/TestCase.php","app/libraries","app/helpers","app/logic","app/jobs","app/validators","app/3rd","app/classes","app/filters"] },"scripts": {"post-install-cmd": ["php artisan clear-compiled","php artisan optimize"],"post-update-cmd": ["php artisan clear-compiled","php artisan optimize"],"post-create-project-cmd": ["php artisan key:generate"] },"config": {"preferred-install":"dist"},"minimum-stability":"stable","require-dev": {"phpunit/phpunit":"4.8"},"repositories": {"packagist": {"type":"composer","url":"https://packagist.laravel-china.org"} }}
因为app\logic自动加载,每次文件改动理论上无需改动,但是会遇到ide代码无法跳转的问题,需执行
composerdump-autoload
二、若ide还是无法跳转,可以尝试
逻辑层工厂类,注释@return项,添加所需逻辑层(ShopLogic),ide就能识别跳转了
以上就是如何自动加载一个文件后必须执行命令composer dump-autoload,小编相信有部分知识点可能是我们日常工作会见到或用到的。