Download the PHP package theodorejb/phaster without Composer
On this page you can find all versions of the php package theodorejb/phaster. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package phaster
Phaster
Phaster is a PSR-7 compatible library for easily making CRUD API endpoints. It enables mapping API fields to columns in the database or from a select query, and implementing custom validation or row modification logic. Built on top of PeachySQL.
Installation
composer require devtheorem/phaster
Usage
Create a class extending Entities, and implement the methods to map properties to columns and
define the base SQL query (see example below).
Pass the callable returned by the route handling functions to your Slim or other PSR-7 compatible framework.
If it is necessary to bind parameters in the base query, use getBaseSelect() instead:
To validate entities before they are inserted or updated, implement validateEntity(). $entity contains
every property from getMap() with the values that will be saved. For partial updates, this is the existing
entity with the patch merged in. When updating, $entity and $existing also contain the ID property,
and $existing contains the fields returned by getEntityById(), such as computed properties.
$existing is null when inserting. Writable properties which aren't selectable (such as a password) aren't
in $existing, and are only in $entity for partial updates if the patch sets them. The ID property must be
output, so the existing entities can be retrieved. If any of the rows being updated can't be selected (e.g.
because the ID doesn't exist or is excluded by processFilter()), a 404 HttpException is thrown and no rows
are updated.
Example API request/response
GET https://example.com/api/users?q[firstName]=Ted&q[isDisabled]=0&fields=id,username,role
Author
Theodore Brown
https://theodorejb.me
License
MIT
All versions of phaster with dependencies
ext-pdo Version *
devtheorem/peachy-sql Version ^7.1
psr/http-message Version ^1.1 || ^2.0
shrikeh/teapot Version ^3.0