{"id":20917783,"url":"https://github.com/kitloong/laravel-api-practice","last_synced_at":"2025-04-11T10:21:59.087Z","repository":{"id":38183513,"uuid":"270031514","full_name":"kitloong/laravel-api-practice","owner":"kitloong","description":"Create CRUD REST API with Laravel API Resource https://medium.com/@kitloong/create-crud-rest-api-with-laravel-api-resource-3146d91b38b6","archived":false,"fork":false,"pushed_at":"2023-04-19T20:56:05.000Z","size":345,"stargazers_count":7,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-18T16:59:38.470Z","etag":null,"topics":["api-resources","laravel","swagger"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kitloong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-06-06T16:04:34.000Z","updated_at":"2024-07-05T14:49:28.000Z","dependencies_parsed_at":"2024-11-18T16:51:49.231Z","dependency_job_id":"84586246-2222-4f23-87ce-e3620733e623","html_url":"https://github.com/kitloong/laravel-api-practice","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitloong%2Flaravel-api-practice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitloong%2Flaravel-api-practice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitloong%2Flaravel-api-practice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitloong%2Flaravel-api-practice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kitloong","download_url":"https://codeload.github.com/kitloong/laravel-api-practice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234668881,"owners_count":18868977,"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-resources","laravel","swagger"],"created_at":"2024-11-18T16:35:49.552Z","updated_at":"2025-01-19T16:43:17.364Z","avatar_url":"https://github.com/kitloong.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Article\n\nhttps://medium.com/@kitloong/create-crud-rest-api-with-laravel-api-resource-3146d91b38b6\n\n## Setup\n\nThis project uses [Sail](https://laravel.com/docs/sail).\n\nPlease install [Docker](https://www.docker.com) in order to start using Sail.\n\nInstall project dependencies:\n\n```shell\ncomposer install\n```\n\nSetup env:\n\n```shell\ncp .env.example .env\nphp artisan key:generate\n```\n\nStartup services:\n\n```shell\n./vendor/bin/sail up -d # Up on port 8080\n```\n\nPS: `.env` has been pre-configured to support MySQL and Redis from sail.\n\nCheck service status:\n\n```\ncurl http://localhost:8080/api/health\n```\n\nMigrate and seed database:\n\n```shell\n./vendor/bin/sail artisan migrate\n./vendor/bin/sail artisan db:seed\n```\n\n### Swagger\n\nGenerate swagger page\n\n```shell\n./vendor/bin/sail artisan l5-swagger:generate\n```\n\nOpen http://localhost:8080/api/documentation with your favourite browser to browse Swagger page.\n\n## API example\n\n### List\n\nRoute: `users.index`\n\n```shell\ncurl http://localhost:8080/api/users \\\n     -H 'Accept: application/json'\n```\n\n### Get\n\nRoute: `users.show`\n\n```shell\ncurl http://localhost:8080/api/users/1 \\\n     -H 'Accept: application/json'\n```\n\n### Create\n\nRoute: `users.store`\n\n```shell\ncurl -X POST http://localhost:8080/api/users \\\n     -H 'Accept: application/json' \\\n     -H 'Content-Type: application/json' \\\n     -d $'{\n         \"name\": \"Name\",\n         \"email\": \"test@email.com\",\n         \"password\": \"password\"\n      }'\n```\n\n### Update\n\nRoute: `users.update`\n\n```shell\ncurl -X PUT http://localhost:8080/api/users/1 \\\n     -H 'Accept: application/json' \\\n     -H 'Content-Type: application/json' \\\n     -d $'{\n         \"name\": \"Name\",\n         \"email\": \"test@email.com\"\n      }'\n```\n\n### Delete\n\nRoute: `users.destroy`\n\n```shell\ncurl -X DELETE http://localhost:8080/api/users/7 \\\n     -H 'Accept: application/json'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitloong%2Flaravel-api-practice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkitloong%2Flaravel-api-practice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitloong%2Flaravel-api-practice/lists"}