# Install PHP file manager using Composer

> Run composer require edsdk/flmngr-server-php, point a PHP handler at FlmngrServer, and set the two URLs in the Dashboard to link it.

Source: https://n1ed.com/docs/file-manager/php-composer  
Original: https://flmngr.com/doc/install-file-manager-server-php-composer  
Section: File manager > PHP Composer 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 the package

Go into your PHP project and in its root directory, run:

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

This will install [PHP Flmngr Composer package](https://packagist.org/packages/edsdk/flmngr-server-php).

> **Hint:** If you do not use Composer you can use a [no-Composer archive](https://n1ed.com/docs/file-manager/php-script)

And let some URL be a handler. If you do not use any framework, just create a PHP file `flmngr.php` with the following contents:

```php
<?php
    // Composer's autoloader: flmngr.php sits in the project's root, next to vendor/
    require __DIR__ . '/vendor/autoload.php';

    \EdSDK\FlmngrServer\FlmngrServer::flmngrRequest(
        array(
            'dirFiles' => '/var/www/files',
        )
    );
```

In frameworks like [Laravel](https://n1ed.com/docs/file-manager/laravel), [Symfony](https://n1ed.com/docs/file-manager/symfony), Yii, CodeIgniter, etc., you can create a new method in some controller calling the same method. A URL mapped to this method will be the entry point of all Flmngr requests.

## Update

Later, this package will be automatically updated among all your packages each time you call `composer update`. If you wish to update only the backend of Flmngr, call:

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

## 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 full URL of `flmngr.php`.
- **Files URL** is the full URL of `dirFiles` (not a directory path!).

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

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

> **Note:** Alternatively, you can pass these parameters as [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 Flmngr will add to any file when inserting it into your content (or returning it into a 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/my-project/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/my-project/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)
