ebsp / resting
Simple REST library for Laravel
Installs: 7 845
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 14
Requires
- php: ^8.2
- ext-json: *
- laravel/framework: ^8.0|^9.0|^10.0
Requires (Dev)
- jchook/phpunit-assert-throws: ^1.0
- orchestra/testbench: ^6.3
- phpunit/phpunit: ^8.0|^9.0
- dev-master
- v5.9.0
- v5.8.1
- v5.8.0
- v5.7.0
- v5.6.0
- v5.5.0
- v5.4.0
- v5.3.0
- v5.2.5
- v5.2.4
- v5.2.3
- v5.2.2
- v5.2.1
- v5.2.0
- v5.1.2
- v5.1.1
- v5.1.0
- v5.0.1
- v5.0.0
- v4.9.0
- v4.8.0
- v4.7.1
- v4.7.0
- v4.6.1
- v4.6.0
- v4.5.0
- v4.4.0
- v4.3.1
- v4.3.0
- v4.2.1
- v4.2.0
- v4.1.1
- v4.1.0
- v4.0.0
- v3.0.0
- v2.6.0
- v2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.1
- v2.0.1
- v2.0.0
- v1.1.0
- v1.0
- dev-normalize-arrays-to-be-list
- dev-dependabot/composer/guzzlehttp/psr7-2.5.0
- dev-dependabot/composer/symfony/http-kernel-5.4.20
- dev-35-add-bypass-option-for-middleware-to-allow-dumpdie-during-development
- dev-29-pre-set-values-with-defaultvalue-to-avoid-unset-variable-issues
- dev-21-add-documentation
- dev-36-validate-body-contents-if-not-empty
- dev-28-carbonperiodfield-use-from-as-to-when-to-is-not-present
- dev-open-api-fix
- dev-variadic-fix
This package is auto-updated.
Last update: 2025-04-01 08:59:59 UTC
README
Simple REST library for Laravel
This is a pendant to Laravel’s built in resources. It’s aimed to be more type aware, strict and to enforce a layer between models and API interfaces.
Please note
This project is developed for use in personal projects. It's currently not advised to use in production projects, as breaking changes will happen.
Resources
Resources are classes representing the data you want to send and receive in your API. Resources are made to separate your data layer from your API interface, making it more flexible. A resource is made up of fields (properties), each having a type. The field type is aware of the fields data type and validation criteria.
Resources should extend Seier\Resting\Resource
.
Fields
The Resting package comes with a number of predefined field types. The following field types are included:
ArrayField
BoolField
CarbonField
DateField
EnumField
Field
IntField
NumberField
PasswordField
ResourceField
ResourceArrayField
StringField
You may define your own depending on your needs. Each field type implements public function set($value)
which is responsible for casting and/or validating the field input when being set.
An instance of a field type is defined on each of the resource’s properties through the resource’s constructor. For instance if the resource expose an attribute id
the corresponding field type could be IntField
An example
An example resource could look like:
class UserResource extends \Seier\Resting\Resource
{
public $id;
public $name;
public function __construct()
{
$this->id = new IntField;
$this->name = new StringField;
}
}
Todo
- Achieve 100% test coverage
- Clean up and finalize OAPI specs
- Add more documentation