PHPackages                             abd-wazzan/laravel-api-boilerplate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. abd-wazzan/laravel-api-boilerplate

ActiveProject[Testing &amp; Quality](/categories/testing)

abd-wazzan/laravel-api-boilerplate
==================================

A Laravel project with a Domain-Driven Design (DDD) structure, basic configuration, and commonly used packages pre-installed, directed towards building APIs.

v1.0(3y ago)83529MITPHPPHP ^8.1

Since Mar 28Pushed 3y ago1 watchersCompare

[ Source](https://github.com/abd-wazzan/laravel-api-boilerplate)[ Packagist](https://packagist.org/packages/abd-wazzan/laravel-api-boilerplate)[ RSS](/packages/abd-wazzan-laravel-api-boilerplate/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (1)Dependencies (20)Versions (4)Used By (0)

[![Laravel API Boilerplate](https://user-images.githubusercontent.com/46269541/230351628-f3eb6682-3799-42d9-8e7a-9ab918906f2e.png)](https://user-images.githubusercontent.com/46269541/230351628-f3eb6682-3799-42d9-8e7a-9ab918906f2e.png)

 A [Laravel](https://laravel.com) project with a Domain-Driven Design (DDD) structure, basic configuration, and commonly used packages pre-installed and configured, to help you start building your next big application.

Requirements
============

[](#requirements)

- PHP ^8.1
- Composer ^2.2

Installation
============

[](#installation)

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

Install dependencies

```
cd api-app
composer install
```

Setup .env file

```
cp .env.example .env
```

Generate the application key

```
php artisan key:generate
```

Run Locally

```
php artisan serve
```

Installed Packages
==================

[](#installed-packages)

General:

- [Passport](https://laravel.com/docs/10.x/passport)
- [Laravel Actions](https://laravelactions.com)
- [Laravel Data](https://spatie.be/docs/laravel-data/v3/introduction)
- [Laravel Query Builder](https://spatie.be/index.php/docs/laravel-query-builder/v5/introduction)

Development:

- [Laravel IDE Helper](https://github.com/barryvdh/laravel-ide-helper)
- [Scribe API documentation tool](https://scribe.knuckles.wtf/laravel)
- [Laravel Telescope](https://laravel.com/docs/10.x/telescope)
- [Pest Testing Framework](https://pestphp.com/)
- [Grum PHP](https://github.com/phpro/grumphp)
- [Security Advisor](https://github.com/Roave/SecurityAdvisories)

Features
========

[](#features)

- [DDD (Domain Driven Design)](#ddd)
- [API Response Helper](#api-response-helper)
- [Scribe Api Tags](#scribe-api-tags)
- [Global Helper](#global-helper)
- [Migration Structure](#migration-structure)
- [Polymorphic Mapping](#polymorphic-mapping)
- [Database Seeders](#database-seeders)
- [Shared Directory](#shared-directory)
- [Enable Model Strict Mode](https://laravel.com/docs/10.x/eloquent#configuring-eloquent-strictness)
- [Pest testing framework](https://pestphp.com/docs/installation)

DDD
---

[](#ddd)

Software development approach that tries to bring the business language and the source code as close as possible.

This structure is inspired by [LARAVEL BEYOND CRUD](https://laravel-beyond-crud.com/).

### Files Structure

[](#files-structure)

Domain Layer Example:

```
src/Domain/Invoices/
├── Actions
├── QueryBuilders
├── Collections
├── Data
├── Events
├── Exceptions
├── Listeners
├── Models
├── Rules
└── States
src/Domain/Products/
├── Actions
└── .....

```

Application Layer Example:

```
The REST API application:
src/App/Api/
├── Products
    ├── Controllers
    ├── Middlewares
    ├── Requests
    ├── Queries
    ├── Filters
    └── Resources

The Console application
src/App/Console/
└── Commands

The admin HTTP application:
src/App/Admin/
├── Products
    ├── Controllers
    ├── Middlewares
    ├── Requests
    ├── Resources
    ├── Queries
    ├── Filters
    └── ViewModels

```

### Dependency Illustration

[](#dependency-illustration)

[![](https://camo.githubusercontent.com/ac8011703a73275cd9d113b9e28fb6aaccdd6efc1399738a20cc0c8577f9df4b/68747470733a2f2f6d65726d6169642e696e6b2f696d672f70616b6f3a654e70746b563950776a41557862394b63784d5354415a685f786a7377515257664a4b6767433879487570326c6356746e563258694a547662756c454d50477476656433656d3776505544435534515133675372646d524e343549514d746b3831536932704e653756557638614c4357696b793745532d6c34486d4f676b77536d66487978744254773948315170476f53336e4273764b5048686e3967516c576f455368434f334f64576a657176536b457256367643643149724a4b4a3830326c456e32776d7263476d5457496f384e696a30525744653568756931655f6c546a43364252433071464f7a557871396e65756e586543706531716a49354e72565f734e554f70307a6534637932524854674b4a6e6a6637546c6b344143776f556567717048757668424d636764316867444b452d706b7938787843585238327852764c56766b77676c4b4a4243356f715a524a707876513243676866575637724b71615a35474c6537736d7379344b4b6c632d634632656a766b4a346745384948635f762d383434474e75755a3439747833597432454d34437671654637676a4e78674e664e2d7867364d46582d614251585f6f4259345f3948335844747a423048654f3333337a6f64773f747970653d706e67)](https://mermaid.live/edit#pako:eNptkV9PwjAUxb9KcxMSTAZh_xjswQRWfJKggC8yHup2lcVtnV2XiJTvbulEMPGtved3em7vPUDCU4QQ3gSrdmRN45IQMtk81Si2pNe7VUv8aLCWiky7ES-l4HmOgkwSmfHyxtBTw9H1QpGoS3nBsvKPHhn9gQlWoEShCO3OdWjeqvSkErV6vCd1IrJKJ802lEn2wmrcGmTWIo8Nij0RWDe5hui1e_lTjC6BRC0qFOzUxq9neunXeCpe1qjI5NrV_sNUOp0ze4cy2RHTgKJnjf7Tlk4ACwoUegqpHuvhBMcgd1hgDKE-pky8xxCXR82xRvLVvkwglKJBC5oqZRJpxvQ2CghfWV7rKqaZ5GLe7smsy4KKlc-cF2ejvkJ4gE8IHc_v-844GNuuZ49tx3Yt2EM4CvqeF7gjNxgNfN-xg6MFX-aBQX_oBY4_9H3XDtzB0HeO333zodw)

### Resources

[](#resources)

- [Domain Oriented Laravel](https://stitcher.io/blog/laravel-beyond-crud-01-domain-oriented-laravel)
- [Working With Data](https://stitcher.io/blog/laravel-beyond-crud-02-working-with-data)
- [Actions](https://stitcher.io/blog/laravel-beyond-crud-03-actions)
- [Models](https://stitcher.io/blog/laravel-beyond-crud-04-models)
- [States](https://stitcher.io/blog/laravel-beyond-crud-05-states)
- [Managing Domains](https://stitcher.io/blog/laravel-beyond-crud-06-managing-domains)
- [Application Layer](https://stitcher.io/blog/laravel-beyond-crud-07-entering-the-application-layer)
- [View Models](https://stitcher.io/blog/laravel-beyond-crud-08-view-models)
- [Test Factories](https://stitcher.io/blog/laravel-beyond-crud-09-test-factories)

API Response Helper
-------------------

[](#api-response-helper)

A simple trait allowing consistent API responses throughout your Laravel application.

### Available methods:

[](#available-methods)

MethodStatus`okResponse()``200``createdResponse()``201``failedResponse()``400``unauthorizedResponse()``401``forbiddenResponse()``403``notFoundResponse()``404``unprocessableResponse()``422``serverErrorResponse()``500`### Usages Example:

[](#usages-example)

```
