A professional API showcasing Laravel best practices for crud, authentication, validation, testing, and clean architecture.
- ✅ RESTful API with versioning (v1)
- ✅ JWT Authentication (Laravel Sanctum)
- ✅ Policies (Authorization logic)
- ✅ Repository Pattern
- ✅ Service Layer
- ✅ Form Request Validation
- ✅ API Resources
- ✅ Comprehensive error handling
- ✅ Pagination & Filtering
- ✅ Soft Deletes
- ✅ Feature & Unit Tests
- ✅ API Documentation
app/
├── Http/
│ ├── Controllers/
│ │ └── Api/
│ │ └── V1/
│ │ ├── AuthController.php
│ │ └── TaskController.php
│ ├── Requests/
│ │ ├── StoreTaskRequest.php
│ │ └── UpdateTaskRequest.php
│ ├── Resources/
│ │ ├── TaskResource.php
│ │ └── TaskCollection.php
├── Models/
│ ├── User.php
│ └── Task.php
├── Services/
│ └── TaskService.php
├── Repositories/
│ ├── Contracts/
│ │ └── TaskRepositoryInterface.php
│ └── Eloquent/
│ └── TaskRepository.php
├── Policies/
│ └── TaskPolicy.php
├── Exceptions/
│ └── ApiHandler.php
└── Traits/
└── ApiResponse.php
database/
├── migrations/
│ ├── 2025_12_01_082837_create_tasks_table.php
├── factories/
│ └── TaskFactory.php
└── seeders/
├── DatabaseSeeder.php
└── TaskSeeder.php
tests/
├── Feature
│ └── TaskTest.php
└── Unit/
└── TaskServiceTest.php
- PHP 8.2+
- Composer
- MySQL 8.0+
git clone https://github.com/fathallah7/laravel-best-practices-api.git
cd laravel-best-practices-api
composer installcp .env.example .env
php artisan key:generateConfigure your .env:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel-best-practices-api
DB_USERNAME=root
DB_PASSWORD=php artisan migrate --seedphp artisan serveAPI will be available at: http://localhost:8000/api/v1
This project is educational. Feel free to fork and learn!
MIT License
⭐ If this helps you learn Laravel best practices, give it a star!