I have shared my Laravel project, but the images don't show on the production. On the other hand, the project is working perfectly locally, but I faced a problem when I want to run php artisan storage:link on the server in order to show images.
Server OS:Linux GNU/Linux
PHP version : 7.4
Laravel version: 8
yf*******#sg3pl***** [~/a***]$ php artisan storage:link
ErrorException
symlink(): No such file or directory
at vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:315
311▕ */
312▕ public function link($target, $link)
313▕ {
314▕ if (! windows_os()) {
➜ 315▕ return symlink($target, $link);
316▕ }
317▕
318▕ $mode = $this->isDirectory($target) ? 'J' : 'H';
319▕
+15 vendor frames
16 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Thanks in advance.
My similar problem was solved by adding FILESYSTEM_DRIVER = public in .env, you can try this.
I have been solving this issue.
I was wrong, for I deleted the public folder from my project. Moreover, when I deleted the public folder from my project folder, I couldn’t link a storage folder, so I should keep the public file in the main folder project.
=> cd FILE_PROJECT in the root.
=> mkdir public .
=> php artisan storage:link
This way works for me.
Related
I'm trying to extract a zip archive in a docker container app running Laravel 9 on PHP 8.1.7, and i'm facing a weird error.
So if a try this code in a controller
$zip = new ZipArchive();
$result = $zip->open("/var/www/html/public/my_archive.zip");
if ($result === TRUE) {
$zip->extractTo("/var/www/html/public/my_folder");
}
$zip->close();
the files in archive are correctly extracted, but return this error:
ErrorException
ZipArchive::extractTo(/var/www/html/public/my_folder/my_file.xml): Operation failed: Operation not permitted
If I run the same code in php artisan tinker it works.
Anyone have some idea to fix this problem?
It don't seem a permissions related problem, the folder is created with 777 permission and the files are copied correctly.
EDIT
root#5899a5badc45:/var/www/html/public/my_folder# ls -lhart *
-rwxrwxrwx 1 1000 1000 1.3K Oct 25 12:24 phpunit.xml
Thanks
I worked on a team and then clone the laravel/php codes from our repository. When I serve the laravel on localhost, it cannot find all the file inside the public directory and throw an error on the terminal:
[404]: GET /public/css/style.css - No such file or directory
Many answers to similar issues advise me to change the codes in the blade.php file. The problem is that I can't edit the blade.php because it works fine on other team members even though we have the same ubuntu, PHP, and laravel version and .env file.
What I have tried:
Run composer install and composer update
Try different browsers such as firefox and chromium-based browsers
Run php artisan storage:link
Restart apache2
Run npm install and npm run dev
I think there is some package or something missing.
List of paths I get from dd($__data):
"path" => "/project-directory/project-name/app"
"path.base" => "/project-directory/project-name"
"path.lang" => "/project-directory/project-name/resources/lang"
"path.config" => "/project-directory/project-name/config"
"path.public" => "/project-directory/project-name/public"
"path.storage" => "/project-directory/project-name/storage"
"path.database" => "/project-directory/project-name/database"
"path.resources" => "/project-directory/project-name/resources"
"path.bootstrap" => "/project-directory/project-name/bootstrap"
Have you tried?
php artisan storage:link
You need first run
php artisan storage:link
For more details check https://laravel.com/docs/8.x/filesystem
Then you must be check your .env values.
Is correctly APP_URL=
Also in your exception is strange
/public/.../...
Reason is wrong configuration.
First check your .env values like
APP_URL=...
FILESYSTEM_DRIVER=public
then check config/filesystems.php
I'm new on laravel , I didn't write any code yet but when I open my project it gives me this error , anyone can help me to solve it ?
[
Just try http://localhost:8000 since it seems like you already started development server in your local machine using php artisan serve while you were on your project root via terminal.
Or you can try from begining:
Go to your project root from terminal / cmd
Run php artisan serve
Now try http://localhost:8000 which is equivalent to http://localhost/laravel/public , considering laravel is your project folder name.
I have Laravel installed on my localhost. And when I try to deploy it to the server, it throws an error: View [frontend.layouts.login] not found.
And I can see that it is looking at my local file path when on my machine aka:
/Applications/MAMP/htdocs/personal/project_name/resources/views
Instead of the server's file path.
If I try and copy the project outside of the personal folder (on my local machine), so make the file path:
/Applications/MAMP/htdocs/project_name/resources/views
It gives the same issue?
Is it something with caching the views?
The other error on the same page is:
file_put_contents(/Applications/MAMP/htdocs/personal/project_name/storage/framework/sessions/7a0aaa6c977031111312b785c7b7e22a659b6a36): failed to open stream: No such file or directory
And again, the server has nothing to do with my local machine.
What could be going on?
This issue is due to the Laravel Configuration Caching.I suggest you
Remove the configuration cache file
Flush the application cache
Create a cache file for faster configuration loading
To do this, run the following Artisan commands on your command line
php artisan config:clear
php artisan cache:clear
php artisan config:cache
Where you don't have access to the command line on your server, you can programmatically execute commands like this:
Route::get('/clear-cache', function() {
$exitCode = Artisan::call('config:clear');
$exitCode = Artisan::call('cache:clear');
$exitCode = Artisan::call('config:cache');
return 'DONE'; //Return anything
});
I hope this is helpful.
I think this might fix it
Go to config/app.php
and change the url to your production url
'url' => 'http://localhost',
I had the same issue so i tried many things including all the solutions in this question, but it didn't work.
What worked for me is that i just deleted this file bootstrap/cache/config.php and it worked.
Hello i installed laravel 4.2 on my windows pc and get error that view cannot by foundet
InvalidArgumentException
View [layout.index] not found.
my controller content
protected $layout = 'layout.index';
public function home()
{
return $this->layout->content = View::make('content_index.home');
}
but realy file exists 'views/layout/index.blade.php'
its kinda bug or something ?
The folder is actually /layouts, so your view should be located at :
protected $layout = 'layouts.index';
my problem is start after I run this on local:
php artisan config:cache
after that I run this in vagrant and solve problem.
open ssh
php artisan config:cache