libriciel / cakephp-odata
Provides OData integration for CakePHP with automatic field exposure, dynamic metadata, and RESTful request handling.
dev-master
2025-06-05 08:46 UTC
Requires
- php: ^8.3
- ext-dom: *
- ext-pdo: *
- ext-xml: *
- ext-xsl: *
- cakephp/cakephp: ~5.0
- libriciel/php-odata: dev-master
Requires (Dev)
- phpunit/phpunit: ^12.1
- squizlabs/php_codesniffer: ^3.13
This package is auto-updated.
Last update: 2025-06-05 08:46:46 UTC
README
cakephp-odata is a CakePHP plugin that enables exposing your models via the OData protocol.
It provides:
- An
ODataBehavior
to declare which fields and associations are exposed - Automatic detection of entity structure based on the schema
- A
$metadata
endpoint - A component to handle RESTful OData queries
Installation
Install the plugin with Composer:
composer require libriciel/cakephp-odata
Load the plugin in Application.php
(if not auto-loaded):
$this->addPlugin('CakeOData');
Usage
Enable behavior
In your table class:
$this->addBehavior('OData', [
'blackList' => ['password', 'secret_token']
]);
Fetch formatted output
$odata = $this->fetchTable('Users')->toODataValue($entity);
Access metadata
Visit: /odata/$metadata
It returns the full EDMX XML metadata for all models using ODataBehavior
.
Query records
GET /odata/Users?$top=10&$skip=20
Testing
composer install
vendor/bin/phpunit
License
AGPL-3.0 © Libriciel SCOP