cakephp / datasource
Provides connection managing and traits for Entities and Queries that can be reused for different datastores
Requires
- php: >=8.1
- cakephp/core: ^5.1
- psr/simple-cache: ^2.0 || ^3.0
Requires (Dev)
- cakephp/cache: ^5.1
- cakephp/collection: ^5.1
- cakephp/utility: ^5.1
Suggests
- cakephp/cache: If you decide to use Query caching.
- cakephp/collection: If you decide to use ResultSetInterface.
- cakephp/utility: If you decide to use EntityTrait.
- dev-master
- 5.x-dev
- 5.1.2
- 5.1.1
- 5.1.0
- 5.1.0-RC2
- 5.1.0-RC1
- 5.0.11
- 5.0.10
- 5.0.9
- 5.0.8
- 5.0.7
- 5.0.6
- 5.0.5
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.0
- 5.0.0-RC2
- 5.0.0-RC1
- 5.0.0-beta2
- 5.0.0-beta1
- 4.x-dev
- 4.5.8
- 4.5.7
- 4.5.6
- 4.5.5
- 4.5.4
- 4.5.3
- 4.5.2
- 4.5.1
- 4.5.0
- 4.5.0-RC1
- 4.4.17
- 4.4.16
- 4.4.15
- 4.4.14
- 4.4.13
- 4.4.12
- 4.4.11
- 4.4.10
- 4.4.9
- 4.4.8
- 4.4.7
- 4.4.6
- 4.4.5
- 4.4.4
- 4.4.3
- 4.4.2
- 4.4.1
- 4.4.0
- 4.4.0-RC2
- 4.4.0-RC1
- 4.3.x-dev
- 4.3.11
- 4.3.10
- 4.3.9
- 4.3.8
- 4.3.7
- 4.3.6
- 4.3.5
- 4.3.4
- 4.3.3
- 4.3.2
- 4.3.1
- 4.3.0
- 4.3.0-RC4
- 4.3.0-RC3
- 4.3.0-RC2
- 4.3.0-RC1
- 4.2.x-dev
- 4.2.12
- 4.2.11
- 4.2.10
- 4.2.9
- 4.2.8
- 4.2.7
- 4.2.6
- 4.2.5
- 4.2.4
- 4.2.3
- 4.2.2
- 4.2.1
- 4.2.0
- 4.2.0-RC1
- 4.2.0-beta1
- 4.1.7
- 4.1.6
- 4.1.5
- 4.1.4
- 4.1.3
- 4.1.2
- 4.1.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1
- 3.4.x-dev
- 3.4.14
- 3.4.13
- 3.4.12
- 3.4.11
- 3.4.10
- 3.4.9
- 3.4.8
- 3.4.7
- 3.4.6
- 3.4.5
- 3.4.4
- 3.4.3
- 3.4.2
- 3.4.1
- 3.4.0
- 3.4.0-RC4
- 3.4.0-RC3
- 3.4.0-RC2
- 3.4.0-RC1
- 3.4.0-beta4
- 3.4.0-beta3
- 3.4.0-beta2
- 3.4.0-beta1
- 3.3.16
- 3.3.15
- 3.3.14
- 3.3.13
- 3.3.12
- 3.3.11
- 3.3.10
- 3.3.9
- 3.3.8
- 3.3.7
- 3.3.6
- 3.3.5
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.3.0-RC1
- 3.3.0-beta3
- 3.3.0-beta2
- 3.3.0-beta
- 3.2.x-dev
- 3.2.14
- 3.2.13
- 3.2.12
- 3.2.11
- 3.2.10
- 3.2.9
- 3.2.8
- 3.2.7
- 3.2.6
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.2.0-RC1
- 3.1.x-dev
- 3.1.13
- 3.1.10
- 3.1.9
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.1.0-RC1
- 3.1.0-beta2
- 3.1.0-beta
- 3.0.x-dev
- 3.0.18
- 3.0.15
- 3.0.13
- 3.0.12
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 3.0.0-RC2
- 3.0.0-RC1
- 3.0.0-beta3
- dev-5.next
- dev-4.next
- dev-datasouce
- dev-3.next
- dev-3-1
- dev-3-0
This package is auto-updated.
Last update: 2024-11-25 03:35:21 UTC
README
CakePHP Datasource Library
This library contains interfaces for implementing Repositories and Entities using any data source, a class for managing connections to datasources and traits to help you quickly implement the interfaces provided by this package.
Repositories
A repository is a class capable of interfacing with a data source using operations such as
find
, save
and delete
by using intermediate query objects for expressing commands to
the data store and returning Entities as the single result unit of such system.
In the case of a Relational database, a Repository would be a Table
, which can be return single
or multiple Entity
objects by using a Query
.
This library exposes the following interfaces for creating a system that implements the repository pattern and is compatible with the CakePHP framework:
RepositoryInterface
- Describes the methods for a base repository class.EntityInterface
- Describes the methods for a single result object.ResultSetInterface
- Represents the idea of a collection of Entities as a result of a query.
Additionally, this package provides a few traits and classes you can use in your own implementations:
EntityTrait
- Contains the default implementation for theEntityInterface
.QueryTrait
- Exposes the methods for creating a query object capable of returning decoratable collections.ResultSetDecorator
- Decorates any traversable object, so it complies withResultSetInterface
.
Connections
This library contains a couple of utility classes meant to create and manage connection objects. Connections are typically used in repositories for interfacing with the actual data source system.
The ConnectionManager
class acts as a registry to access database connections
your application has. It provides a place that other objects can get references
to existing connections. Creating connections with the ConnectionManager
is
easy:
use Cake\Datasource\ConnectionManager; ConnectionManager::config('connection-one', [ 'className' => 'MyApp\Connections\CustomConnection', 'param1' => 'value', 'param2' => 'another value' ]); ConnectionManager::config('connection-two', [ 'className' => 'MyApp\Connections\CustomConnection', 'param1' => 'different value', 'param2' => 'another value' ]);
When requested, the ConnectionManager
will instantiate
MyApp\Connections\CustomConnection
by passing param1
and param2
inside an
array as the first argument of the constructor.
Once configured connections can be fetched using ConnectionManager::get()
.
This method will construct and load a connection if it has not been built
before, or return the existing known connection:
use Cake\Datasource\ConnectionManager; $conn = ConnectionManager::get('master');
It is also possible to store connection objects by passing the instance directly to the manager:
use Cake\Datasource\ConnectionManager; $conn = ConnectionManager::config('other', $connectionInstance);
Documentation
Please make sure you check the official API documentation