Download the PHP package benyaminrmb/laravel-dynamic-resources without Composer
On this page you can find all versions of the php package benyaminrmb/laravel-dynamic-resources. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download benyaminrmb/laravel-dynamic-resources
More information about benyaminrmb/laravel-dynamic-resources
Files in benyaminrmb/laravel-dynamic-resources
Package laravel-dynamic-resources
Short Description Composable, IDE-discoverable API resource views and safe sparse fieldsets for Laravel.
License MIT
Homepage https://github.com/Benyaminrmb/laravel-dynamic-resources
Informations about the package laravel-dynamic-resources
Laravel Dynamic Resources
Define every API representation of a model in one Laravel resource. Views are composable, safe for loaded relationships, and represented by real PHP constants and methods that IDEs can discover.
Installation
Laravel 12 and 13 and PHP 8.3–8.5 are supported.
One resource, every response
The method name becomes the kebab-case view name: minimalWithAvatarFields() defines minimal-with-avatar. Use name: on #[View] when an explicit name is clearer.
Exactly one view must have default: true. Only views with requestable: true may be selected through HTTP query parameters.
IDE-discoverable selection
Synchronize real constants and fluent methods after adding or renaming a view:
Both forms are real PHP—not runtime magic:
Use the check command in CI:
Composing views
Pass one view or several:
Views resolve from left to right; later fields replace matching earlier fields. withoutView() accepts a string or array too.
For a combination used throughout the application, define a named view and call the component methods directly with combine(), as shown by minimalWithAvatarFields(). This gives PHPStorm and refactoring tools real method references.
Fields and relationships
String entries lazily read the corresponding model attribute. Named entries transform or condition values using the normal Laravel resource API:
relation() only serializes an already-loaded relationship. It never runs a query:
It resolves the related resource through Laravel conventions, supports one/many relations, and accepts resourceClass: when a project uses a custom location.
Filtering and safe request views
Request selection is explicit:
Clients may request allowlisted views and sparse fields:
Malformed, oversized, too-deep, or non-requestable selections produce HTTP 400 responses. Parameter names and limits are configurable in config/dynamic-resources.php.
Commands
See UPGRADE.md for migration from v2.
Quality
Laravel Dynamic Resources is open-source software licensed under the MIT license.
All versions of laravel-dynamic-resources with dependencies
illuminate/console Version ^12.0|^13.0
illuminate/filesystem Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
symfony/http-kernel Version ^7.2|^8.0