Download the PHP package tobento/service-repository-storage without Composer
On this page you can find all versions of the php package tobento/service-repository-storage. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tobento/service-repository-storage
More information about tobento/service-repository-storage
Files in tobento/service-repository-storage
Package service-repository-storage
Short Description Storage repository implementation.
License MIT
Homepage https://www.tobento.ch
Informations about the package service-repository-storage
Repository Storage Service
Storage repository implementation.
Table of Contents
- Getting started
- Requirements
- Highlights
- Documentation
- Storage Repository
- Storage Read Repository
- Storage Write Repository
- Where Parameters
- Storage Entity Factory
- Repository With Columns
- Columns Common Methods
- Type
- Read
- Write
- Force Writing
- Storable
- Columns
- Boolean
- Datetime
- Float
- Id
- Integer
- Json
- Text
- Translatable
- Translations
- Where Parameters Translations
- Write Translations
- Migration
- Credits
Getting started
Add the latest version of the repository storage service project running this command.
Requirements
- PHP 8.0 or greater
Highlights
- Framework-agnostic, will work with any project
- Decoupled design
Documentation
Check out the Storage Service - Storages for its available storages.
Check out the Repository Service for its documentation.
Storage Repository
To create a storage repository simply extend the :
You may also check out the Repository With Columns section to create the repository using columns.
By default, the read and write methods will return the following types depending on the method called:
You may specify a custom Storage Entity Factory to return custom entities by the parameter.
Storage Read Repository
To create a storage read repository simply extend the :
You may also check out the Repository With Columns section to create the repository using columns.
By default, the find methods will return the following types depending on the method called:
You may specify a custom Storage Entity Factory to return custom entities by the parameter.
findById
You may check out the Storage Service - ItemInterface for its documentation.
findByIds
You may check out the Storage Service - ItemsInterface for its documentation.
You may check out the Storage Service - ItemInterface for its documentation.
findOne
You may check out the Where Parameters for its supported parameters.
You may check out the Storage Service - ItemInterface for its documentation.
findAll
You may check out the Where Parameters for its supported parameters.
You may check out the Storage Service - ItemsInterface for its documentation.
You may check out the Storage Service - ItemInterface for its documentation.
Storage Write Repository
To create a storage write repository simply extend the :
You may also check out the Repository With Columns section to create the repository using columns.
By default, the methods will return the following types depending on the method called:
You may specify a custom Storage Entity Factory to return custom entities by the parameter.
create
You may check out the Storage Service - ItemInterface for its documentation.
updateById
This method will throw a exception if the storage table has no primary key specified or the entity to update does not exist.
You may check out the Storage Service - ItemInterface for its documentation.
update
You may check out the Where Parameters for its supported parameters.
You may check out the Storage Service - ItemsInterface for its documentation.
You may check out the Storage Service - ItemInterface for its documentation.
deleteById
This method will throw a exception if the storage table has no primary key specified or the entity to delete does not exist.
You may check out the Storage Service - ItemInterface for its documentation.
delete
You may check out the Where Parameters for its supported parameters.
You may check out the Storage Service - ItemsInterface for its documentation.
You may check out the Storage Service - ItemInterface for its documentation.
Where Parameters
The following where clauses are supported (for all read/write methods with where parameter):
Or Clauses
To create or clauses add the keyword before any operator:
Storage Entity Factory
You may create a custom entity factory to return custom entities by the Storage Write Repository.
To create a custom entity factory simply extend the and adjust the method:
Repository With Columns
Creating a storage repository with columns has the following advantages:
- casts values to primitive types on reading and writing
- specify a reader and writer to handle casting
- create database migration based on columns
You may prefer to specify the columns on its class instead by using the method:
Columns Common Methods
Type
The parameters set on the method are used for Migration purpose only.
Check out the Service Database - Column Factory method for more detail.
Check out the Service Database - Index Factory method for more detail.
Read
You may use the read method to specify a reader (callable). The reader will automatically be called by the repository when attempting to retrieve the value.
The value is casted to its column type before being passed to the reader!
Write
You may use the write method to specify a writer (callable). The writer will automatically be called by the repository when attempting to write the value. The writer will only be called if the attribute exists on any write methods. If you you want the writer to be always called, check out the Force Writing section.
The value is casted to its column type before being passed to the writer!
Force Writing
You may use the method to specify if you want to force writing, meaning the writer gets always called even if the attribute was not passed on any write methods.
Storable
Columns
Boolean
Datetime
read
You may use the read method to cast your value. Without specifying a read method, the value will be casted to a string only.
Check out the Dater Service - DateFormatter for more detail.
write
You may use the write method to cast your value. Without specifying a write method, the value will be casted to the following formats:
- datetime type:
- date type:
- time type:
- timestamp type: timestamp string
Check out the Dater Service - DateFormatter for more detail.
autoCreate
Use the method if you want the date to be automatically created if no value was passed by any write methods.
autoUpdate
Use the method if you want the date to be automatically updated if no value was passed by any write methods.
Float
Id
Integer
Json
Text
Translatable
Read Attribute
After reading, a or is being created depending on its column subtype or .
Translations
Confiure the locales for the repository:
Where Parameters Translations
Where clauses for translation columns (for all read/write methods with where parameter):
Write Translations
create
update
Migration
If you have set up your Repository With Columns, you might use the migration and to create your database migration from the columns defined.
First, you will need to install:
Example of migration class
You may check out the Migration Service for more detail.
Credits
- Tobias Strub
- All Contributors
All versions of service-repository-storage with dependencies
tobento/service-repository Version ^1.0
tobento/service-storage Version ^1.2.1
tobento/service-iterable Version ^1.0
tobento/service-collection Version ^1.0.5
tobento/service-support Version ^1.0
tobento/service-dater Version ^1.0.1