SCRIPT

Streamline Your Development with Laravel API Boilerplate

The Laravel API Boilerplate is designed to simplify your development process with a DDD structure and essential packages pre-installed.

laravel api boilerplate ddd php pest laravel-packages
Streamline Your Development with Laravel API Boilerplate

πŸ“¦ Get Streamline Your Development with Laravel API Boilerplate

v1.x· Open Source· ⭐ 81 stars · Updated Apr 13, 2023

Building a new application can often feel overwhelming, especially when it comes to setting up the framework and architecture. The Laravel API Boilerplate is specifically designed for developers seeking a solid starting point. Featuring a Domain-Driven Design (DDD) structure, this boilerplate comes pre-loaded with commonly used packages, allowing you to focus on what truly matters: creating your application.

What Is Laravel API Boilerplate?

The Laravel API Boilerplate is a starter kit for Laravel projects that emphasizes a clean and organized architecture. By leveraging the DDD approach, it brings business logic and software design closer together, making your application more maintainable and scalable. This boilerplate is perfect for developers looking to kickstart their projects without getting bogged down by initial setup and configuration tasks.

Key Features

  • Domain-Driven Design (DDD): Organizes your application around business domains, improving code clarity and reducing technical debt.
  • API Response Helper: Streamlines API response formatting, ensuring consistency across endpoints.
  • Scribe API Tags: Automatically generates documentation for your APIs, making it easier for other developers to understand your endpoints.
  • Migration Structure: Well-organized migration files align with your DDD structure, facilitating easier database management.
  • Pest Testing Framework: A modern testing framework that simplifies writing and running tests for your application.
  • Laravel Passport: Provides a full OAuth2 server implementation for API authentication.
  • Development Tools: Includes tools like Laravel Telescope and IDE Helper, enhancing the development experience.
  • Global Helpers: Predefined helper functions to speed up common tasks, enhancing productivity.

Installation & Setup

Getting started with the Laravel API Boilerplate is straightforward. Here are the commands you'll need to run:

CODE
composer create-project abd-wazzan/laravel-api-boilerplate api-app

Once the project is created, navigate to the project directory and install the dependencies:

CODE
cd api-app
composer install

Next, create a copy of the environment configuration file:

CODE
cp .env.example .env

Generate your application key with:

CODE
php artisan key:generate 

Finally, to run your application locally, execute:

CODE
php artisan serve

How to Use It

Let’s say you want to create an Invoice feature in your application. You would typically structure your code as follows:

CODE
src/Domain/Invoices/
β”œβ”€β”€ Actions
β”œβ”€β”€ QueryBuilders
β”œβ”€β”€ Collections
β”œβ”€β”€ Data
β”œβ”€β”€ Events
β”œβ”€β”€ Exceptions
β”œβ”€β”€ Listeners
β”œβ”€β”€ Models
β”œβ”€β”€ Rules
└── States

This structure allows you to keep your code organized and easy to navigate. For example, you could create an Invoice model in Models and define business logic in the Actions directory.

Who Should Use Laravel API Boilerplate?

This boilerplate is ideal for developers who are looking to build robust applications using Laravel with a focus on maintainability and scalability. Whether you’re a solo developer or part of a larger team, this structure helps streamline collaboration and improves code quality. It’s particularly beneficial for projects that require a comprehensive API structure.

Final Thoughts

The Laravel API Boilerplate provides a solid foundation for building modern applications while promoting best practices through its DDD structure. With essential packages pre-configured, you can hit the ground running. If you're in the market for a boilerplate that emphasizes organization and scalability, look no further than this repository. It’s not just about starting a project; it’s about setting it up for long-term success.

ScriptForge Admin

Senior developer and curator of the ScriptForge platform. Specializing in PHP, Laravel, and full-stack JavaScript development.

gh
𝕏
🌐

Related Scripts