Skip to content

Testing & Troubleshooting ​

Running the package tests ​

bash
composer install
vendor/bin/phpunit

The suite uses Orchestra Testbench and an in-memory SQLite database. CI runs it on PHP 8.2, 8.3 and 8.4.

Testing uploads in your app ​

php
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;

public function test_admin_can_upload_a_cover(): void
{
    Storage::fake('public');

    $this->actingAs($this->admin())
        ->postJson(route('mediaflow.upload'), [
            'file' => UploadedFile::fake()->image('cover.jpg', 1200, 800),
        ])
        ->assertOk()
        ->assertJsonPath('success', true);
}

UploadedFile::fake()->image() needs the GD extension.

Common problems ​

SymptomFix
401 Unauthenticated or a redirect to loginSign in, or for a local demo only set MEDIAFLOW_AUTH_ENABLED=false.
403 for a signed-in userThe user fails a role, permission, gate or callback check. See Access Control.
419 CSRF token mismatchAdd <meta name="csrf-token" content="{{ csrf_token() }}"> to your layout. The components also read data-csrf-token and can refresh the token from /mediaflow/csrf-token.
Images return 404 on the public diskRun php artisan storage:link and check APP_URL.
No thumbnailsEnable the PHP gd extension with WebP support. Check the Diagnostics page.
MIME type [...] is not allowedAdd the detected type to allowed_mimes, e.g. image/*.
413 or an empty uploadRaise upload_max_filesize, post_max_size and your web server's body limit.
"Cloud storage needs the S3 driver"Run composer require league/flysystem-aws-s3-v3 "^3.0". It is normally installed with MediaFlow.
Any file type accepted, or no thumbnails, after a deployYour config cache predates MediaFlow. Run php artisan config:cache. MediaFlow loads safe defaults and logs a warning until you do.
Old UI behaviour after updatingRe-publish assets: php artisan vendor:publish --tag=mediaflow-assets --force.
Picker or modal cut off inside a sidebarMake sure mediaflow.js is loaded; modals are attached to document.body so parents cannot clip them.
Components added by Livewire or Turbo do nothingCall window.MediaFlow.initInput(el), initUploader(el) or initManager(el) after inserting them.

Released under the MIT License.