π Pre-configured Laravel Project Template. Includes PHPUnit, Pest PHP, PHPStan, Larastan, PHP CS Fixer, and CI tools. Supports OpenAPI, DDD, Deptrac, Deployer, PHP 8.3, Docker, local SSL, and DNS. Enhance development with advanced features and maintain high code quality.
This is an opinionated modified version of the Laravel framework which aims at providing a Domain-Driven Design (DDD) structure.
Laravel is a popular PHP web framework that provides an easy and efficient way to build web applications. However, the default structure of Laravel, coupled with Eloquentβs active record pattern, may not always fit the needs of a project that requires a Domain-Driven Design (DDD) architecture. Eloquentβs active record pattern breaks DDD principles and make it difficult to separate your business logic from your infrastructure code.
This repository provides a modified file structure for Laravel that follows DDD principles and tries to adhere to best practices, such as those outlined in Spatieβs Laravel Beyond CRUD. The goal is to provide a starting point for building Laravel applications using a DDD approach, while still leveraging the power and convenience of the Laravel framework.
π If you find this repository useful, consider giving it a βοΈ. Thank you!
This starter template includes several added, changed, and removed features:
Added:
make help
to view available commandsChanged:
final
Removed:
make help
to view available commands
To use this repository, you need to meet the following requirements:
[!Note]
You should configure, set up, and run the docker-shared-services repository to ensure system-wide TLS and DNS support.
Check full instructions in docker-shared-services repository.
Create shared project directory:
mkdir -p ~/projects/infra && cd ~/projects/infra
Clone docker-shared-services
repository:
git clone \
[email protected]:wayofdev/docker-shared-services.git \
~/projects/infra/docker-shared-services && \
cd ~/projects/infra/docker-shared-services
Create .env
file:
make env
Install root certificate and generate default project certs:
make cert-install
Run shared services:
make up
Clone repository:
After forking or creating generating repository from template, you can clone it to your local machine. In this example we will use laravel-starter-tpl
repository as starting point.
git clone \
[email protected]:wayofdev/laravel-starter-tpl.git \
~/projects/laravel-starter-tpl && \
cd ~/projects/laravel-starter-tpl
Generate .env
file
Generate .env
file from .env.example
file using Makefile
command:
$ make env \
APP_NAME=laravel \
SHARED_SERVICES_NAMESPACE=ss \
COMPOSE_PROJECT_NAME=laravel-starter-tpl
Change generated .env
file to match your needs, if needed.
(Optional): to re-generate .env
file, add FORCE=true
to the end of command:
$ make env \
APP_NAME=laravel \
SHARED_SERVICES_NAMESPACE=ss \
COMPOSE_PROJECT_NAME=laravel-starter-tpl \
FORCE=true
Build, install and run. This will also generate Laravel app key:
$ make
# or run commands separately
$ make hooks
$ make install
$ make key
$ make prepare
$ make up
Open your browser and navigate to https://laravel-starter-tpl.docker
to see Laravel welcome page.
The project architecture of wayofdev/laravel-starter-tpl
follows a structured approach with distinct layers:
Each layer has defined dependencies, ensuring a clear separation of concerns and facilitating maintainability and scalability.
For more information check deptrac.yaml located in repository app
folder.
This repository utilizes GitHub Actions for continuous deployment to both staging and production servers. Below is a description.
develop
branch: Initiates the deployment process to the staging server. Merge PR against develop
branch, to trigger deploy-staging.yml
deploy-staging.yml
workflow.develop
branch into master
: Triggers the deployment process to the production server on push event.create-release.yml
workflow.deploy-release.yml
waits for the event release: released
.deploy-release.yml
workflow.Deployment Successful: Both staging and production servers send a success message back to GitHub Actions. Additionally, a success message is sent to the Slack server.
Deployment Failed: If an error occurs, a failure message is sent back to GitHub Actions. Additionally, a failure message is sent to the Slack server.
Useful resources about Laravel and DDD approach:
This project has a security policy.
Thank you for considering contributing to the wayofdev community! We are open to all kinds of contributions. If you want to:
You are more than welcome. Before contributing, kindly check our contribution guidelines.