Skip to content

Laravel framework

pavel edited this page Mar 17, 2018 · 2 revisions

PHP connector for RichFilemanager contains dependency packages which are used in Laravel. This means possible collisions, despite the fact that the guide below have been successfully tested.

The steps below was applied to Laravel 5.6 and will work presumably for Laravel >= 5.4

  1. Install Laravel, see detail at the official page.

  2. Clone the main RichFilemanager package into the public folder of your Laravel application.

  3. Perform the initial client-side configuration setup of the cloned RichFilemanager package instance.

  4. Open composer.json file of your Laravel application and append the following line into the require section:

{
  "require": {
    "servocoder/richfilemanager-php": "^1.2.3"
  }
}

Don't forget to update composer to install new package.

  1. Open the routes/api.php file and add a new route. You can find that the content of this route in almost the same as PHP connector entry script with some adjustments:
Route::match(['get', 'post'], '/filemanager', function (Request $request) {
    require_once base_path('public/RichFilemanager/connectors/php/events.php');

    function fm_authenticate()
    {
        // Customize this code as desired.
        return true;
    }

    function fm_has_read_permission($filepath)
    {
        // Customize this code as desired.
        return true;
    }

    function fm_has_write_permission($filepath)
    {
        // Customize this code as desired.
        return true;
    }


    $config = [];

    // example to override the default config
    //$config = [
    //    'security' => [
    //        'readOnly' => true,
    //        'extensions' => [
    //            'policy' => 'ALLOW_LIST',
    //            'restrictions' => [
    //                'jpg',
    //                'jpe',
    //                'jpeg',
    //                'gif',
    //                'png',
    //            ],
    //        ],
    //    ],
    //];


    $app = new \RFM\Application();

    // uncomment to use events
    $app->registerEventsListeners();

    $local = new \RFM\Repository\Local\Storage($config);

    // example to setup files root folder
    $path = app()->basePath() . '/public/filemanager';
    $local->setRoot($path, true, false);

    $app->setStorage($local);

    // set application API
    $app->api = new RFM\Api\LocalApi();

    $app->run();
});
  1. Now you have to configure RichFilemanager connector endpoint to the newly created route. In the example at step 5 the route is /filemanager, but since it's in the "api" group it will turn into the /api/filemanager.

    Open the filemanager.config.json file of the cloned RichFilemanager package instance and set the api.connectorUrl configuration option like this:

{
    "connectorUrl": "http://your.host/api/filemanager"
}
  1. Open http://your.host//RichFilemanager/index.html
Clone this wiki locally