Download the PHP package api-skeletons/laravel-hal-doctrine without Composer
On this page you can find all versions of the php package api-skeletons/laravel-hal-doctrine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download api-skeletons/laravel-hal-doctrine
More information about api-skeletons/laravel-hal-doctrine
Files in api-skeletons/laravel-hal-doctrine
Package laravel-hal-doctrine
Short Description Doctrine Metadata based HAL
License MIT
Informations about the package laravel-hal-doctrine
Laravel HAL Doctrine
This library provides a hydrator for laravel-hal for Doctrine. Instead of manually creating every hydrator for your entities, this library will introspect an entity and generate the HAL for it including links to other entities and collections for one to many relationships and embedding many to one and one to one entities.
A grouped minimal configuration file allows for excluded fields and associations and configures the routes for each entity.
Use
Create a hydrator manager
Extract an entity
will result in a HAL response like
Configuration
A hal-doctrine.php
configuration file is required. Publish the included config to your project:
Doctrine\Laminas\Hydrator\DoctrineObject
The Laminas Hydrator is used by this library to extract data directly from entities. You must add this configuration
to your doctrine.php
configuration file:
Naming Strategy
The default naming strategy uses the Inflector's urlize()
method to change 'associationName' into 'association-name'.
If this is not the way you want to name your relationsihps or routes then create your own naming strategy and assign
it in the config file.
Route naming
When using the routeNamePatterns
to create a route name, the entity name becomes $namingStrategy->route($entityName)
such as api.short-name::fetch
according to the example configuration.
Filtering Collections
For extracted related collections, links will be created with filter options compatible with
ApiSkeletons\Doctrine\QueryBuilder\Filter\Applicator
to filter the collection data to just the extracted entity.
For example
The link to the Album will be filtered where album.artist = 1
. In order to process these URLs in your application,
implement ApiSkeletons\Doctrine\QueryBuilder\Filter\Applicator
in your controller action:
See the documentation for doctrine-querybuilder-filter for more detailed examples.
Multiple Object Managers
To configure a hydrator for other than the default
configuration section, extend the Doctrine Hydrator
Then in your hal-doctrine.php
configuration file, create a new section titled secondary
and set the
entityManager
to your second Entity Manager.
All versions of laravel-hal-doctrine with dependencies
laravel-doctrine/orm Version ^1.7
api-skeletons/laravel-hal Version ^5.0.2
doctrine/doctrine-laminas-hydrator Version ^2.2
api-skeletons/doctrine-querybuilder-filter Version ^1.2