2017 © Pedro Peláez
 

library laravel-cksource

CKEditor & CKFinder integrated for Laravel framework.

image

amiirarsallan/laravel-cksource

CKEditor & CKFinder integrated for Laravel framework.

  • Friday, March 30, 2018
  • by amiirarsallan
  • Repository
  • 0 Watchers
  • 0 Stars
  • 15 Installations
  • CSS
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel CKSource (CKEditor & CKFinder) package

This package provides two products of CKSource, called CKEditor thats one of the world best WYSIWYG editors and CKFinder that creates a very easy, safe file upload and management trought the CKEditor and by itself, for Laravel 5.4+ framework., (*1)

Installation

Require package via composer

composer require amiirarsallan/laravel-cksource

Publishing assets

Run this artisan command inside your main laravel project directory, (*2)

php artisan vendor:publish --tag=laravel-cksource

Note

By running this command you'll have a new directory named files inside your laravel project storage directory, this directory will used for CKFinder uploads path., (*3)

Configurating CKFinder

Open CKFinder config.php file available in this path /public/vendor/amiirarsalan/laravel-cksource/src/assets/ckfinder/ in line 29 Replace YOUR_APP_KEY with your own application key stores in .env file of project, without base64: flag, (*4)

$config['authentication'] = function () {
    $APP_KEY = "YOUR_APP_KEY";

Then, we have the most important part for authentication,, (*5)

1- Set Cookie to authenticate user in login, (*6)

In your user login process you have to redirect user after successful login attempt, so by that way you have to redirect with a cookie set, with command withCookie() and the cookie should be named allowCkfinder with true value, and the code snippet should be something like this, (*7)

//Attempt to login user
if (!auth()->attempt($credentials, request('remember'))) {
    return back()->withErrors([
        'message' => 'Please check your credentials.'
    ]);
}

//Redirect to panel
return redirect()->withCookie(cookie()->forever('allowCkfinder', true));

2- Unset Cookie while user logout, (*8)

To make the process works completely, you have to remove the cookie while user logout, and the snippet should be something like this, (*9)

//Log out the user
auth()->logout();

//Redirect to index
return redirect()->withCookie(cookie()->forget('allowCkfinder'));

Updating

Update composer at first level

composer update amiirarsallan/laravel-cksource

Publish new assets with flag --force to overwrite existing files

php artisan vendor:publish --tag=laravel-cksource --force

Usage

Package generates new custom Laravel Blade syntax,, (*10)

@ckeditor( [arg1](textarea name), [arg2](textarea id), [arg3]{optional}(ckeditor custom configs)  )

This syntax creates a new <textarea> HTML element in your view and its name and id attributes will populate trough first two arguments of @ckeditor syntax., (*11)

3rd argument will be the CKFinder custom configurations., (*12)

NOTE CKFinder and browse server button of CKEditor will be available while Auth::check() return true result, so it means when a user authenticated then CKFinder will be enabled., (*13)

Notes

To disable CKFinder activation via Laravel Auth, just go trough this path in your laravel project, (*14)

/public/vendor/amiirarsallan/laravel-cksource/src/assets/ckfinder/

and open config.php file inside this directory, then remove the whole code $config['authentication'] in line 28 and just write, (*15)

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

Invalid Request | Interface 'CKSource\CKFinder\Request\Transformer\TransformerInterface' not found

This error usually occures while you hit Browse Server button from CKEditor dialog, to fix this you have to Open CKFinder config /public/vendor/amiirarsalan/laravel-cksource/src/assets/ckfinder/config.php and comment line 13, 14, (*16)

// Production
// error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
// ini_set('display_errors', 0);

and uncomment line 17, 18, (*17)

// Development
error_reporting(E_ALL);
ini_set('display_errors', 1);

Save the config file and try re-open the Browse Server dialog from CKEditor, If the error shown on screen display something like this,, (*18)

Fatal error: Interface 'CKSource\CKFinder\Request\Transformer\TransformerInterface' not found in X:\X\public\vendor\amiirarsallan\laravel-cksource\src\assets\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\Request\Transformer\JsonTransformer.php on line 24, (*19)

Go to the path, (*20)

X:\X\public\vendor\amiirarsallan\laravel-cksource\src\assets\ckfinder\core\connector\php\vendor\cksource\ckfinder\src\CKSource\CKFinder\Request\Transformer\JsonTransformer.php, (*21)

and open JsonTransformer.php file, on line 24, change the code like this, (*22)

class JsonTransformer //implements TransformerInterface
{

This will fix the Browse Server dialog., (*23)

The Versions

30/03 2018

dev-master

9999999-dev

CKEditor & CKFinder integrated for Laravel framework.

  Sources   Download

MIT

The Requires

 

laravel ckeditor ckfinder laravel ckeditor laravel ckfinder laravel html editor