How useful UniSharp file manager works with Laravel?

The UniSharp file manager is a file upload/editor we can use with Laravel 5 till 8.8 and CKEditor / TinyMCE. There are many uses of the package. It provides easy usage for images and files processing, uploads and validation. To use the package, follow the step by step guide below.

Step 1: Installations and Create New UniSharp Project

Open the terminal and pass the command as shown below.

composer create-project --prefer-dist laravel/unisharp blog

Now install the UniSharp file manager package in the Laravel application you created above. Type in the command as shown below.

composer require unisharp/laravel-filemanager

Step 2: Create new UniSharp Providers and Alias

Open the app.php file under the config folder. Add providers and aliases to use the file manager services. You should add the Filemanager and Image service providers.

//Providers
UniSharp\LaravelFilemanager\LaravelFilemanagerServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,

//Aliases
'Image' => Intervention\Image\Facades\Image::class,

Step 3: Publish config files and create symbolic links

Add new commands as shown below to publish Unisharp package’s configuration and assets.

php artisan vendor:publish --tag=lfm_config
php artisan vendor:publish --tag=lfm_public

Next, you should create a symbolic link for the image and file storage.

php artisan storage:link

Step 4: Update .env file

Open the .env file and change the APP_URL variable to your local host or whatever host server location you are using. For example, as shown below.

APP_URL:http://localhost:8000

Step 5: Create new routes

Add a new route in the application that will provide access to the File Manager package. Add the code snippet as shown below to your web.php file.

Route::group(['prefix' => 'laravel-filemanager', 'middleware' => ['web', 'auth']], function (){
    \UniSharp\LaravelFilemanager\Lfm::routes();
});

You can now run the application using the command below.

php artisan serve

Now, open the link below in browser, or wherever your localhost directs to and check the UniSharp file manager functionality.

http://localhost:8000/unisharp-filemanager