2

I´ve created a duplicate project of mine to upgrade from Laravel 10 to Laravel 12. As far as the PHP code, routes, and database everything went well as expected.

Yet, in my Laravel 10 project I had my images, css, js, inside the /storage/app/public/ directory and I´ve been calling those assets, for instance an image in the frontend home view as

<img src="{!! asset('assets/images/logos/LOGO-SQUARE-BLUE-WHITE.svg') !!}" class="img-fluid floating-top-logo" style="width: 100% \9;" alt="{!! config('app.name') !!}"> and all works perfectly.

On the new Laravel 12, I´ve maintained the same storage links and same directory structures (both in view and in storage), but the images do not show and all the assets in the deve console display as 404 (not found).

I have removed all the symlinks and rebuild the filesystem configuration again with artisan storage:link. The symlinks were created in the /public/directory.

In the config/filesystems.php configuration file I have the following:

links => [
    public_path('assets') => storage_path('app/public'),
]

The above configuration works in my Laravel 10 project and not on 12.

What I've noticed is that the symlinks in the /public/ directory are referencing the full path to the external drive. E.g. assets -> /Volumes/SERVERS/VirtualBoxes VMS/Servers/nginx24/www/myproject/storage/app/

Any ideas of what I might be doing wrong? Thanks in advance for any help.

1 Answer 1

3

After digging in the documentation, and finding nothing that would point me to solve the issue, I started digging inside the vendor/laravel/ codebase finding how the storage:link command is created. Guess what? To create the symlinks with a relative path, instead of the absolute path, there's a flag artisan storage:link --relative that will do the job. Yet this is not in the documentation nor if one enters the cli command artisan storage --help.

But there´s more... to be able to use the command artisan storage:link --relative the symfony/filesystem package must be installed via composer.

If someone falls in this "trap" the solution is explained above.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.