Looking to hire Laravel developers? Try LaraJobs

laravel-media maintained by ronasit

Description
A module for working with Media.
Author
Last update
2026/04/13 09:58 (dev-master)
License
Links
Downloads
2 332

Comments
comments powered by Disqus

Laravel Media plugin

Coverage Status

Introduction

This plugin adds the ability for users to work with media files.

Installation

  1. Install the package using the following command:
composer require ronasit/laravel-media
  1. Publish the package configuration:
php artisan vendor:publish --provider=RonasIT\\Media\\MediaServiceProvider
  1. For Laravel <= 5.5 add RonasIT\Media\MediaServiceProvider::class to config app.providers list.
  2. Set your project's User model to the media.classes.user_model config.

Usage

All media routes, will be automatically registered with the package installation.

You can manually register package routes in any place in your app routes using Route::media() helper:

#routes/api.php

<?php

use Illuminate\Support\Facades\Route;

Route::group(['middleware' => ['my_auth']], function () {
    Route::media();
});

In this case automatically registered package routes will fails with the 404 code error.

Disable media routes

If you want to disable the automatically registered routes, you can set the api_enable option to false in the config/media.php file:

#config/media.php

return [
    ...

    'api_enable' => false,
];

Customizing

You can register only necessary routes using MediaRouteActionEnum:

#routes/api.php

<?php

use Illuminate\Support\Facades\Route;
use RonasIT\Media\Enums\MediaRouteActionEnum;

Route::media(MediaRouteActionEnum::SingleUpload, MediaRouteActionEnum::Delete);

Integration with LaravelSwagger

This package includes OpenAPI documentation file. To include it to your project's documentation, you need to register it in the auto-doc.additional_paths config:

vendor/ronasit/laravel-media/documentation.json

Contributing

Thank you for considering contributing to Laravel Media plugin! The contribution guide can be found in the Contributing guide.

License

Laravel Media plugin is open-sourced software licensed under the MIT license.