Problems with laravel-medialibrary


I use the spatie/media-library package to handle media in my Laravel project. The uploaded media gets stored in the storage/app/public directory. I have already followed the documentation to persist the storage folder but there seems to be something wrong because I have to constantly run fly ssh console -C "php /var/www/html/artisan storage:link" to make my files available again.

The only thread related to this issue is this one, which doesn’t seem to fix my problem.

Here is my fly.toml file:

app = 'the-wordsmiths-collection'
primary_region = 'mad'
console_command = 'php /var/www/html/artisan tinker'

    NODE_VERSION = '18'
    PHP_VERSION = '8.3'

  APP_ENV = 'production'
  LOG_CHANNEL = 'stderr'
  LOG_LEVEL = 'info'
  LOG_STDERR_FORMATTER = 'Monolog\Formatter\JsonFormatter'
  SESSION_DRIVER = 'cookie'

  internal_port = 8080
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']


  memory = '1gb'
  cpu_kind = 'shared'
  cpus = 1

Here is my GitHub repository for the project, if it helps.

I fixed this by adding the line /usr/bin/php /var/www/html/artisan storage:link to the end of the file.

#!/usr/bin/env bash

/usr/bin/php /var/www/html/artisan config:cache --no-ansi -q
/usr/bin/php /var/www/html/artisan route:cache --no-ansi -q
/usr/bin/php /var/www/html/artisan view:cache --no-ansi -q

/usr/bin/php /var/www/html/artisan storage:link
1 Like