{"id":18262524,"url":"https://github.com/ignitionwolf/wolf-api","last_synced_at":"2026-05-16T22:32:32.117Z","repository":{"id":186826635,"uuid":"261322957","full_name":"IgnitionWolf/wolf-api","owner":"IgnitionWolf","description":"This converts any fresh Laravel project into a full-fledged RESTful API.","archived":false,"fork":false,"pushed_at":"2021-09-25T16:32:04.000Z","size":538,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-09T00:56:02.412Z","etag":null,"topics":["laravel","php","rest-api"],"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/IgnitionWolf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"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":"2020-05-05T00:04:26.000Z","updated_at":"2024-01-31T21:13:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"b1c3726c-8f9d-436d-98bd-cc11bdfc9dc4","html_url":"https://github.com/IgnitionWolf/wolf-api","commit_stats":null,"previous_names":["ignitionwolf/wolf-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/IgnitionWolf/wolf-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IgnitionWolf%2Fwolf-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IgnitionWolf%2Fwolf-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IgnitionWolf%2Fwolf-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IgnitionWolf%2Fwolf-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IgnitionWolf","download_url":"https://codeload.github.com/IgnitionWolf/wolf-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IgnitionWolf%2Fwolf-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265427641,"owners_count":23763366,"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":["laravel","php","rest-api"],"created_at":"2024-11-05T11:08:03.668Z","updated_at":"2026-05-16T22:32:27.089Z","avatar_url":"https://github.com/IgnitionWolf.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WolfAPI\n\nThis is meant to ease the friction when developing restful APIs with Laravel, by simply installing this package you\nwill be able to serve an API service without much hassle.\n\n## How it works\n\nThis package focuses on handling boilerplate when creating a REST API, most of the magic occurs in the `CRUDController`\nwhich is in charge of handling create, read, update, delete, and list requests for a specific model. This follows\nLaravel conventions, so you will also need to create a FormRequest for each action which will handle validation\nand authorization. Of course, this package provides a set of commands to help with that.\n\nIn the background, this uses Responder package for building the JSON responses, and a custom exception handler which\nintercepts thrown exceptions and outputs them as JSON accordingly.\n\n## Installation\n\nYou can install the package via composer:\n\n``` bash\n$ composer require ignitionwolf/wolf-api\n$ php artisan clear-compiled\n```\n\n## Usage\n\n### Create an API resource\n\nYou can create the CRUD controller file, form requests, model, and route definitions by running this command:\n\n``` bash\n$ php artisan make:crud {name}\n```\n\nYou can also run each make command individually and define the routes manually like you usually do with Laravel.\n\n### Extending the controller\n\nWhen you create a controller with ```bash php artisan make:crud``` or ```php artisan make:controller --api``` you will\nbe able to see a class like this:\n\n```php\nclass DummyController extends CRUDController\n{\n    /**\n     * Points to the model to be handled in the controller.\n     *\n     * @var string\n     */\n    protected string $model = \\App\\Models\\Dummy:class;\n\n    /**\n     * List of sortable attributes for the list endpoint.\n     *\n     * @var array\n     */\n    protected array $allowedSorts = [];\n\n    /**\n     * List of filterable attributes for the list endpoint.\n     *\n     * @var array\n     */\n    protected array $allowedFilters = [];\n}\n```\n\nThe ```$allowedSorts``` and ```$allowedFilters``` are used for listing purposes, this uses\n[spatie's laravel-query-builder](https://github.com/spatie/laravel-query-builder) internally to generate the data\nfor the ``` GET /api/model ``` route.\n\n\nBehind scenes, the ```CRUDController``` grabs validated data from the FormRequest and uses it to fill the model data accordingly.\nThere isn't more than that, therefore if you need to extend the functionality of the controller in order to implement\nbusiness logic or more complex actions then you can use pre and post hooks for a specific action, for example:\n\n```php\npublic function onPreUpdate(Request $request, Model $model)\n{\n    $model-\u003etimes_updated ++;\n}\n```\n\nYou can check out the [WithHooks trait](./src/Concerns/WithHooks.php) in order to see which hooks you can use.\n\nIt's also worthy to note that you're not restricted to using hooks to extend a model's functionality for specific actions\nbut that you can also use Laravel events and listeners, or the Automap pattern.\n\n#### Automap\n\nThere are some repetitive actions when creating a model. For example, let's say you want to keep record on who created\ncertain entities.\n\n```bash\n$ php artisan make:automap CreatedByAttribute\n```\n\n```php\n# file: app/Models/Dummy.php\nclass Dummy extends Model\n{\n    use \\IgnitionWolf\\API\\Automap\\Automapable;\n    \n    protected $map = [\n        'created_by' =\u003e \\App\\Automap\\CreatedByAttribute::class\n    ];\n}\n```\n\n```php\n# file: app/Automap/CreatedByAttribute.php\nclass CreatedByAttribute implements AutomapInterface\n{\n    public function map(Model $entity, string $attribute)\n    {\n        // This will assign created_by to the current authenticated user.\n        $entity-\u003e${attribute} = auth()-\u003euser();\n    }\n}\n```\n\n## Alternatively, dingo\n\nAnother known solution is [dingoapi](https://github.com/dingo/api). Contrary to dingoapi, WolfAPI tries to stay ignorant\nabout implementation details and business logic, for example, authentication or authorization/permission systems. You're\nfree to develop your API however you want, with a small-to-none learning curve as long as you're comfortable\nwith Laravel principles and best practices, while WolfAPI removes the overhead of writing and maintaining boilerplate code.\n\n## Testing\n\n```bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease send an e-mail to mauricio@ignitionwolf.com in order to report security vulnerabilities.\n\n## Credits\n\n- [IgnitionWolf](https://github.com/IgnitionWolf)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignitionwolf%2Fwolf-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fignitionwolf%2Fwolf-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignitionwolf%2Fwolf-api/lists"}