{"id":25171648,"url":"https://github.com/basemax/firstlaravelapi","last_synced_at":"2025-07-19T16:06:57.938Z","repository":{"id":37589301,"uuid":"355335269","full_name":"BaseMax/FirstLaravelAPI","owner":"BaseMax","description":"A simple example of how to create a RESTful API in Laravel Framework 8.36.1.","archived":false,"fork":false,"pushed_at":"2024-11-13T06:38:28.000Z","size":9754,"stargazers_count":12,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-04T21:45:38.425Z","etag":null,"topics":["laravel","laravel-example","laravel-json-api","laravel-rest","laravel-rest-api","laravel-restful-api","laravel-sample","php","php8"],"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/BaseMax.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":"2021-04-06T21:32:41.000Z","updated_at":"2024-11-13T06:38:25.000Z","dependencies_parsed_at":"2024-11-07T00:38:20.040Z","dependency_job_id":null,"html_url":"https://github.com/BaseMax/FirstLaravelAPI","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/BaseMax%2FFirstLaravelAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FFirstLaravelAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FFirstLaravelAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FFirstLaravelAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/FirstLaravelAPI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252577000,"owners_count":21770721,"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","laravel-example","laravel-json-api","laravel-rest","laravel-rest-api","laravel-restful-api","laravel-sample","php","php8"],"created_at":"2025-02-09T09:21:28.374Z","updated_at":"2025-05-05T21:06:20.659Z","avatar_url":"https://github.com/BaseMax.png","language":"PHP","readme":"# First Laravel PHP\n\nA simple example of how to create a RESTful API in Laravel Framework 8.36.1.\n\nI used Database **sqlite** because I wanted to deploy this project very quickly and easy.\nYou can easily change the type of database and its connection in the **[config file](.env)**.\n\n## Endpoints\n\n**Get all posts:** `GET /api/posts`\n\n**Get a single post:** `GET /api/posts/{id}`\n\n**Create a new post:** `POST /api/posts`\n\n**Update a post:** `PUT /api/posts/{id}`\n\n**Delete a post:** `DELETE /api/posts/{id}`\n\n## Routes\n\n```\nRoute::get('/posts', [PostsApiController::class, 'index']);\nRoute::get('/post/{post}', [PostsApiController::class, 'get']);\nRoute::post('/posts', [PostsApiController::class, 'store']);\nRoute::put('/posts/{post}', [PostsApiController::class, 'update']);\nRoute::delete('/posts/{post}', [PostsApiController::class, 'destroy']);\n```\n\n### Laravel artisan commands\n\n```\nphp artisan --version\nrm database/database.sqlite \nsqlite3 database/database.sqlite \"create table aTable(field1 int); drop table aTable;\"\nphp artisan make:model Post -m\nphp artisan migrate\nphp artisan migrate:fresh\nphp artisan migrate:status\nphp artisan migrate:reset\nphp artisan migrate:refresh\nphp artisan migrate\nphp artisan make:controller PostsApiController \n```\n\n### Insert fake/sample data to database\n\n**$ php artisan tinker**\n\n```\nPsy Shell v0.10.7 (PHP 8.0.3 — cli) by Justin Hileman\n\u003e\u003e\u003e $post = new Post;\n[!] Aliasing 'Post' to 'App\\Models\\Post' for this Tinker session.\n=\u003e App\\Models\\Post {#3329}\n\u003e\u003e\u003e $post-\u003etitle = 'My first post'\n=\u003e \"My first post\"\n\u003e\u003e\u003e $post-\u003econtent = 'My first blog post text...'\n=\u003e \"My first blog post text...\"\n\u003e\u003e\u003e $post-\u003esave()\n=\u003e true\n\n\u003e\u003e\u003e $post = new Post\n=\u003e App\\Models\\Post {#3322}\n\u003e\u003e\u003e $post-\u003etitle = 'My second post'\n=\u003e \"My second post\"\n\u003e\u003e\u003e $post-\u003econtent = 'My second blog post text'\n=\u003e \"My second blog post text\"\n\u003e\u003e\u003e $post-\u003esave()\n=\u003e true\n```\n\n### Database Preview\n\n![sqlite laravel sample project database preview](sqlite-preview.png)\n\n![sqlite laravel sample project database preview](sqlite-post-table-preview.png)\n\n## Acknowledgment\n\n\u003c!-- https://www.youtube.com/watch?v=WDha52dbLWM --\u003e\nI saw an Youtube video and It's encouraged me to write a similar project myself.\n\n© Copyright Max Base 2021\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Ffirstlaravelapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Ffirstlaravelapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Ffirstlaravelapi/lists"}