I deployed laravel app on shared hosting in public_html/app folder. Here is everything from public folder. In /../../files I have rest of files. When I do php artisan storag
Just in case your down here still without an answer.
I had trouble because I did the symlink locally, then copied the files to the server. In order to make it work I did the following:
$ cd path/to/laravel/root
// if public does not exist, first create it.
$ cd public
// if public/storage does not exist, first create it.
$ rm -r storage
$ cd ..
// Now it should work
$ php artisan storage:link
I'm face same error when use share hosting and my public directory move to public_html or different directory like : project directory in root name "project" and public directory in root name "public_html"
when run artisan command by Artisan::call('storage:link'); then face this error.
Solution: 1st need to bind your public directory in app/Providers/AppServiceProvider register method
$this->app->bind('path.public', function() {
return base_path('../public_html');
});
Now run the command its working fine
Go to config/filesystem.php in the symbolic links section in my case I removed public_path function and wrote my own path in it then run php artisan storage:link command again.
'links' => [
'/var/www/storage' => storage_path('app/public'),
],
Worked for me.
Make sure the APP_URL
configuration in .env
file is set correctly. after that run following command line:
php artisan config:cache
php artisan storage:link
My problem was that te symlink not was placed in /localhost/public/ but in /localhost/storage/app/ When i removed the symlink in /localhost/storage/app/ the artisan command works like a charm
In my code i placed this to prevent creating the wrong symlink
Route::get('/clear', function () {
Storage::deleteDirectory('public');
Storage::makeDirectory('public');
Artisan::call('route:clear');
Artisan::call('storage:link', [] );
});
Go to /public
directory and run:
rm storage
Go to Laravel root directory and run:
php artisan storage:link
Edited on May 1st 2018
This problem comes when laravel project is moved/copied to some other folder.
The storage link is still there thus causing the exception error. public/storage folder exists and points to wrong location and it needs to be deleted with rm storage
command.
After that run php artisan storage:link
in terminal and it will create the storage link.
This needs to be done EVERY time when laravel is moved/copied/deployed!