{"repo":"juampi92/api-resources","free":true,"listed":false,"github":"https://github.com/juampi92/api-resources","clone":"git clone https://github.com/juampi92/api-resources.git","description":"Manage your Laravel Eloquent Resources maintaining API versioning","language":"PHP","stars":112,"topics":["laravel","api","php"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Api Resources Manage your resources maintaining API versioning. With a simple middleware separate routes by api version, and smart instanciate Http\\Resources based on this version. Add the middleware 'api.v:2' on your api/v2 group. And then api resource('App\\User')- make($user) is the same as new App\\Http\\Resources\\App\\v2\\User($user) , but version free. The idea behing this A while back I faced this API versioning problem, so I wrote this medium post with my solution and this package reflects this. Installation You can install this package via composer using: The package will automatically register itself. Config To publish the config file to config/api.php run: This will publish a file api.php in your config directory with the following content: Middleware Install this middleware on your Http/Kernel.php under the $routeMiddleware Configure correctly For this package to work, you need to understand how it requires resources. If we have the following config: This means that if you include the Api\\User resource, it will instantiate App\\Http\\Resources\\Api\\v2\\User . Api works for sub organizing your structure, but you can put your Resources versionate folders in the root, like this: Now if we include User , it will instantiate App\\Http\\Resources\\v2\\User . Fallback When you use a version that is NOT the latest, if you try to include a Resource that's NOT defined inside that version's directory, this will automatically fallback in the LATEST version. This way you don't have to dupl","default_branch":null,"files":null,"tree":[],"storefront":"/r/juampi92","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/juampi92/api-resources/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."}