Skip to content
CKFinder 3 package for Laravel
Branch: master
Clone or download
Latest commit 88d1677 Nov 27, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
_connector Basic package stub. Jul 7, 2018
public/ckfinder
src Update to v3.4.5 Nov 27, 2018
views Some cleanup. Jul 8, 2018
.gitignore ckfinder:download command Jul 7, 2018
LICENSE.md
README.md Update README.md Aug 7, 2018
composer.json

README.md

CKFinder 3 Package for Laravel 5.5+ Tweet

Laravel version License Packagist Packagist Join newsletter Follow twitter

This repository contains the CKFinder 3 Package for Laravel 5.5+.

Installation

  1. Add a Composer dependency and install the package.

    composer require ckfinder/ckfinder-laravel-package
  2. Run the command to download the CKFinder code.

    After installing the Laravel package you need to download CKFinder code. It is not shipped with the package due to different license terms. To install it, run the following artisan command:

    php artisan ckfinder:download

    It will download the required code and place it inside an appropriate directory of the package (vendor/ckfinder/ckfinder-laravel-package/).

  3. Publish the CKFinder connector configuration and assets.

    php artisan vendor:publish --tag=ckfinder

    This will publish CKFinder assets to public/js/ckfinder, and the CKFinder connector configuration to config/ckfinder.php.

  4. Create a directory for CKFinder files and allow for write access to it. By default CKFinder expects the files to be placed in public/userfiles (this can be altered in the configuration).

    mkdir -m 777 public/userfiles

NOTE: Since usually setting permissions to 0777 is insecure, it is advisable to change the group ownership of the directory to the same user as Apache and add group write permissions instead. Please contact your system administrator in case of any doubts.

At this point you should see the connector JSON response after navigating to the <APP BASE URL>/ckfinder/connector?command=Init address. Authentication for CKFinder is not configured yet, so you will see an error response saying that CKFinder is not enabled.

Configuring Authentication

CKFinder connector authentication is managed by the authentication option in the connector configuration file (config/ckfinder.php). It expects a PHP callable value that after calling would return a Boolean value to decide if the user should have access to CKFinder. As you can see, the default service implementation is not complete and simply returns false.

A basic implementation that returns true from the authentication callable (which is obviously not secure) can look like below:

// config/ckfinder.php

$config['authentication'] = function () {
    return true;
};

Please have a look at the CKFinder for PHP connector documentation to find out more about this option.

Configuration Options

The CKFinder connector configuration is taken from the config/ckfinder.php file.

To find out more about possible connector configuration options please refer to the CKFinder for PHP connector documentation.

Usage

The package code contains a couple of usage examples that you may find useful. To enable them, uncomment the ckfinder_examples route in vendor/ckfinder/ckfinder-laravel-package/src/routes.php:

// vendor/ckfinder/ckfinder-laravel-package/src/routes.php

Route::any('/ckfinder/examples/{example?}', 'CKSource\CKFinderBridge\Controller\CKFinderController@examplesAction')
    ->name('ckfinder_examples');

After that you can navigate to the <APP BASE URL>/ckfinder/examples path and have a look at the list of available examples. To find out about the code behind them, check the views/samples directory in the package (vendor/ckfinder/ckfinder-laravel-package/views/samples/).

Including the Main CKFinder JavaScript File in Templates

To be able to use CKFinder on a web page you have to include the main CKFinder JavaScript file. The preferred way to do that is to include the CKFinder setup template, as shown below:

@include('ckfinder::setup')

The included template renders the required script tags and configures a valid connector path.

<script type="text/javascript" src="/js/ckfinder/ckfinder.js"></script>
<script>CKFinder.config( { connectorPath: '/ckfinder/connector' } );</script>

Useful Links

You can’t perform that action at this time.