This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (2.3.0) of this package.

Files management for Laravel

2.3.0 2016-10-25 20:44 UTC


This package handles files upload in friendly DDD manner.


In console run:

composer require desmart/files:2.0.*


Add DeSmart\Files\ServiceProvider\ServiceProvider to providers list.

In console run:

php artisan vendor:publish
php artisan migrate


Add this line to bootstrap/app.php file:


In console run:

cp vendor/desmart/files/database/migrations/* database/migrations/
cp vendor/desmart/files/config/desmart_files.php config/desmart_files.php
php artisan migrate



This package uses Laravels storage mechanism. By default package uses upload disk which needs to be defined in config/filesystems.php.

// config/filesystems.php
return [
    'disks' => [
        'upload' => [
            'driver' => 'local',
            'root'   => public_path('upload'),        


Before saving file it can be mapped by a mapper. Mapper receives generated FileEntity and can change its properties. Based on entity data file will be saved in filesystem, and database.

Mappers must implement DeSmart\Files\Mapper\MapperInterface.

Custom File Entity class

By default package uses DeSmart\Files\Entity\FileEntity. This can be changed in desmart_files.file_entity_class config entry.


Storing file from upload

$file = \Request::file('file');
$source = new \DeSmart\Files\FileSource\UploadedFileSource($file);

// I'm assuming that Manager instance will be injected by Laravel Container
$manager = app('DeSmart\Files\Manager');

// Here we have the FileEntity instance
// File is saved on the filesystem and in the database
$entity = $manager->store($source);

// from here you have save the relation with other entity
// this is just example!


Removing file from storage

This method will work only when given FileEntity has no entries in file_records table.

$file = new FileEntity; // $file should be obtained in different way (e.g through a relation)

$manager = app('DeSmart\Files\Manager');