This is a Best Laravel API boilerplate project with pre-configured authentication, authorization, and other common features.
- Laravel 11.x
- User Authentication (Laravel Sanctum)
- Role-based Authorization (Spatie Laravel-permission)
- Google OAuth Integration
- API Routes for User Management
- Database Migrations and Seeders
- Docker Configuration
- PHP 8.2+
- Composer
- Docker (optional)
-
Clone the repository:
git clone [email protected]:hironate/laravel-api-boilerplate.git cd laravel-api-boilerplate
-
Install dependencies:
composer install
-
Copy the
.env.example
file to.env
and configure your environment variables:cp .env.example .env
-
Generate application key:
php artisan key:generate
-
Run migrations and seeders:
php artisan migrate --seed
This project includes a Docker configuration for easy setup. To use Docker:
-
Make sure Docker and Docker Compose are installed on your system.
-
Build and start the containers:
docker-compose up -d --build
-
The application will be available at
http://localhost:8000
.
The API routes are defined in the following files:
routes/api.php
routes/user.php
This project uses Laravel Sanctum for API authentication. The authentication routes and controllers are located in:
app/Http/Controllers/Api/Auth/AuthController.php
routes/api.php
Role-based authorization is implemented using Spatie's Laravel-permission package. Roles and permissions can be managed through the UserAndRoleSeeder
:
Google OAuth is configured for user authentication. Make sure to set up your Google OAuth credentials in the .env
file:
Run the tests using PHPUnit:
php artisan test
This project is licensed under the MIT License. See the LICENSE
file for more details.