{"id":21681644,"url":"https://github.com/sdv-plurimedia/laravel-endpoint","last_synced_at":"2025-10-26T01:44:54.043Z","repository":{"id":62541500,"uuid":"79730649","full_name":"SDV-Plurimedia/laravel-endpoint","owner":"SDV-Plurimedia","description":"Laravel Endpoint is a CRUD REST API package for Laravel.","archived":false,"fork":false,"pushed_at":"2023-10-16T12:20:19.000Z","size":56,"stargazers_count":11,"open_issues_count":7,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T02:02:58.957Z","etag":null,"topics":["api","laravel","laravel-5-package","laravel-endpoint"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SDV-Plurimedia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-22T16:50:46.000Z","updated_at":"2020-10-12T08:00:00.000Z","dependencies_parsed_at":"2024-11-25T15:43:43.958Z","dependency_job_id":null,"html_url":"https://github.com/SDV-Plurimedia/laravel-endpoint","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDV-Plurimedia%2Flaravel-endpoint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDV-Plurimedia%2Flaravel-endpoint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDV-Plurimedia%2Flaravel-endpoint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SDV-Plurimedia%2Flaravel-endpoint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SDV-Plurimedia","download_url":"https://codeload.github.com/SDV-Plurimedia/laravel-endpoint/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248530609,"owners_count":21119591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","laravel","laravel-5-package","laravel-endpoint"],"created_at":"2024-11-25T15:30:10.808Z","updated_at":"2025-10-26T01:44:48.994Z","avatar_url":"https://github.com/SDV-Plurimedia.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Endpoint\n\n[![Latest Stable Version](https://poser.pugx.org/sdv/laravel-endpoint/v/stable)](https://packagist.org/packages/sdv/laravel-endpoint)\n[![License](https://poser.pugx.org/sdv/laravel-endpoint/license)](https://packagist.org/packages/sdv/laravel-endpoint)\n[![Total Downloads](https://poser.pugx.org/sdv/laravel-endpoint/downloads)](https://packagist.org/packages/sdv/laravel-endpoint)\n[![Build Status](https://travis-ci.org/SDV-Plurimedia/laravel-endpoint.svg?branch=master)](https://travis-ci.org/SDV-Plurimedia/laravel-endpoint)\n\n\nLaravel Endpoint is a CRUD REST API package for Laravel.\n\n## Features\n\n- [X] REST CRUD Endpoint scaffolding\n- [X] Normalized JSON Response using [laravel-fractal](https://github.com/spatie/laravel-fractal)\n- [X] Simple filtering operations\n- [ ] Ability to customize fractal serializer\n- [ ] Ability to customize filtering and sorting strategies\n- [ ] [Elasticsearch](https://www.elastic.co/products/elasticsearch) / [Algolia](https://www.algolia.com/) search\n- [ ] Api Documentation ([Swagger](http://swagger.io/swagger-ui/), [API Blueprint](https://apiblueprint.org/))\n\n## Installation\n\nYou can pull in the package via composer:\n\n```\n$ composer require sdv/laravel-endpoint\n```\n\nRegister the service provider.\n\n```\n// config/app.php\n'providers' =\u003e [\n    ...\n    SdV\\Endpoint\\EndpointServiceProvider::class,\n]\n```\n\nReplace the render method in ```app/Exceptions/Handler.php```.\n\n```\nuse SdV\\Endpoint\\ProvidesExceptionsHandler;\n\nclass Handler extends ExceptionHandler\n{\n    use ProvidesExceptionsHandler;\n\n    ...\n\n    /**\n     * Render an exception into an HTTP response.\n     *\n     * @param  \\Illuminate\\Http\\Request  $request\n     * @param  \\Exception  $exception\n     * @return \\Illuminate\\Http\\Response\n     */\n    public function render($request, Exception $exception)\n    {\n        if ($this-\u003eisRequestForApi($request)) {\n            return $this-\u003erenderJson($exception, $request);\n        }\n\n        return parent::render($request, $exception);\n    }\n\n    ...\n}\n```\n\n## Testing\n\n```\ncomposer test\n```\n\n## Commands Usage\n\n### Create a new endpoint\n\n```\nphp artisan endpoint:make:all Post v1\n```\n\nThis will create all this files.\n\n- app/Post.php\n- app/Repositories/PostRepository.php\n- app/Transformers/PostTransformer.php\n- app/Http/Controllers/Api/V1/PostController.php\n\nOptions:\n\n- --mongo : Generate a Laravel-MongoDB compatible Model. (You need to install https://github.com/jenssegers/laravel-mongodb in your app)\n- --module=Modules\\\\Search : Generate all the files under the App\\Modules\\Search namespace.\n\n```\n    - app\n        - Modules\n            - Search\n                - Http\\Controllers\\Api\\V1\n                - Models\n                - Repositories\n                - Transformers\n    - bootstrap\n    - config\n    - database\n    - ...\n```\n\nThen, you need to register your api routes.\n\n```\n// routes/api.php\nRoute::group(['namespace' =\u003e 'Api\\V1', 'prefix' =\u003e 'v1'], function () {\n    Route::resource('posts', 'PostController', ['except' =\u003e [\n        'create', 'edit'\n    ]]);\n});\n```\n\n### Create a new model class.\n\n```\nphp artisan endpoint:make:model Post\n```\n\nThis will create the file ```app/Post.php``` and insert the minimum boilerplate with filtrable trait.\n\nOptionnaly, you can add the --mongo flag to generate a Laravel-MongoDB compatible Model.\n\n### Create a new controller class.\n\n```\nphp artisan endpoint:make:controller Post v1\n```\n\nThis will create the file ```app/Http/Controllers/Api/V1/PostController.php``` and insert the minimum boilerplate.\n\n###  Create a new repository class.\n\n```\nphp artisan endpoint:make:repository Post\n```\n\nThis will create the file ```app/Repositories/PostRepository.php``` and insert the minimum boilerplate.\n\n### Create a new transformer class.\n\n```\nphp artisan endpoint:make:transformer Post\n```\n\nThis will create the file ```app/Transformers/PostTransformer.php``` and insert the minimum boilerplate.\n\n## API Usage\n\n### Pagination\n\n#### Change the selected page\n\n```\n/api/v1/topics?page=2\n```\n\n#### Change the number of items per page\n\n```\n/api/v1/topics?per_page=50\n```\n\n### Returns all\n\n```\n/api/v1/topics?limit=all\n```\n\n### Filters\n\nThe ```and``` filter is applied by default.\n\n#### And Filter\n\n```\n/api/v1/topics?filter[]=name,eq,laravel\u0026filter[]=name,eq,eloquent\u0026satisfy=all\n```\n\n#### Or Filter\n\n```\n/api/v1/topics?filter[]=name,eq,laravel\u0026filter[]=name,eq,eloquent\u0026satisfy=any\n```\n\n### Sort\n\n```\n/api/v1/topics?sort=name\n```\n\n```\n/api/v1/topics?sort=-name\n```\n\n```\n/api/v1/topics?sort=-slug,name\n```\n\n### Includes\n\nUpdate your transformer to add your include rules, according to fractal docs (http://fractal.thephpleague.com/transformers/)\n\nThen you can include related models on your calls\n\n```\n/api/v1/topics?include=posts,posts.author\n```\n\n## Error responses\n\n- Bad request (400) ```$this-\u003ebadRequest('The request was unacceptable.')```\n- Unauthorized (401) ```$this-\u003eunauthorized('No valid API key was provided.')```\n- Forbidden (403) ```$this-\u003eforbidden('Access forbidden.')```\n- Not found (404) ```$this-\u003enotFound('Resource not found.')```\n- Method not allowed (405) ```$this-\u003emethodNotAllowed('The HTTP method is not allowed.')```\n- Unprocessable entity (422) ```$this-\u003eunprocessableEntity('Invalid fields.')```\n- Too many requests (429) ```$this-\u003etooManyRequests('Too many requests hit the API.')```\n- Server error (500) ```$this-\u003eserverError('Internal server error.')```\n\nNote: The ```ProvidesExceptionsHandler``` comes with default support for the following exceptions:\n\n- Illuminate\\Database\\Eloquent\\ModelNotFoundException\n- Illuminate\\Validation\\ValidationException\n- Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException\n- Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException\n\n## Credits\n\n- http://fractal.thephpleague.com/transformers/\n- https://github.com/spatie/laravel-fractal\n\n## License\n\nLaravel Endpoint is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdv-plurimedia%2Flaravel-endpoint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsdv-plurimedia%2Flaravel-endpoint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsdv-plurimedia%2Flaravel-endpoint/lists"}