This repository provides a boilerplate for creating RESTful APIs using Laravel 11, with a focus on clean, maintainable code. It leverages Actions, Data Transfer Objects (DTOs), and best practices to ensure a scalable architecture.
- RESTful API: Preconfigured routes and controllers for building APIs.
- Actions: Separate business logic into single-responsibility classes.
- DTOs: Manage data flow between layers of the application.
- Clean Code: Emphasis on readability, reusability, and performance.
- Laravel 11: Leverage the latest features and enhancements in Laravel.
- PHP 8.2 or higher
- Composer
- Laravel 11.x
- MySQL or any other supported database
-
Clone the repository:
git clone https://github.com/holiq/api-boilerplate.git
-
Navigate to the project directory:
cd api-boilerplate
-
Install dependencies:
composer install --prefer-dist
-
Set up environment variables:
Copy the
.env.example
file to.env
and configure your database settings.cp .env.example .env
-
Generate application key:
php artisan key:generate
-
Run migrations:
php artisan migrate
Start the development server:
php artisan serve
The API will be accessible at http://localhost:8000/api
.
- Routes: Define your API routes in
routes/api.php
. - Controllers: Implement your API logic using controllers located in
app/Http/Controllers
. - Actions: Organize business logic in
app/Actions
and use commandmake:action {name}
for generate the action. - DTOs: Use Data Transfer Objects in
app/DataTransferObjects
and use commandmake:dto {name}
for generate the DTOs.
Contributions are welcome! Please fork this repository and submit a pull request for any enhancements or bug fixes.