{"id":15984538,"url":"https://github.com/mixerapi/rest","last_synced_at":"2025-09-04T03:32:49.015Z","repository":{"id":57017887,"uuid":"276237595","full_name":"mixerapi/rest","owner":"mixerapi","description":"Generate restful routes with a single command or expose them automatically with an AutoRouter [READ-ONLY]","archived":false,"fork":false,"pushed_at":"2024-03-25T23:50:18.000Z","size":112,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-15T02:32:02.247Z","etag":null,"topics":["cakephp","cakephp-api","cakephp-bake","cakephp-plugin","cakephp-rest","cakephp4","php","rest","rest-api","restful","restful-api"],"latest_commit_sha":null,"homepage":"https://mixerapi.com/plugins/rest","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mixerapi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-01T00:22:32.000Z","updated_at":"2024-02-17T22:21:23.000Z","dependencies_parsed_at":"2023-02-08T06:31:13.505Z","dependency_job_id":null,"html_url":"https://github.com/mixerapi/rest","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixerapi%2Frest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixerapi%2Frest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixerapi%2Frest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixerapi%2Frest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mixerapi","download_url":"https://codeload.github.com/mixerapi/rest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221703934,"owners_count":16866641,"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":["cakephp","cakephp-api","cakephp-bake","cakephp-plugin","cakephp-rest","cakephp4","php","rest","rest-api","restful","restful-api"],"created_at":"2024-10-08T02:09:27.841Z","updated_at":"2024-10-27T16:24:35.428Z","avatar_url":"https://github.com/mixerapi.png","language":"PHP","readme":"# MixerApi REST\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/mixerapi/cakephp-rest.svg?style=flat-square)](https://packagist.org/packages/mixerapi/cakephp-rest)\n[![Build](https://github.com/mixerapi/mixerapi-dev/workflows/Build/badge.svg?branch=master)](https://github.com/mixerapi/mixerapi-dev/actions?query=workflow%3ABuild)\n[![Coverage Status](https://coveralls.io/repos/github/mixerapi/mixerapi-dev/badge.svg?branch=master)](https://coveralls.io/github/mixerapi/mixerapi-dev?branch=master)\n[![MixerApi](https://mixerapi.com/assets/img/mixer-api-red.svg)](https://mixerapi.com)\n[![CakePHP](https://img.shields.io/badge/cakephp-^4.2-red?logo=cakephp)](https://book.cakephp.org/4/en/index.html)\n[![Minimum PHP Version](https://img.shields.io/badge/php-^8.0-8892BF.svg?logo=php)](https://php.net/)\n\nThis plugin gets your API project up and going quickly by creating routes for you.\n\n- Build your `routes.php` file from a single command or automatically expose RESTful CRUD routes with a handy AutoRouter.\n- Set default HTTP status codes for CRUD operations\n\nThis plugin assumes you have already created models and controllers. For help with the latter check out\n[MixerApi/Bake](https://github.com/mixerapi/bake). Check the official\n[RESTful routing](https://book.cakephp.org/4/en/development/routing.html#restful-routing) documentation\nfor handling advanced routing scenarios not covered by this plugin.\n\nRead more at [MixerAPI.com](https://mixerapi.com).\n\n## Installation\n\n!!! info \"\"\n    You can skip this step if MixerAPI is installed.\n\n```console\ncomposer require mixerapi/rest\nbin/cake plugin load MixerApi/Rest\n```\n\nAlternatively after composer installing you can manually load the plugin in your Application:\n\n```php\n# src/Application.php\npublic function bootstrap(): void\n{\n    // other logic...\n    $this-\u003eaddPlugin('MixerApi/Rest');\n}\n```\n\n## AutoRouter\n\nCreating routes is already pretty easy, but AutoRouter makes building CRUD routes effortless. This is great\nif you are just getting started with building APIs in CakePHP.\n\nIn your `routes.php` simply add `\\MixerApi\\Rest\\Lib\\AutoRouter`:\n\n```php\n# config/routes.php\n$routes-\u003escope('/', function (RouteBuilder $builder) {\n    // ... other routes\n    (new AutoRouter($builder))-\u003ebuildResources();\n    // ... other routes\n});\n```\n\nThis will add routes for CRUD controller actions (index, add, edit, view, and delete). If your controller does not have\nany CRUD methods, then the route will be skipped. AutoRouting works for plugins too:\n\n```php\n# in your plugins/{PluginName}/routes.php file\n(new AutoRouter($builder, new ResourceScanner('MyPlugin\\Controller')))-\u003ebuildResources();\n```\n\n## Create Routes\n\nWhile AutoRouter makes life easy, it must scan your controllers to build RESTful resources. This has a slight\nperformance penalty. No worry, you can use `mixerapi:rest route create` to code your routes for you. This will write\nroutes directly to your routes.php file.\n\n```console\n# writes to `config/routes.php`\nbin/cake mixerapi:rest route create\n```\n\nUse `--prefix` to specify a prefix:\n\n```console\nbin/cake mixerapi:rest route create --prefix /api\n```\n\nUse `--plugin` for plugins:\n\n```console\n# writes to `plugins/MyPlugin/config/routes.php`\nbin/cake mixerapi:rest route create --plugin MyPlugin\n```\n\nTo perform a dry-run use the `--display` option:\n\n```console\nbin/cake mixerapi:rest route create --display\n```\n\nFor non-CRUD routes, sub-resources, and advanced routing please reference the CakePHP\n[RESTful routing](https://book.cakephp.org/4/en/development/routing.html#restful-routing) documentation\n\n### List Routes\n\nThis works similar to `bin/cake routes` but shows only RESTful routes and improves some formatting of information.\n\n```console\nbin/cake mixerapi:rest route list\n```\n\nTo limit output to a specific plugin use the `--plugin` option:\n\n```console\n# limit to a plugin:\nbin/cake mixerapi:rest route list --plugin MyPlugin\n\n#limit to main application:\nbin/cake mixerapi:rest route list --plugin App\n```\n\n### CRUD HTTP Status Codes\n\nThe default status codes are:\n\n| Action      | Status Code |\n| ----------- | ----------- |\n| index       | 200         |\n| view        | 200         |\n| add         | 201         |\n| edit        | 200         |\n| delete      | 204         |\n\nTo change these load a `MixerApi.Rest.crud.statusCodes` configuration:\n\n```php\nreturn [\n    'MixerApi' =\u003e [\n        'Rest' =\u003e [\n            'crud' =\u003e [\n                'statusCodes' =\u003e [\n                    'index' =\u003e 200,\n                    'view' =\u003e 200,\n                    'add' =\u003e 201,\n                    'edit' =\u003e 200,\n                    'delete' =\u003e 204\n                ]\n            ]\n        ]\n    ]\n];\n```\n\nSee the CakePHP documentation on\n[loading configuration files](https://book.cakephp.org/4/en/development/configuration.html#loading-additional-configuration-files)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixerapi%2Frest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmixerapi%2Frest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixerapi%2Frest/lists"}