Laravel API Boilerplate designed for developers who want to kickstart projects using Laravel as a backend API. Whether you're building a Single Page Application (SPA), a mobile app, or integrating with third-party systems, this boilerplate provides a robust and scalable foundation.
Out-of-the-box, it includes REST API authentication powered by Laravel Sanctum, MySQL integration, and best practices for API development. It is built using Laravel 11, the latest version, to leverage the most recent features and improvements.
- RESTful API: Structured and clean RESTful API endpoints.
- API Versioning: Structure API with versioning (e.g.,
/api/v1
). - Authentication: Token-based authentication using Laravel Sanctum.
- User Management: Pre-built endpoints for user registration, login, logout, and password reset.
- MySQL Integration: Ready-to-use MySQL database schema for seamless integration.
- Error Handling: Centralized error handling for consistent API responses.
- Localization: Multilingual support for error messages and responses.
Library | Category | Version | Description |
---|---|---|---|
Laravel | Framework | v11.36.1 | The best cross-platform framework |
JSONAPI | Package | v5.0.2 | Feature-rich JSON:API compliant APIs for Laravel applications. |
Laravel Media Library | Package | v11.11 | Package can associate all sorts of files with Eloquent models |
Scribe | Package | v4.38.0 | Package to generate API documentation |
-
Clone the repository:
git clone https://github.com/AlaaKanaan/laravel-boilerplate-api.git cd laravel-boilerplate-api
-
Install dependencies:
composer install
-
Set up the
.env
file:cp .env.example .env
-
Generate the application key:
php artisan key:generate
-
Configure your database in the
.env
file and run migrations:php artisan migrate --seed
-
Serve the application:
php artisan serve
- Single Page Applications (SPAs): A seamless backend for SPAs built with frameworks like Vue.js, React.js, or Angular.
- Mobile Apps: Fully compatible with mobile app development using Flutter, React Native, Swift, or Kotlin.
- Third-Party Integration: Easily expose APIs for other systems to consume.
- Microservices: Use as a boilerplate service in a larger microservice architecture.
Consider adding the following features to expand the boilerplate's functionality:
- Database Options: Add support for MongoDB, PostgreSQL, or SQLite.
- Role and Permission Management: Integrate a package like Spatie Laravel Permissions.
- OAuth2 Authentication: Add Laravel Passport for advanced use cases.
- File Uploads: Include endpoints for handling file uploads (e.g., images or documents).
- WebSocket Support: Add real-time functionality using Laravel WebSockets.
- Localization: Multilingual support for error messages and responses.
- Audit Logs: Log user activities and API usage.
- Rate Limiting by User Role: Customize rate limiting rules for different user roles.
- API Metrics Dashboard: Build a simple dashboard to monitor API usage and performance.
This project includes auto-generated API documentation using Scribe. Access the documentation at:
/docs/index.html
Contributions are welcome! Submit a pull request or create an issue to suggest features or report bugs.
This project is open-sourced software licensed under the MIT license.