DDD & Hexagonal Architecture with Laravel
Implementing Domain Driven Design and Hexagonal Architecture example API using Laravel.
Installing:
- Clone repository:
git clone https://github.com/fSchettino/ddd-hexagonal-architecture-laravel.git
. - Move to project folder:
cd ddd-hexagonal-architecture-laravel
. - Duplicate .env.example file and set your variables.
- Install project dependencies:
composer install
. - Generate encryption key:
php artisan key:generate
. - Create a new schema in your database.
- Execute migration:
php artisan migrate
. - Start server:
php artisan serve
.
Tests:
Run: php artisan test
.
API endpoints:
Create a new user:
POST - http://127.0.0.1:8000/api/user
Body object:
{
"name": "Firstname Lastname",
"email": "[email protected]",
"password": "password_example"
}
-------------------------------------------
Get created user:
GET - http://127.0.0.1:8000/api/user/1
-------------------------------------------
Update existing user:
PUT - http://127.0.0.1:8000/api/user/1
Body object:
{
"name": "Name Surname",
"email": "[email protected]"
}
-------------------------------------------
Delete user:
DELETE - http://127.0.0.1:8000/api/user/1