Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Pawooo's avatar

Can't get the images to display on my first deploy (heroku, Laravel 9)

Laravel newbie here (shoutout to Brad Traversy).

I've managed to deploy my first Laravel app, but the images won't show up (=as well as other media files that are part of the CRUD functionality=storage folder is not linked properly).

Website URL

Repo URL

filesystems.php

    'default' => env('FILESYSTEM_DISK', 'public'),
    'disks' => [
	        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
            'throw' => false,
        ],
    ]

What I've tried (maybe the implementation was poor so if you're 100% certain this should work, I'll try again):

1. Removed .gitignore /storage and included all the related files to allow linking on the server-side (the storage part of the formula is definitely uploaded to my git repo and should be synched with my heroku app)

2. Edited my composer.json script as advised here

    "scripts": {
		//other standard code here
        "post-install-cmd": [ 
            "ln -sr storage/app/public public/storage" 
        ]
    },

3. Executed both throuth CML and Procfile implementation

  heroku run php artisan storage:link

4. Browsed other laracasts/SO forum entries

5. Browsed a bunch of other threads and guides, because it's extremely weird that this functionality is not covered in deployment guides I cross-referenced 1 2

6. Desperately clenched my fists

I do not want to just create a folder with the same name in public, I want it to be as close as possible to the real environment (I'm fine with heroku's ephemerial file structure since this is simply a portfolio project, setting up S3 is overdoing it for proof-of-concept)

Any advice would be much appreciated, I'm out of options at this point :(

0 likes
17 replies
Pawooo's avatar

@Sinnbeck Another sonic-speed reply! :)

tl;dr they are located in app/public/storage/nekoimg/file-name.jpg

On my repo the public/storage folder does not exist, my understanding was I need to generate it the same way I did by running

heroku run php artisan storage:link

The command does not return any errors, so I decided to browse folder structure as per your advice. The folders seem to be in place, as well as files. Just like in local test environment, they are located in app/public/storage/nekoimg/file-name.jpg

Pawooo's avatar

@Sinnbeck It depends (maybe I totally screwed up that part 0_0)

For static image on my landing page I do this (I can already foresee the solution for this one :))

src="/nekoimg/tran-mau-tri-tam-FbhNdD1ow2g-unsplash.jpg"

For my carousel in my controller I first do this:

    public function index() {
        return view('nekos.index', [
            'nekos' => Neko::latest()->filter(request(['tag', 'nekosagashi']))->simplePaginate(8),
            'randImgs' => Neko::latest()
                            ->inRandomOrder()
                            ->limit(4)
                            ->get()
        ]);
    } 

Then in my blade:

                    @foreach ($randImgs as $randImg)
                        <li class="splide__slide"><img class="splide__img" src="{{$randImg['img']}}" alt="Cat Carousel Image"></li>
                    @endforeach

For each individual card I do this:

Controller:

'nekos' => Neko::latest()->filter(request(['tag', 'nekosagashi']))->simplePaginate(8),

Blade:

@foreach ($nekos as $neko)
 <x-neko-card :neko="$neko"/>
@endforeach

Component:

@props(['neko'])
img src="{{$neko['img']}}"
Sinnbeck's avatar

@Pawooo If the images are in storage, you need that to be part of the url :) So lets say this returns a path without storage {{$randImg['img']}}. Then add it to the path

And its recommended to use the asset() helper for all assets (css images etc) :)

@foreach ($randImgs as $randImg)
                        <li class="splide__slide"><img class="splide__img" src="{{asset('/storage/'.$randImg['img'])}}" alt="Cat Carousel Image"></li>
                    @endforeach
Pawooo's avatar

@Sinnbeck But how come it works on local without prepending /storage?

What kind of magic is this? :)

I'll try it out with asset(), one sec!

Sinnbeck's avatar

@Pawooo Sounds like an issue with your local setup? Are the files placed differently there perhaps? Like not in the storage folder?

Pawooo's avatar

@Sinnbeck Not sure if this matters, but storage folder itself is a shortcut (I hope this conveys what I'm trying to say), on mac it says "Alias." Since I have not created this folder manually I assumed that's just how artisan link works

Sinnbeck's avatar

@Pawooo Yeah that sounds correct. But I am curious how it works locally if the files are only inside the storage directory and not in the root of public/nekoimg. Are they perhaps in both places on your local pc?

Pawooo's avatar

@Sinnbeck That's definitely not the case, folder structure is as follows

| Public

||css

||img

||js

||misc

||storage

In order for that logic to apply I'd have to have 2 extra folders in here (nekoimg and purrsound)

Sinnbeck's avatar

@Pawooo Yeah. But then I dont see how the urls for the images can work locally as they dont have /storage in the url :)

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Btw. The error you are facing currently seems to be due to have ' in the wrong places :)

Correct

{{asset('/storage/'.$randImg['img'])}}

Not correct

{{asset('/storage/$randImg['img']')}}
1 like

Please or to participate in this conversation.