laravelvagrantsymlinkhomestead

Symbolic link issues on Laravel/Homestead/Windows


I'm having problems displaying images stored in the storage folder. At the moment all file uploads are configured to end up in the following folder:

storage\app\public

And I'm trying to access them as follows:

http://homestead.vaniloapp-demo/storage/6/testimage.jpg

However, this results in a 404.

If I run: php artisan storage:link I get the following error message:

"The "public/storage" directory already exists."

I have tied a bunch of different tips and tricks from various other threads including unlinking the public folder using unlink storage and then attempting to link it again manually using ln -s ../storage/app/public storage but that results in the following error:

"failed to create symbolic link 'storage': Protocol error"

Have tried using Sudo, have tied launching CMD as Administrator.

I'm running Homestead and Vagrant for Windows.

Thanks in advance!

Mika


Solution

  • Here are the best steps I've come up with

    1. Unlink storage on your current Vagrant instance
    2. Halt vagrant vagrant halt
    3. Run CMD/Terminal as Administration (Right click > Run as administrator)
    4. Go to your Homestead folder and start vagrant vagrant up --provision
    5. SSH into vagrant vagrant ssh while still in the same CMD/Terminal
    6. CD into your Laravel directory and run php artisan storage:link

    I've seen people have issues while the vagrant box has not been started in the CMD administration mode.

    Hope this helps.