PHP with DDD in Symfony
PHP project based on Symfony skeleton with some components and tools to build a solid application following clean architecture. The environment is built with Docker which contains the components to run the application without external dependencies.
The project only requires to have installed Docker and Docker Compose in order to start working on it.
-
Create a copy of
.env.example
as.env
and assign values toAPP_SECRET
andMYSQL_ROOT_PASSWORD
cp .env.example .env
-
Build and start docker containers
docker compose build --no-cache --pull && docker compose up -d
-
Install composer dependencies
docker exec php sh -c 'composer install'
-
Execute all DB migrations.
docker exec php sh -c 'php bin/console doctrine:migrations:migrate -n'
-
(Optional) Import seeder.
docker exec -i mysql sh -c 'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD" storage' < seeder/database_seeder_data.sql
-
Use the desired service.
-
Endpoints accessible
GET http://localhost:8000/api/activities
activity_type: "AEROBIC" (string)
Examples: http://localhost:8000/api/activities?activity_type=BALANCE http://localhost:8000/api/activities
HTTPStatus: 200
[
{
"id": 8,
"activity_type": "BALANCE",
"name": "One-leg stand",
"description": "Start by standing facing the wall, with your arms outstretched."
}
]
GET http://localhost:8000/api/activities/{id}
id: 1 (integer)
Example: http://localhost:8000/api/1
HTTPStatus: 200
{
"id": 1,
"activity_type": "AEROBIC",
"name": "Running",
"description": "Running is for the cowards"
}
http://localhost:8000/api/activities
POST http://localhost:8000/api/activities
{
"activity_type": "FLEXIBILITY",
"name": "strecth",
"description": "Walking is a type of exercise where you walk"
}
Example: http://localhost:8000/api/activities
HTTPStatus: 200
Resource Created