[英]Laravel Artisan make command issue
I am trying to make a middleware using artisan php artisan make:middleware AuthorizedUserOnly
but I get ErrorException
like below. 我正在尝试使用artisan
php artisan make:middleware AuthorizedUserOnly
来制作中间件php artisan make:middleware AuthorizedUserOnly
但ErrorException
如下所示的ErrorException
。
file_get_contents(/mysite.com/www/local/composer.json) Failed to open stream no such file or directory.
file_get_contents(/mysite.com/www/local/composer.json)无法打开流,没有此类文件或目录。
This is my document root. 这是我的文档根目录。
-local
-Laravel application folders
-artisan
-index.php
-composer.json
.htaccess
I changed my directory structure to work with shared hosting. 我更改了目录结构以使用共享主机。 And It was working fine.
而且工作正常。
KEY NOTES 重点说明
artisan
commands work. artisan
命令也可以工作。 Like I tried php artisan route:list
& php artisan config:cache
& php artisan tinker
. php artisan route:list
和php artisan config:cache
& php artisan tinker
。 composer.json
in local
directory while it is on document root
. document root
目录上的local
目录中查找composer.json
。 php artisan make:model
command spits the same Exception
php artisan make:model
命令吐出同样的Exception
What could be the possible issue and solution ? 可能的问题和解决方案是什么?
Solution : I moved my composer.json
file to local
directory and it worked fine. 解决方案 :我将
composer.json
文件移动到local
目录,并且工作正常。 So new directory structure is 所以新的目录结构是
-local
-Laravel Application Folders
-composer.json
-artisan
-index.php
.htaccess
HOW ? 怎么样 ?
I am not sure about this yet. 我还不确定。 But this is the possible reason.
但这是可能的原因。
php artisan make
command create some files. php artisan make
命令创建一些文件。 So to included these created files into system execute composer dump-autoload
. 因此要将这些创建的文件包含到系统中,请执行
composer dump-autoload
。 So to run composer
it looks for in the same directory where artisan
lives which is local
directory in my case. 因此,要运行
composer
它会在artisan
所在的目录中查找local
目录(本例中为local
目录)。
IMPORTANT 重要
I changed laravel default directory structure to successfully run my applicaiton on SHARED HOSTING which laravel DOESNOT RECOMMEND . 我更改了laravel默认目录结构,以在LARavel 不推荐的 SHARED HOSTING上成功运行我的应用程序。
We should follow the recommendations made by laravel to avoid any similiar issue. 我们应该遵循laravel提出的建议,以避免任何类似的问题。 Specially never to mess with default directory structure at least.
特别是至少不要搞乱默认目录结构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.