I am trying to make a middleware using artisan php artisan make:middleware AuthorizedUserOnly
but I get ErrorException
like below.
file_get_contents(/mysite.com/www/local/composer.json) Failed to open stream no such file or directory.
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. Like I tried php artisan route:list
& php artisan config:cache
& php artisan tinker
.composer.json
in local
directory while it is on document root
.php artisan make:model
command spits the same Exception
What could be the possible issue and solution ?
Solution : I moved my composer.json
file to local
directory and it worked fine. 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. So to included these created files into system execute composer dump-autoload
. So to run composer
it looks for in the same directory where artisan
lives which is local
directory in my case.
IMPORTANT
I changed laravel default directory structure to successfully run my applicaiton on SHARED HOSTING which laravel DOESNOT RECOMMEND.
We should follow the recommendations made by laravel to avoid any similiar issue. Specially never to mess with default directory structure at least.