# Install Flmngr as a module for your Laravel website or app

> Add edsdk/flmngr-server-php with Composer and declare a POST route in routes/web.php that calls FlmngrServer with your dirFiles path.

Source: https://n1ed.com/docs/file-manager/laravel  
Original: https://flmngr.com/doc/install-file-manager-server-php-laravel  
Section: File manager > PHP Laravel package  
Every page of n1ed.com has a Markdown copy at its URL + `.md` (`index.md` after a URL that ends in `/`); all of them are in one file: https://n1ed.com/llms-full.txt

## Install Composer package

Installing the file manager backend into the Laravel framework is easy: in the project directory install the PHP package: [`edsdk/flmngr-server-php`](https://packagist.org/packages/edsdk/flmngr-server-php) with the following command:

```bash
composer require edsdk/flmngr-server-php
```

## Set up routes to map a URL

Configure the routing of your Laravel app to serve a specific URL for communication between the client (file manager dialog) and the server (Laravel app).

You don't even need to have any code in the Laravel controller. It's more easy: in the file `routes/web.php` define a new route that calls a function from the Flmngr package:

```js
Route::post('/flmngr', function () {

    \EdSDK\FlmngrServer\FlmngrServer::flmngrRequest(
        array(
            'dirFiles' => base_path() . '/public/files'
        )
    );

});
```

The code above demonstrates how to manage the public directory `public/files/` with the file manager using the `/flmngr` endpoint (route). Of course, you can manage the entire `public/` directory if you wish.

## GitHub sample

There is a sample on GitHub showing how to implement the Flmngr backend in an existing app:

[Flmngr backend in Laravel app sample](https://github.com/flmngr/flmngr-server-php-laravel-example)

> **Hint:** You can fork the sample if you are starting a new Laravel project where you need the Flmngr file manager to be included.

## Link Flmngr with the server

Using the visual Dashboard, you can specify the URLs of your server to link Flmngr with it.

- **File Manager URL** is the value you've passed into the `Route::post` as the `urlFileManager` option.
- **Files URL** is the URL of your files you manage with Flmngr. `public/` suffix must be omitted.

![File manager control panel](https://n1ed.com/img/screenshots/docs/widgets/config-editor/file-manager-set-url.png)

**Use absolute URLs**. While URLs in the Laravel server should be without a domain, but from the root of your website (like `/path`), these URLs on the client (in Dashboard or config) should be set in the full absolute form (like `http://your-domain.com/path`) to avoid any possible mistakes.

> **Note:** If you use a HTTP proxy server like Nginx, please use URLs it maps to the internal Laravel app.

[Go to Dashboard](https://n1ed.com/dashboard)

> **Note:** Alternatively, you can pass these parameters as the [Flmngr.urlFileManager](https://flmngr.com/doc/api-load#method_load__param_urlFileManager) and [Flmngr.urlFiles](https://flmngr.com/doc/api-load#method_load__param_urlFiles) parameters into the Flmngr config. This is useful when you need to use different directories based on the current user to support [multi-user installations](https://n1ed.com/docs/multisite/separating-file-storages).

### Files URL explanation

The **Files URL** option is the prefix that Flmngr will add to any file when inserting it into your content (or returning it in the callback of your API call). If you can use Flmngr fine, but all inserted images are broken, please see this sample to understand how it works:

**Files URL** or `Flmngr.urlFiles` client-side parameter

`http://your-website.com/files/`

`/var/www/laravel-app/public/files/`

`dirFiles` server-side parameter

\+ `/path/to/image.png`

For example, Flmngr inserts the file `/path/to/image.png` into your content as `http://your-website.com/files/path/to/image.png`, and on the server that file is `/var/www/laravel-app/public/files/path/to/image.png`.

## Multi-user environment

Flmngr can work in applications where you have many users with different storages. You can programmatically specify `Flmngr.urlFiles` and `dirFiles` parameters synchronously with values based on the current user's session.

[Multi-user manual](https://n1ed.com/docs/multisite/separating-file-storages)

## S3/Blob support

Flmngr supports not only your own server but also cloud storages: Amazon S3 and Azure Blob. This is an enterprise feature we offer as a separate option.

[S3/Blob support](https://n1ed.com/docs/cloud-storage)
