pieceofcake2 / filebinder
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
Requires
- php: ^8.1
- composer/installers: ^1.0 || ^2.0
- pieceofcake2/cakephp: ^2.12
Requires (Dev)
- async-aws/simple-s3: ^2.1 || ^3.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^9.6
- pieceofcake2/app: ^2.2
- pieceofcake2/async-aws: ^1.0
- pieceofcake2/aws: ^1.2
- pieceofcake2/phpcs-cakephp2: ^1.1
- pieceofcake2/phpstan-cakephp2: ^1.0
Suggests
- async-aws/simple-s3: Required with pieceofcake2/async-aws for the S3 storage (installs async-aws/s3)
- pieceofcake2/async-aws: S3 storage with AsyncAws; also install async-aws/simple-s3
- pieceofcake2/aws: S3 storage with the AWS SDK for PHP (aws/aws-sdk-php)
Provides
None
Conflicts
None
Replaces
This package is auto-updated.
Last update: 2026-10-22 09:54:14 UTC
README
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.Ringkeeps the uploaded files for a confirmation page, andFilebinder.Labelshows them- Amazon S3 through pieceofcake2/async-aws (AsyncAws) or pieceofcake2/aws (AWS SDK for PHP)
Documentation
- Website: https://pieceofcake2.github.io/filebinder/ (日本語: https://pieceofcake2.github.io/filebinder/ja/)
- Markdown: docs/README.md (日本語: docs/ja/README.md) (for AI tools and offline reading)
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.

