PHPackages                             metra/metra-ckfinder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. metra/metra-ckfinder

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

metra/metra-ckfinder
====================

CKFinder bundle for Symfony Metra

3.5.3(4y ago)03MITPHPPHP &gt;=5.6.0

Since Oct 12Pushed 3y agoCompare

[ Source](https://github.com/metra-nimes/ckfinder-symfony-bundle)[ Packagist](https://packagist.org/packages/metra/metra-ckfinder)[ RSS](/packages/metra-metra-ckfinder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (14)Used By (0)

CKFinder 3 Bundle for Symfony
=============================

[](#ckfinder-3-bundle-for-symfony)

This repository contains the CKFinder 3 bundle for Symfony 3+. If you're looking for bundle for Symfony 2, please refer [here](https://github.com/ckfinder/ckfinder-symfony2-bundle).

Installation
------------

[](#installation)

1. Add Composer dependency and install the bundle.

    ```
    composer require ckfinder/ckfinder-symfony-bundle
    ```
2. Enable the bundle in `AppKernel.php`.

    **Note:** This step is required only for Symfony 3. If you use Symfony 4+ the bundle will be registered automatically.

    ```
    // app/AppKernel.php

    public function registerBundles()
    {
    	$bundles = [
    		// ...
    		new CKSource\Bundle\CKFinderBundle\CKSourceCKFinderBundle(),
    	];
    }
    ```
3. Run the command to download the CKFinder distribution package.

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

    ```
    php bin/console ckfinder:download
    ```

    It will download the code and place it in the `Resource/public` directory of the bundle. After that you may also want to install assets, so the public directory will be updated with CKFinder code.

    ```
    php bin/console assets:install
    ```
4. Enable bundle routing.

    **Symfony 3**

    Enable bundle routes in `app/config/routing.yml`:

    ```
    # app/config/routing.yml

    ckfinder_connector:
        resource: "@CKSourceCKFinderBundle/Resources/config/routing.yml"
        prefix:   /
    ```

    **Symfony 4+**

    Create `config/routes/ckfinder.yml` with following contents:

    ```
    # config/routes/ckfinder.yml

    ckfinder_connector:
        resource: "@CKSourceCKFinderBundle/Resources/config/routing.yml"
        prefix:   /
    ```
5. Create a directory for CKFinder files and allow for write access to it. By default CKFinder expects it to be placed in `/userfiles` (this can be altered in configuration).

    **Symfony 3**

    ```
    mkdir -m 777 web/userfiles
    ```

    **Symfony 4+**

    ```
    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 `/ckfinder/connector?command=Init` route. Authentication for CKFinder is not configured yet, so you will see an error response saying that CKFinder is not enabled.

Configuring Authentication
--------------------------

[](#configuring-authentication)

CKFinder connector authentication is managed by the `ckfinder.connector.auth` service, which by default is defined in the `CKSourceCKFinderBundle\Authentication\Authentication` class. It contains the `authenticate` method that should 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` inside the `authenticate` method, but you can find it useful as a starting stub code.

To configure authentication for the CKFinder connector you need to create a class that implements `CKSource\Bundle\CKFinderBundle\Authentication\AuthenticationInterface`, and point the CKFinder connector to use it.

A basic implementation that returns `true` from the `authenticate` method (which is obviously **not secure**) can look like below:

**Symfony 3**

```
// src/AppBundle/CustomCKFinderAuth/CustomCKFinderAuth.php

namespace AppBundle\CustomCKFinderAuth;

use CKSource\Bundle\CKFinderBundle\Authentication\Authentication as AuthenticationBase;

class CustomCKFinderAuth extends AuthenticationBase
{
    public function authenticate()
    {
        return true;
    }
}
```

**Symfony 4**

```
// src/CustomCKFinderAuth/CustomCKFinderAuth.php

namespace App\CustomCKFinderAuth;

use CKSource\Bundle\CKFinderBundle\Authentication\Authentication as AuthenticationBase;

class CustomCKFinderAuth extends AuthenticationBase
{
    public function authenticate()
    {
        return true;
    }
}
```

You may have noticed that `AuthenticationInterface` extends `ContainerAwareInterface`, so you have access to the service container from the authentication class scope.

When your custom authentication is ready, you need to tell the CKFinder connector to start using it. To do that add the following option to your configuration:

**Symfony 3**

In `app/config/config.yml` file add following configuration:

```
# app/config/config.yml

ckfinder:
    connector:
        authenticationClass: AppBundle\CustomCKFinderAuth\CustomCKFinderAuth
```

**Symfony 4**

Create `config/packages/ckfinder.yml` file:

```
# config/packages/ckfinder.yml

ckfinder:
    connector:
        authenticationClass: App\CustomCKFinderAuth\CustomCKFinderAuth
```

Configuration Options
---------------------

[](#configuration-options)

The default CKFinder connector configuration is taken from the `@CKSourceCKFinder/Resources/config/ckfinder_config.php` file. Thanks to the Symfony configuration merging mechanism there are multiple ways you can overwrite it. The default configuration is provided in form of a regular PHP file, but you can use the format you prefer (YAML, XML) as long as the structure is valid.

The simplest way to overwrite the default configuration is copying the `ckfinder_config.php` file to your application config directory, and then importing it in the main configuration file:

**Symfony 3**

```
# app/config/config.yml

imports:
    ...
    - { resource: ckfinder_config.php }
```

**Symfony 4**

```
# config/packages/ckfinder.yml

imports:
    - { resource: ckfinder_config.php }

...
```

From now all connector configuration options will be taken from copied `ckfinder_config.php`.

Another way to configure CKFinder is to include required options under the `ckfinder` node, directly in your config file.

**Symfony 3**

```
# app/config/config.yml

ckfinder:
    connector:
        licenseName: LICENSE-NAME
        licenseKey: LICENSE-KEY
        authenticationClass: AppBundle\CustomCKFinderAuth\CustomCKFinderAuth

        resourceTypes:
            MyResource:
                name: MyResource
                backend: default
                directory: myResource
```

**Symfony 4**

```
# config/packages/ckfinder.yml

ckfinder:
    connector:
        licenseName: LICENSE-NAME
        licenseKey: LICENSE-KEY
        authenticationClass: AppBundle\CustomCKFinderAuth\CustomCKFinderAuth

        resourceTypes:
            MyResource:
                name: MyResource
                backend: default
                directory: myResource
```

**Note**: All options that are not defined will be taken from the default configuration file.

To find out more about possible connector configuration options please refer to [CKFinder 3 – PHP Connector Documentation](https://ckeditor.com/docs/ckfinder/ckfinder3-php/configuration.html).

The CKFinder bundle provides two extra options:

- `authenticationClass` – the name of the CKFinder authentication service class (defaults to `CKSource\Bundle\CKFinderBundle\Authentication\Authentication`)
- `connectorClass` – the name of the CKFinder connector service class (defaults to `CKSource\CKFinder\CKFinder`)

Usage
-----

[](#usage)

The bundle code contains a few usage examples that you may find useful. To enable them uncomment the `ckfinder_examples`route in `@CKSourceCKFinder/Resources/config/routing.yml`:

```
ckfinder_examples:
    pattern:     /ckfinder/examples/{example}
    defaults: { _controller: CKSource\Bundle\CKFinderBundle\Controller::examplesAction, example: null }
```

After that you can navigate to the `/ckfinder/examples` path and have a look at the list of available examples. To find out about the code behind them, check the `CKFinderController` class (`CKSourceCKFinderBundle::Controller/CKFinderController.php`).

### Including the Main CKFinder JavaScript File in Templates

[](#including-the-main-ckfinder-javascript-file-in-templates)

The preferred way to include `ckfinder.js` in a template is including the CKFinder setup template, like presented below:

```
{% include "@CKSourceCKFinder/setup.html.twig" %}
```

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

```

CKFinder.config( { connectorPath: '/ckfinder/connector' } );
```

### CKFinder File Chooser

[](#ckfinder-file-chooser)

The bundle registers a form field type — `CKFinderFileChooserType` — that allows for easy integration of CKFinder as a file chooser in your forms. After choosing the file in CKFinder the corresponding input field is automaticaly filled with the file URL. You can see a working example under the `/ckfinder/examples/filechooser` path.

The file chooser field is built on top of the regular `text` type, so it inherits all configuration options. It also provides a few custom options:

NameTypeDefault ValueDescription`mode``string``popup`Mode in which CKFinder will be opened after clicking the "Browse" button. Allowed values are `modal` and `popup`.`button_text``string``Browse`The text displayed in the button.`button_attr``array``[]`Attributes for the button element.A simple usage example may look like below:

```
$form = $this->createFormBuilder()
             ->add('file_chooser1', CKFinderFileChooserType::class, [
                 'label' => 'Photo',
                 'button_text' => 'Browse photos',
                 'button_attr' => [
                     'class' => 'my-fancy-class'
                 ]
             ])
             ->getForm();
```

**Note**: To use CKFinder file chooser in your forms you still need to include the main CKFinder JavaScript file in your template (see *Including the main CKFinder JavaScript file in templates*).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 58.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~96 days

Recently: every ~139 days

Total

13

Last Release

1607d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e382901e55aa4d1d7b07bfdbaae425b8a07eec153d3091b6bb1074328b00aa72?d=identicon)[metra-nimes](/maintainers/metra-nimes)

---

Top Contributors

[![zaak](https://avatars.githubusercontent.com/u/803299?v=4)](https://github.com/zaak "zaak (40 commits)")[![metra-nimes](https://avatars.githubusercontent.com/u/28503863?v=4)](https://github.com/metra-nimes "metra-nimes (7 commits)")[![BoShurik](https://avatars.githubusercontent.com/u/1428848?v=4)](https://github.com/BoShurik "BoShurik (6 commits)")[![angelsk](https://avatars.githubusercontent.com/u/606510?v=4)](https://github.com/angelsk "angelsk (5 commits)")[![lukaszcieslakKTR](https://avatars.githubusercontent.com/u/93586433?v=4)](https://github.com/lukaszcieslakKTR "lukaszcieslakKTR (2 commits)")[![IndyDevGuy](https://avatars.githubusercontent.com/u/9091277?v=4)](https://github.com/IndyDevGuy "IndyDevGuy (2 commits)")[![dmitchell9xb](https://avatars.githubusercontent.com/u/149150569?v=4)](https://github.com/dmitchell9xb "dmitchell9xb (1 commits)")[![pwiaderny-cksource](https://avatars.githubusercontent.com/u/24876072?v=4)](https://github.com/pwiaderny-cksource "pwiaderny-cksource (1 commits)")[![Seb33300](https://avatars.githubusercontent.com/u/915273?v=4)](https://github.com/Seb33300 "Seb33300 (1 commits)")[![yemiez](https://avatars.githubusercontent.com/u/24540060?v=4)](https://github.com/yemiez "yemiez (1 commits)")[![ChristopheFerreboeuf](https://avatars.githubusercontent.com/u/10241898?v=4)](https://github.com/ChristopheFerreboeuf "ChristopheFerreboeuf (1 commits)")[![kix](https://avatars.githubusercontent.com/u/345754?v=4)](https://github.com/kix "kix (1 commits)")

### Embed Badge

![Health badge](/badges/metra-metra-ckfinder/health.svg)

```
[![Health](https://phpackages.com/badges/metra-metra-ckfinder/health.svg)](https://phpackages.com/packages/metra-metra-ckfinder)
```

###  Alternatives

[mj/breadcrumb

A simple breadcrumb generator for Laravel 4

116.3k](/packages/mj-breadcrumb)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
