{"repo":"gdebrauwer/laravel-hateoas","free":true,"listed":false,"github":"https://github.com/gdebrauwer/laravel-hateoas","clone":"git clone https://github.com/gdebrauwer/laravel-hateoas.git","description":"Expose the authorization logic of your REST API using HATEOAS links","language":"PHP","stars":175,"topics":["laravel","hateoas","api","rest-api","resources"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Laravel HATEOAS HATEOAS allows you to expose the authorization logic of your REST API. This package makes it easy to add HATEOAS links to your Laravel API resources. Each resource has its HATEOAS links, and only the accessible links per resource are returned. If a link is not available on a resource, then the clients of your API can disable functionality linked to that HATEOAS link. By default an array of links, in the following format, will be added to the JSON of a Laravel API resource: Installation You can install the package via composer: Usage You can create a new HATEOAS class for a model using the following artisan command: In the created class you can define public methods that will be used to generate the links. A method should either return a link or null . To add the links to an API resource, you have to add the HasLinks trait and use the $this- links() method. The HATEOAS class will be automatically discovered. Customization Formatting You can customize the JSON links formatting by providing a formatter class that implements the Formatter interface to the formatLinksUsing method. If the code to format the links is pretty small or you don't want to create a separate formatter class for it, you also have the option to provide a formatting callback function to the formatLinksUsing method. HATEOAS class discovery By default, the HATEOAS classes of models will be auto-discovered. Specifically, the HATEOAS classes must be in a Hateoas directory below the directory that ","default_branch":null,"files":null,"tree":[],"storefront":"/r/gdebrauwer","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/gdebrauwer/laravel-hateoas/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}