spatie/laravel-resource-links
Abandoned package that adds action URLs to Laravel API resources. Generate per-item and collection links (show/edit/update/delete, index/create/store) from a controller or defined actions, so resources include ready-to-use endpoints without manual URL building.
API Consistency & Developer Experience (DX):
Roadmap: API-First Strategy
Build vs. Buy: Low-Effort HATEOAS
links: { self: "/users/1", edit: "/users/1/edit" } to every resource).Use Cases:
user.links.edit for deep-linking).Adopt When:
JsonResource and want to avoid manual link generation in every resource class.Look Elsewhere If:
spatie/laravel-honeypot (for security) + custom link logic.filp/whoops (for error handling) + bespoke link generation.spatie/laravel-query-builder for complex filtering/sorting."This package lets our API ‘speak for itself’—reducing dev time and errors.
edit, delete) in every API response, so clients (mobile apps, dashboards) can navigate dynamically—like a self-driving API."Cut API boilerplate and standardize HATEOAS with minimal effort.
links: { self: "/users/1" } code in every JsonResource with a single use Spatie\ResourceLinks\HasLinks.show endpoints include edit/delete links by default).composer.json and enable links in resources:
class UserResource extends JsonResource {
use \Spatie\ResourceLinks\HasLinks;
// ...
}
users.edit → /users/{id}/edit).spatie/laravel-activitylog for inspiration.User, Order).links(['publish' => route('posts.publish', $this)])).""Never write route('users.edit', $user) in a resource again.
use HasLinks to your JsonResource—links appear automatically in the links array.{
"id": 1,
"name": "John",
"links": {
"self": "/users/1",
"edit": "/users/1/edit",
"delete": "/users/1"
}
}
links(['except' => ['delete']]).links(['publish' => route('posts.publish', $this)]).users.edit). Misnamed routes = broken links.How can I help you explore Laravel packages today?