2

I Created a Laravel app and I am using a windows PC in combination with Docker and Laradock. Docker runs on WSL2 but mounted to my windows drives (I know, it is very slow and I should switch to working in the Linux Filesystem).

I want to use Laravel's filesystem because I use envoyer to deploy my app. Therefor I created a symlink from public/storage to storage/app/public (default) with php artisan storage:link in the workspace container.

My IDE (PHPStorm) correctly displays the files from the link. Uploading images and thus moving them to the storage folder works as well.

The problem with Laradock (local development setup) is that if I use the URL from the asset() function (mywebsite.test/storage/file.txt for example), I get 404 Not Found. This problem does not persist on my staging linux server. Everything works fine over there.

Someone any idea what the problem could be?

  • Did you run this on your current machine too? `php artisan storage:link` – STA Nov 14 '20 at 12:15
  • I ran it from my machine and from the docker container. I am now rebuilding my laradock containers to try it from workspace immediatly instead and not first from my local machine – Matthias De Schoenmacker Nov 14 '20 at 12:31

2 Answers2

4

Apparently the issue was that you should always make the symlink in the workspace container. My process was the following:

  • docker-compose down
  • docker-compose up
  • docker ps to get workspace container id
  • docker exec -it [workspace-container-id] bash
  • php artisan storage:link in project folder. If this does not work, you can create it manualy from the public folder with ln -sf ../storage/app/public storage
  • Just faced the same problem, forget about the container symlink... BTW if using sail the process is simpler by just doing `sail php artisan ...` – convers39 May 01 '21 at 01:23
0

I had to run it from the Windows host and not from the Docker terminal.

Open a CMD prompt as administrator.

CD to your Laravel Root folder and run the mklink command

mklink /J .\public\storage .\storage\app\public

You should see

Junction created for .\public\storage <<===>> .\storage\app\public

Dragonfly
  • 427
  • 4
  • 5