spatie/laravel-endpoint-resources
Abandoned package that adds controller/action-based URL links to Laravel API resources and collection meta. Includes traits to generate “show/edit/update/delete” item links and “index/create/store” collection links automatically.
JsonResource responses.self, related, collection) in API responses, improving client-side navigation.HasLinks, HasMeta) for modularity.JsonResource classes (e.g., use HasLinks).links() method in resource to specify controller actions (e.g., links(UserController::class)).self, related, and collection URLs.api/v1/users) may need manual route resolution.delete for unauthenticated users).api/v1) that require manual configuration?delete for non-admins)?spatie/laravel-hal).spatie/laravel-fractal, nWidart/laravel-routes) with active maintenance?Route::getRoutes()).JsonResource for responses.JsonResource classes to identify link generation needs.phpunit, spatie/laravel-package-tools).UserResource) to validate link generation.JsonResource classes.links.self).spatie/laravel-package-tools (v1.x); may conflict with newer Spatie packages.#[\ReturnTypeWillChange]).// Example: Custom route name
public function links(): array
{
return [
'self' => route('custom.user.show', $this->resource),
];
}
JsonResource classes.links() methods for critical resources (e.g., User, Post).delete).spatie/laravel-hal) for long-term stability.route() calls in resources.route() fallback for custom routes").php artisan route:list).Cache::remember()).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Laravel version upgrade | Package breaks | Fork or replace with spatie/laravel-hal |
| Route caching enabled | Stale links | Disable caching or implement refresh logic |
| Missing route | Undefined route error |
Fallback to route() or silent suppression |
| Permission leak | Unauthorized access via links | Filter links by user roles in resource |
| Dependency conflicts | Package fails to install | Isolate in custom namespace or fork |
links() method.JsonResource snippets for the team.How can I help you explore Laravel packages today?