本篇文章给大家分享的是有关如何自动加载一个文件后必须执行命令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代码无法跳转的问题,需执行
composer dump-autoload
二、若ide还是无法跳转,可以尝试
逻辑层工厂类,注释@return项,添加所需逻辑层(ShopLogic),ide就能识别跳转了
以上就是如何自动加载一个文件后必须执行命令composer dump-autoload,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。