1codehappy / laravel-api
The Boilerplate for Laravel Restful Apis.
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.1
- darkaonline/l5-swagger: ^8.0
- fruitcake/laravel-cors: ^2.0
- guzzlehttp/guzzle: ^7.0.1
- itsgoingd/clockwork: ^5.1
- jessarcher/laravel-castable-data-transfer-object: ^2.1
- laracasts/presenter: dev-chore/laravel-9
- laravel/framework: ^9.0
- laravel/tinker: ^2.5
- php-open-source-saver/jwt-auth: ^1.4
- spatie/data-transfer-object: ^3.0
- spatie/laravel-fractal: ^6.0
- spatie/laravel-permission: ^5.0
- spatie/laravel-query-builder: ^5.0
Requires (Dev)
- barryvdh/laravel-ide-helper: ^2.9
- brianium/paratest: ^6.2
- enlightn/security-checker: ^1.10
- fakerphp/faker: ^1.9.1
- friendsofphp/php-cs-fixer: ^3.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0
- pestphp/pest-plugin-faker: ^1.0
- pestphp/pest-plugin-laravel: ^1.2
- pestphp/pest-plugin-parallel: ^1.0
- phpunit/phpunit: ^9.3.3
- spatie/laravel-ignition: ^1.0
README
A simple, a modern and an elegant Laravel boilerpate for your api, applying Domain Driven Design and hexagonal architecture principles based on Laravel Beyond Crud.
Features
- PHP 8.1+
- Laravel 9 Github Docs
- CircleCI Site
- Api restful
- JWT Auth
- ACL & Laravel Policies
- PestPHP tests
- OpenApi docs
Installation
Create your project using composer.
composer create-project 1codehappy/laravel-api myApi
Directories
See the directory structure bellow:
|-- app/
|-- Backend # Api & Artisan commands
|-- Domain # Domains
|-- Support # Commons & Api Documentation
Factories
<?php $user = User::factory()->hasRoles()->hasPermissions()->create(); $roles = Role::factory()->hasPermissions()->count(2)->create(); $permissions = Permission::factory()->count(3)->create(); $user->assignRole($roles->pluck('name')->all()) # Assign 2 random roles. ->givePermissionTo($permissions->pluck('name')->all()) # Give 3 random permissions. ->load('roles', 'permissions'); # Load object relations.
Routes
GET /api-docs
:
- Authentication:
- POST
/auth/login
: Sign in. - POST
/auth/logout
: Sign out. - POST
/auth/refresh
: Refresh the JWT Token.
- POST
- User's profile:
- GET
/auth/me
: Get authenticated user's profile. - PUT
/auth/me
: Edit authenticated user's profile. - PUT
/auth/me/password
: Change authenticated user's password.
- GET
- ACL:
- GET
/permissions
: Get the permission list. - GET
/roles
: Get the role list. - GET
/roles/{uuid}
: Get the role. - POST
/roles
: Create a new role. - PUT
/roles/{uuid}
: Edit the role. - DELETE
/roles/{uuid}
: Delete the role.
- GET
- Users:
- GET
/users/
: Get the user list. - GET
/users/{uuid}
: Get the user. - POST
/users
: Create a new user. - PUT
/users/{uuid}
: Edit the user. - DELETE
/users/{uuid}
: Delete the user.
- GET
Api Documentation
To generate the api documentation:
php artisan l5-swagger:generate # or `composer doc`
PHP Libraries
- Laracasts Presenter GitHub
- Clockwork GitHub Docs
- PHP Open Source Saver JWT GitHub Docs
- Jess Archer Castable GitHub
- Spatie Data Transfer Objects GitHub
- Spatie Laravel Fractal GitHub
- Spatie Laravel Query Builder GitHub Docs
- Spatie Permissions Github Docs
- Darka On Line Swagger GitHub
- FriendsOfPHP CS Fixer GitHub Docs
- Laravel IDE Helper GitHub
- Larastan GitHub Docs
- PestPHP GitHub Docs
- Enlightn Security Checker GitHub
Composer Scripts
composer clear
: Clear laravel cache.composer optimize
: Optimize api.composer cs
: Fix coding style.composer analyse
: Run larastan.composer test
: Run pestphp.composer sec
: Check the php libraries.composer code
: Runcs
,analyse
,test
andsec
.composer doc
: Generate the api documentation.
by CodeHappy ;)