{"id":18767958,"url":"https://github.com/zikju/laravel-rest-api-starter","last_synced_at":"2025-04-13T06:32:35.452Z","repository":{"id":37271724,"uuid":"486169032","full_name":"zikju/laravel-rest-api-starter","owner":"zikju","description":"Laravel 9 boilerplate for a handy REST API backend development","archived":true,"fork":false,"pushed_at":"2022-05-25T08:17:26.000Z","size":317,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-19T14:12:28.812Z","etag":null,"topics":["boilerplate","jwt","jwt-auth","laravel","laravel9","php","rest-api","role-based","starter"],"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/zikju.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}},"created_at":"2022-04-27T11:44:31.000Z","updated_at":"2024-11-06T21:28:08.000Z","dependencies_parsed_at":"2022-09-17T12:40:38.993Z","dependency_job_id":null,"html_url":"https://github.com/zikju/laravel-rest-api-starter","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/zikju%2Flaravel-rest-api-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zikju%2Flaravel-rest-api-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zikju%2Flaravel-rest-api-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zikju%2Flaravel-rest-api-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zikju","download_url":"https://codeload.github.com/zikju/laravel-rest-api-starter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248674678,"owners_count":21143760,"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":["boilerplate","jwt","jwt-auth","laravel","laravel9","php","rest-api","role-based","starter"],"created_at":"2024-11-07T19:09:44.849Z","updated_at":"2025-04-13T06:32:30.696Z","avatar_url":"https://github.com/zikju.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Description\nLaravel 9 boilerplate for a handy REST API backend development.\u003cbr /\u003e\n\n_Project created mainly for myself - to learn and practice Laravel._\n\n\n\n# Requirements\n* PHP: \u003e=8.0 \n* MySQL: \u003e=5.7\n* Composer\n\n\n\n# Packages used\n* [php-open-source-saver/jwt-auth](https://github.com/PHP-Open-Source-Saver/jwt-auth \"php-open-source-saver/jwt-auth\") \u003cbr /\u003e\nThis repository is a fork from original [tymonsdesigns/jwt-auth](https://github.com/tymondesigns/jwt-auth/ \"tymonsdesigns/jwt-auth\"). Bunch of enthusiasts decided to work independent, because the original package was not being updated for a long time.\n\n\n\n# Features\n- Laravel 9\n- REST API\n- Authentication with JWT Tokens\n- Refresh Tokens\n- Login, register, email verification and password reset\n- Role-based permissions\n- Users management\n- More to come...\n\n\n\n# Installation\nClone repository:\u003cbr /\u003e\n```\ngit clone https://github.com/zikju/laravel-rest-api-starter\n```\n\n\nInstall composer dependencies:\u003cbr /\u003e\n```\ncomposer install\n```\n\nRename file **_.env.example_**  to **_.env_**\u003cbr /\u003e\n```\ncp .env.example .env\n```\n\nChange MySQL logins variables to match your own database settings:\n\n```dotenv\n DB_HOST=localhost\n DB_PORT=3306\n DB_DATABASE=database_name\n DB_USERNAME=root\n DB_PASSWORD=\n```\n\nGenerate laravel app key:\u003cbr /\u003e\n```\nphp artisan key:generate\n```\n\nGenerate JWT secret key:\u003cbr /\u003e\n```\nphp artisan jwt:secret\n```\n\nMigrate tables to database:\u003cbr /\u003e\n```\nphp artisan migrate\n```\n\nRun server:\u003cbr /\u003e\n````\nphp artisan serve\n````\n\n\n\n\n# POSTMAN\nFor easiest way to test endpoints - import file `POSTMAN_ENDPOINTS.json` into your [Postman](https://www.postman.com/ \"Postman\") workflow. \u003cbr /\u003e\n  After file import - find Collection variables and change `API_URL` to your project url.\n\n\n\n# IDE-Helper\nFor better development experience consider to use [barryvdh/laravel-ide-helper](https://github.com/barryvdh/laravel-ide-helper) (already pre-installed by default).\nThis package generates helper files that enable your IDE to provide accurate autocompletion. Generation is done based on the files in your project, so they are always up-to-date.\n\nRun this commands:\n\n```\nphp artisan clear-compiled\n```\n\n```\nphp artisan ide-helper:generate\n```\n\n```\nphp artisan ide-helper:meta\n```\n\n\n\n# JWT Access Tokens \u0026 Refresh Tokens\n\n**Access Token** - is JWT token. Used to authorize requests and store in payload some additional information about the user (for example: _user_id_, _user_role_ and so on...).\n\n**Refresh Token** - issued by the backend server upon successful authentication and is used to obtain a new pair of access/refresh tokens.\n\nEach token has its own lifetime, for example access: 30 min, refresh: 2 hours.\n\nYou free to override tokens lifetime in `.env` file:\n\n`JWT_TTL=60` - _Access Token_ lifetime in minutes\n\n`JWT_REFRESH_TOKEN_TTL=120` - _Refresh Token_ lifetime in minutes\n\n`JWT_REFRESH_TOKEN_HEADER_KEY=\"X-REFRESH-TOKEN-ID\"` - HTTP Header name that will pass _Refresh Token_ from frontend\n\n\n\n# Role permissions\n\nBy default, `users` database table contains these roles:\n* `user`\n* `manager`\n* `admin`\n\nUser with role `admin` - can bypass any role-checker and access any route.\n\n\n\nFor example, you can protect certain routes with custom middleware:\n\n```php\nRoute::post('users', [UserController::class, 'delete'])-\u003emiddleware('role:manager');\n```\n\nYou can allow multiple roles, just divide them with commas:\n\n```php\nRoute::post('users', [UserController::class, 'delete'])-\u003emiddleware('role:user,manager');\n```\n\u003cbr /\u003e\n\n### To change `role` column values in database via migrations, you have to use `DB::statement`\n\nMigration snippet:\n```php \npublic function up():\n{\n    \\DB::statement(\"ALTER TABLE `users` CHANGE `role` `role` ENUM('user','manager','admin','super-admin') CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'user';\");\n}\n```\n\n\n\n# Endpoints\n\n### Authentication:\n| Method | Endpoint                         | Parameters                                                                                                           | Description         |\n|--------|----------------------------------|----------------------------------------------------------------------------------------------------------------------|---------------------|\n| `POST` | `/auth/login`                    | `email` *string* **required**\u003cbr/\u003e`password` *string* **required**                                                   | login user          |\n| `GET`  | `/auth/logout`                   |                                                                                                                      | logout user         |\n| `GET`  | `/auth/refresh-tokens`           |                                                                                                                      | refresh tokens      |\n\n\n### Registration:\n| Method | Endpoint                         | Parameters                                                                                                           | Description         |\n|--------|----------------------------------|----------------------------------------------------------------------------------------------------------------------|---------------------|\n| `POST` | `/auth/register`                 | `email` *string* **required**\u003cbr/\u003e`password` *string* **required**\u003cbr/\u003e`password_confirmation` *string* **required** | registration        |\n| `PUT`  | `/auth/register/confirm`         | `token` *string* **required**                                                                                        | confirm email       |\n\n\n### Password recovery:\n| Method | Endpoint                         | Parameters                                                                                                           | Description         |\n|--------|----------------------------------|----------------------------------------------------------------------------------------------------------------------|---------------------|\n| `PUT`  | `/auth/recovery/send-email`      | `email` *string* **required**                                                                                        | send recovery email |\n| `PUT`  | `/auth/recovery/change-password` | `token` *string* **required**\u003cbr/\u003e`password` *string* **required**\u003cbr/\u003e`password_confirmation` *string* **required** | save new password   |\n\n### Users create/delete:\n| Method   | Endpoint | Parameters                                                                                                           | Description     |\n|----------|----------|----------------------------------------------------------------------------------------------------------------------|-----------------|\n| `POST`   | `/users` | `email` *string* **required**\u003cbr/\u003e`password` *string* **required**\u003cbr/\u003e`password_confirmation` *string* **required** | Create new User |\n| `DELETE` | `/users` | `id` *string* **required**                                                                                           | Delete user     |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzikju%2Flaravel-rest-api-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzikju%2Flaravel-rest-api-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzikju%2Flaravel-rest-api-starter/lists"}