Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork4
🚀 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.
License
wayofdev/laravel-starter-tpl
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This is anopinionated 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:
- Strict types declaration in all PHP files
- Application dockerization using docker-compose and Makefile — use
make helpto view available commands - spatie/laravel-route-attributes package for route definition using PHP8 style attributes
Changed:
- Marked default Laravel classes as
final - Modified file structure to meet DDD principles (as close as possible)
- Changed config folder files to use default PHP multi-line comment style
- Marked default Laravel classes as
Removed:
- Dependencies like Laravel Sanctum, Laravel Pint, and Laravel Sail
- Broadcasting service provider and its routes. It can be added back if required for the project
- Console routes in favor of Command classes
- Sanctum migration files
- Added:
- Style checker package for custom rule-sets to php-cs-fixer —wayofdev/php-cs-fixer-config
- Phive support for managing PHP tools
- ergebnis/composer-normalize composer plugin for normalizing composer.json file
- maglnet/ComposerRequireChecker to check whether a specific composer package uses imported symbols that aren't part of its direct composer dependencies
- Application dockerization using docker-compose and Makefile — use
make helpto view available commands- docker-php-dev as PHP development environment with XDebug support out of the box
- Added:
- ConfiguredPHPUnit for unit testing.
- IntegratedPest PHP for elegant console support and architecture testing.
- Infection for mutation testing to ensure quality.
- Mutation test reports are uploadedStryker Mutator Dashboard.
- Added:
- Static analysis tool —PHPStan and it's extensions:
- phpstan/extension-installer — automatic installation of PHPStan extensions
- phpstan/phpstan-deprecation-rules — rules for detecting usage of deprecated classes, methods, properties, constants and traits.
- larastan/larastan for Laravel-specific static analysis.
- Psalm static analysis tool and it's extensions:
- psalm/plugin-laravel — Psalm plugin for Laravel
- psalm/plugin-phpunit — Psalm plugin for PHPUnit
- PHP Rector for automated code upgrades and refactoring, maintaining modern code standards.
- Static analysis tool —PHPStan and it's extensions:
- Added:
- GitHub action workflows for:
- Continuous integration which includes coding standards checks, unit testing and static analysis
- Automatic pull-request labeling
- Git pre-commit hooks usingpre-commit package
- GitHub action workflows for:
- Added:
- Deployer for automatic deployments to staging and production servers with support ofGitHub Environments
- For more information seeDeployments section
To use this repository, you need to meet the following requirements:
- Operating System: macOS Monterey+, Linux, or Windows with WSL2.
- Docker: Version 26.0.0 or newer. Installation guides:
- Cloned, configured and runningdocker-shared-services to support system-wide DNS, routing, and TLS support via Traefik.
Note
You should configure, set up, and run thedocker-shared-services repository to ensure system-wide TLS and DNS support.
Check full instructions indocker-shared-services repository.
Create shared project directory:
mkdir -p~/projects/infra&&cd~/projects/infra
Clone
docker-shared-servicesrepository:git clone \git@github.com:wayofdev/docker-shared-services.git \~/projects/infra/docker-shared-services&& \cd~/projects/infra/docker-shared-services
Create
.envfile: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-tplrepository as starting point.git clone \ git@github.com:wayofdev/laravel-starter-tpl.git \~/projects/laravel-starter-tpl&& \cd~/projects/laravel-starter-tpl
Generate
.envfileGenerate
.envfile from.env.examplefile usingMakefilecommand:$ make env \ APP_NAME=laravel \ SHARED_SERVICES_NAMESPACE=ss \ COMPOSE_PROJECT_NAME=laravel-starter-tpl
Change generated
.envfile to match your needs, if needed.(Optional): to re-generate
.envfile, addFORCE=trueto 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 upOpen your browser and navigate to
https://laravel-starter-tpl.dockerto see Laravel welcome page.
The project architecture ofwayofdev/laravel-starter-tpl follows a structured approach with distinct layers:
- Domain: Contains core business logic and entities.
- Bridge: Connects the domain layer with external systems or services.
- Infrastructure: Handles interactions with external systems, such as databases, APIs, or file systems.
- Support: Provides general-purpose helper classes that assist various parts of the application.
- DatabaseSeeders: Handles database seeding logic.
- DatabaseFactories: Manages database factory definitions.
- Tests: Contains test cases for various layers of the application.
Each layer has defined dependencies, ensuring a clear separation of concerns and facilitating maintainability and scalability.
For more information checkdeptrac.yaml located in repositoryapp folder.
This repository utilizes GitHub Actions for continuous deployment to both staging and production servers. Below is a description.
- Push to
developbranch: Initiates the deployment process to the staging server. Merge PR againstdevelopbranch, to triggerdeploy-staging.yml - GitHub Actions: Executes the
deploy-staging.ymlworkflow. - Staging Server: Receives deployment instructions and acknowledges the deployment.
- Merge of
developbranch intomaster: Triggers the deployment process to the production server on push event. - GitHub Actions: Runs the
create-release.ymlworkflow. - Release Event:
deploy-release.ymlwaits for the eventrelease: released. - GitHub Actions: Initiates the
deploy-release.ymlworkflow. - Production Server: Receives deployment instructions and acknowledges the deployment.
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 asecurity policy.
Thank you for considering contributing to the wayofdev community! We are open to all kinds of contributions. If you want to:
- 🤔Suggest a feature
- 🐛Report an issue
- 📖Improve documentation
- 👨💻 Contribute to the code
You are more than welcome. Before contributing, kindly check ourcontribution guidelines.
- Twitter: Follow our organization@wayofdev and the author@wlotyp.
- Discord: Join our community onDiscord.
About
🚀 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.
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.

