PHPackages                             chialab/cakephp-object-storage - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. chialab/cakephp-object-storage

ActiveCakephp-plugin[File &amp; Storage](/categories/file-storage)

chialab/cakephp-object-storage
==============================

Object storage plugin for CakePHP applications

v0.1.4(2y ago)087[1 PRs](https://github.com/chialab/cakephp-object-storage/pulls)MITPHPPHP &gt;=8.1

Since May 8Pushed 2y agoCompare

[ Source](https://github.com/chialab/cakephp-object-storage)[ Packagist](https://packagist.org/packages/chialab/cakephp-object-storage)[ RSS](/packages/chialab-cakephp-object-storage/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (11)Versions (8)Used By (0)

Object storage plugin for CakePHP
=================================

[](#object-storage-plugin-for-cakephp)

This plugin offers an implementation of an object storage for [CakePHP](https://cakephp.org) applications.

Features
--------

[](#features)

This plugin provides:

- migration for creating the `files` table
- entity and table classes for `Files` model
- REST controller
- default routing
- service provider for the storage service using CakePHP's [service container](https://book.cakephp.org/4/en/development/dependency-injection.html)
- event listener to inject the service container in table instance on initialization
- modeless forms to handle file operations
- shell command to cleanup incomplete multipart uploads

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

[](#installation)

You can install this plugin using [composer](https://getcomposer.org):

```
composer install chialab/cakephp-object-storage
```

To use AWS S3 as a backend storage, the SDK is also needed:

```
composer install aws/aws-sdk-php
```

Usage
-----

[](#usage)

Add the plugin in your `Application.php` bootstrap:

```
    public function bootstrap(): void
    {
        // ...

        $this->addPlugin('Chialab/CakeObjectStorage');

        // ...
    }
```

Run the migration to create the `files` table:

```
bin/cake migrations migrate --plugin Chialab/CakeObjectStorage
```

Add the configuration for the backend storage in your `app.php`:

```
    // ...

    'Storage' => [
        'className' => FilesystemAdapter::class,
        'args' => [
            WWW_ROOT . 'files' . DS,
            TMP . 'incomplete-uploads' . DS,
            '/files/',
            0007,
        ],
    ],

    // ...
```

See [`chialab/php-object-storage`](https://github.com/chialab/php-object-storage) library's README for more information on the adapters.

### Disable routing

[](#disable-routing)

Use `['routes' => false]` when adding the plugin to implement your own routes. You can still use `Chialab/CakeObjectStorage.Files` as controller if you only want to change the paths, or implement your own controller.

### Disable event listener

[](#disable-event-listener)

Use `['bootstrap' => false]` when adding the plugin to disable automatically adding the event listener. If you're using the plugin's `FilesTable`, you are required to set the DI container to its instances, or implement your own service handling.

### Disable service provider

[](#disable-service-provider)

Use `['services' => false]` when adding the plugin to disable automatically adding the storage service provider. You are required to provide a `MultipartUploadInterface` implementation to `FilesTable` instances, or implement your own service handling.

Upload
------

[](#upload)

See `File::getMultipartChunkSize()` for the threshold between small file and multipart upload.

### Create file entity

[](#create-file-entity)

The default controller accepts a request like the following:

```
POST /files

{
    "filename": "example.jpg",
    "mime_type": "image/jpg",
    "size": 20480 // 20 MiB
}

```

The response is like the following:

```
{
    "file": {
        "filename": "example.jpg",
        "mime_type": "image/jpg",
        "size": 20480, // 20 MiB
        "created": "2023-05-08T15:58:27+00:00",
        "id": "076e11d0-4ba6-4680-8796-ee232eeca090",
        "is_multipart": true,
        "is_finalized": false,
        "url": null
    },
    "chunk_size": 10485760, // 10 MiB, present only if `is_multipart === true`
    "upload": "http://ossma.localhost/api/v1/files/076e11d0-4ba6-4680-8796-ee232eeca090/upload",
    "finalize": "http://ossma.localhost/api/v1/files/076e11d0-4ba6-4680-8796-ee232eeca090/finalize" // present only if `is_multipart === true`
}
```

The file entity in the response has a property `is_multipart` to let the client know if a multipart upload is required. In this case, the response will also contain a `chunk_size` property with the maximum file part size, and a `finalize` URL to call after all parts have been uploaded.

### Upload file

[](#upload-file)

To upload the file, make a request like the following with the file as body:

```
POST /files/{file_id}/upload

```

### Multipart upload

[](#multipart-upload)

To upload a part of a multipart upload, add the `part` query parameter to the request:

```
POST /files/{file_id}/upload?part=1

```

The parameter is an incremental number starting from 1, which represent the "index" of the part currently uploading.

The endpoint will respond with a hash of the uploaded part that needs to be stored to finalize the upload later:

```
{
    "part": "1",
    "hash": "86507bea6d332c2814df1d244abdd3696169607f5f42ac3f6782dd69883f6b0d"
}
```

To finalize the upload:

```
POST /files/{file_id}/finalize

{
    "hashes": [
        { "part": 1, hash: "86507bea6d332c2814df1d244abdd3696169607f5f42ac3f6782dd69883f6b0d" },
        { "part": 2, hash: "df7c1db235bac334dab81d0a25824055bdb738bf54fd2857698d4a9fd88af2c6" },
    ]
}

```

To abort a multipart upload:

```
DELETE /files/{file_id}/abort

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.3% 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 ~5 days

Total

5

Last Release

1083d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/00305fda0159b5d71f7bd6848ae7d3f7ac27d0179d79d58c4847848c8bd673e0?d=identicon)[fquffio](/maintainers/fquffio)

![](https://www.gravatar.com/avatar/36a1b89a62185411675b209cd97652abd29a4e98bd3e68cb5e402bee9ae883d6?d=identicon)[le0m](/maintainers/le0m)

![](https://www.gravatar.com/avatar/4bb153a6227d7c6cd124f94c414e63d68cb1b1def8a6fdac75770c495cb8713d?d=identicon)[edoardocavazza](/maintainers/edoardocavazza)

---

Top Contributors

[![le0m](https://avatars.githubusercontent.com/u/10656716?v=4)](https://github.com/le0m "le0m (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/chialab-cakephp-object-storage/health.svg)

```
[![Health](https://phpackages.com/badges/chialab-cakephp-object-storage/health.svg)](https://phpackages.com/packages/chialab-cakephp-object-storage)
```

###  Alternatives

[sylius/resource-bundle

Resource component for Sylius.

23410.2M173](/packages/sylius-resource-bundle)[puli/repository

A filesystem-like repository for storing arbitrary resources.

44287.6k32](/packages/puli-repository)[wyrihaximus/fly-pie

Flysystem integration plugin for CakePHP 5

38297.8k](/packages/wyrihaximus-fly-pie)[samsonasik/array-lookup

A fast lookup library that help you verify and search array and Traversable data

2863.0k2](/packages/samsonasik-array-lookup)[dereuromark/cakephp-file-storage

This plugin is giving you the possibility to store files in virtually any kind of storage backend. This plugin is wrapping the Gaufrette library (https://github.com/KnpLabs/Gaufrette) library in a CakePHP fashion and provides a simple way to use the storage adapters through the StorageManager class.

104.1k](/packages/dereuromark-cakephp-file-storage)

PHPackages © 2026

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