Skip to content
/ api-boilerplate Public template

Boilerplate rest api on Laravel with Actions DTOs and clean code

Notifications You must be signed in to change notification settings

holiq/api-boilerplate

Repository files navigation

Laravel API Boilerplate

Laravel Version PHP Version License

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.

Features

  • 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.

Getting Started

Prerequisites

  • PHP 8.2 or higher
  • Composer
  • Laravel 11.x
  • MySQL or any other supported database

Installation

  1. Clone the repository:

    git clone https://github.com/holiq/api-boilerplate.git
  2. Navigate to the project directory:

    cd api-boilerplate
  3. Install dependencies:

    composer install --prefer-dist
  4. Set up environment variables:

    Copy the .env.example file to .env and configure your database settings.

    cp .env.example .env
  5. Generate application key:

    php artisan key:generate
  6. Run migrations:

    php artisan migrate

Running the API

Start the development server:

php artisan serve

The API will be accessible at http://localhost:8000/api.

Usage

  • 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 command make:action {name} for generate the action.
  • DTOs: Use Data Transfer Objects in app/DataTransferObjects and use command make:dto {name} for generate the DTOs.

Contributing

Contributions are welcome! Please fork this repository and submit a pull request for any enhancements or bug fixes.

About

Boilerplate rest api on Laravel with Actions DTOs and clean code

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published