Search by

pieceofcake2 / filebinder

ttsuru

Simple file attachment plugin for CakePHP 2: local files, database and Amazon S3 storage

Package info

github.com/pieceofcake2/filebinder

Type:cakephp-plugin

pkg:composer/pieceofcake2/filebinder

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

2.x-dev 2026-10-22 09:50 UTC

This package is auto-updated.

Last update: 2026-10-22 09:54:14 UTC


README

Filebinder

GitHub License Packagist Version PHP CakePHP PHPStan CI Codecov

Simple file attachment for the models of pieceofcake2/cakephp applications. List the file fields of a model in $bindFields, and the Filebinder.Bindable behavior saves the uploaded files.

  • Simple settings: no column for the files in the tables of your models
  • Several file fields per model, in any number of models
  • Files saved in a local directory, in the database and/or on Amazon S3, and restored from the database or S3 when the local file is missing
  • Validation rules for the extension, the content type and the size of the files
  • Filebinder.Ring keeps the uploaded files for a confirmation page, and Filebinder.Label shows them
  • Amazon S3 through pieceofcake2/async-aws (AsyncAws) or pieceofcake2/aws (AWS SDK for PHP)

The attachment table and the path of a saved file

Documentation

It covers the database table, the settings, the storage, Amazon S3, the validation rules, the Ring component, the Label helper and the upgrade from fusic/filebinder.

The Markdown documentation is also included in the Composer package, in the plugin's directory: plugins/Filebinder/docs/README.md (the location depends on your installer-paths).

Requirements

  • PHP 8.1+
  • pieceofcake2/cakephp 2.12+
  • For the S3 storage: pieceofcake2/async-aws with async-aws/simple-s3, or pieceofcake2/aws

Installation

composer require pieceofcake2/filebinder

Load the plugin in config/bootstrap.php (legacy layout: app/Config/bootstrap.php):

CakePlugin::load('Filebinder');

Then create the attachments table. See Installation and Database.

Usage

class Post extends AppModel
{
    public $actsAs = ['Filebinder.Bindable'];

    public $bindFields = [
        ['field' => 'image', 'filePath' => WWW_ROOT . 'files' . DS],
    ];
}
class PostsController extends AppController
{
    public $components = ['Session', 'Filebinder.Ring'];

    public function add()
    {
        if ($this->request->is('post')) {
            $this->Ring->bindUp();
            if ($this->Post->save($this->request->data)) {
                return $this->redirect(['action' => 'index']);
            }
        }
    }
}
echo $this->Label->image($post['Post']['image']);

See Quick Start and Amazon S3.

Contributing

See the contribution guidelines.

Origin

This package is a maintained fork of fusic/filebinder (2.0 branch, fusic/filebinder on Packagist), originally by Fusic Co., Ltd. It is maintained for CakePHP 2 on modern PHP by pieceofcake2. Changes from the original are listed in the CHANGELOG and the commit history since the fork.

License

MIT License. See LICENSE.