https://github.com/wayofdev/laravel-starter-tpl
🚀 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.
https://github.com/wayofdev/laravel-starter-tpl
boilerplate ddd laravel laravel-api laravel-application laravel-boilerplate laravel-ddd laravel-package laravel-starter-kit laravel-starter-template php starter-kit starter-project starter-template
Last synced: about 1 year ago
JSON representation
🚀 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.
- Host: GitHub
- URL: https://github.com/wayofdev/laravel-starter-tpl
- Owner: wayofdev
- License: mit
- Created: 2023-05-03T12:17:27.000Z (about 3 years ago)
- Default Branch: develop
- Last Pushed: 2025-03-19T23:40:37.000Z (about 1 year ago)
- Last Synced: 2025-04-12T00:16:12.081Z (about 1 year ago)
- Topics: boilerplate, ddd, laravel, laravel-api, laravel-application, laravel-boilerplate, laravel-ddd, laravel-package, laravel-starter-kit, laravel-starter-template, php, starter-kit, starter-project, starter-template
- Language: PHP
- Homepage: https://wayof.dev
- Size: 1.79 MB
- Stars: 9
- Watchers: 1
- Forks: 2
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# Laravel Starter Template
This is an **opinionated** modified version of the Laravel framework which aims at providing a Domain-Driven Design (DDD) structure.
## 📄 About
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!
## 🚀 Features
This starter template includes several added, changed, and removed features:
### → Framework Modifications
* **Added:**
* Strict types declaration in all PHP files
* Application dockerization using docker-compose and Makefile — use `make help` to view available commands
* [spatie/laravel-route-attributes](https://github.com/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
* **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
### → Development Tools
* **Added:**
* Style checker package for custom rule-sets to php-cs-fixer — [wayofdev/php-cs-fixer-config](https://github.com/wayofdev/php-cs-fixer-config)
* [Phive](https://github.com/phar-io/phive) support for managing PHP tools
* [ergebnis/composer-normalize](https://github.com/ergebnis/composer-normalize) composer plugin for normalizing composer.json file
* [maglnet/ComposerRequireChecker](https://github.com/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 help` to view available commands
* [docker-php-dev](https://github.com/wayofdev/docker-php-dev) as PHP development environment with XDebug support out of the box
### → Testing
* **Added:**
* Configured [PHPUnit](https://phpunit.de/index.html) for unit testing.
* Integrated [Pest PHP](https://pestphp.com) for elegant console support and architecture testing.
* [Infection](https://github.com/infection/infection) for mutation testing to ensure quality.
* Mutation test reports are uploaded [Stryker Mutator Dashboard](https://dashboard.stryker-mutator.io).
### → Static Analysis
* **Added:**
* Static analysis tool — [PHPStan](https://phpstan.org) and it's extensions:
* [phpstan/extension-installer](https://github.com/phpstan/extension-installer) — automatic installation of PHPStan extensions
* [phpstan/phpstan-deprecation-rules](https://github.com/phpstan/phpstan-deprecation-rules) — rules for detecting usage of deprecated classes, methods, properties, constants and traits.
* [larastan/larastan](https://github.com/larastan/larastan) for Laravel-specific static analysis.
* [Psalm](https://github.com/vimeo/psalm) static analysis tool and it's extensions:
* [psalm/plugin-laravel](https://github.com/psalm/psalm-plugin-laravel) — Psalm plugin for Laravel
* [psalm/plugin-phpunit](https://github.com/psalm/psalm-plugin-phpunit) — Psalm plugin for PHPUnit
* [PHP Rector](https://github.com/rectorphp/rector) for automated code upgrades and refactoring, maintaining modern code standards.
### → Continuous Integration
* **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 using [pre-commit](https://pre-commit.com) package
### → Deployments
* **Added:**
* [Deployer](https://deployer.org) for automatic deployments to staging and production servers with support of [GitHub Environments](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment)
* For more information see [Deployments](#-deployment-to-staging-and-production) section
## 🚩 Requirements
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:
* [How To Install and Use Docker on Ubuntu 22.04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-22-04)
* [How To Install Docker Desktop on Mac](https://docs.docker.com/desktop/install/mac-install/)
* **Cloned, configured and running** [docker-shared-services](https://github.com/wayofdev/docker-shared-services) to support system-wide DNS, routing, and TLS support via Traefik.
## 💿 Installation
> [!Note]
> You should configure, set up, and run the [docker-shared-services](https://github.com/wayofdev/docker-shared-services) repository to ensure system-wide TLS and DNS support.
### → Docker Shared Services
Check full instructions in [docker-shared-services](https://github.com/wayofdev/docker-shared-services) repository.
1. **Create shared project directory:**
```bash
mkdir -p ~/projects/infra && cd ~/projects/infra
```
2. **Clone `docker-shared-services` repository:**
```bash
git clone \
git@github.com:wayofdev/docker-shared-services.git \
~/projects/infra/docker-shared-services && \
cd ~/projects/infra/docker-shared-services
```
3. **Create `.env` file:**
```bash
make env
```
4. **Install root certificate** and generate default project certs:
```bash
make cert-install
```
5. **Run shared services:**
```bash
make up
```
### → Laravel Starter Template
1. **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.
```bash
git clone \
git@github.com:wayofdev/laravel-starter-tpl.git \
~/projects/laravel-starter-tpl && \
cd ~/projects/laravel-starter-tpl
```
2. **Generate** `.env` file
Generate `.env` file from `.env.example` file using `Makefile` command:
```bash
$ 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:
```bash
$ make env \
APP_NAME=laravel \
SHARED_SERVICES_NAMESPACE=ss \
COMPOSE_PROJECT_NAME=laravel-starter-tpl \
FORCE=true
```
3. **Build**, install and run. This will also generate Laravel app key:
```bash
$ make
# or run commands separately
$ make hooks
$ make install
$ make key
$ make prepare
$ make up
```
4. **Open** your browser and navigate to `https://laravel-starter-tpl.docker` to see Laravel welcome page.
## 🧰 Project Architecture
The project architecture of `wayofdev/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 check [deptrac.yaml](https://github.com/wayofdev/laravel-starter-tpl/blob/develop/app/deptrac.yaml) located in repository `app` folder.
### → Architecture Diagram

## 🤖 Deployment to Staging and Production
This repository utilizes GitHub Actions for continuous deployment to both staging and production servers. Below is a description.
### → Deployment Flow
#### Deployment to Staging
1. **Push to `develop` branch**: Initiates the deployment process to the staging server. Merge PR against `develop` branch, to trigger `deploy-staging.yml`
2. **GitHub Actions**: Executes the `deploy-staging.yml` workflow.
3. **Staging Server**: Receives deployment instructions and acknowledges the deployment.
#### Deployment to Production
1. **Merge of `develop` branch into `master`**: Triggers the deployment process to the production server on push event.
2. **GitHub Actions**: Runs the `create-release.yml` workflow.
3. **Release Event**: `deploy-release.yml` waits for the event `release: released`.
4. **GitHub Actions**: Initiates the `deploy-release.yml` workflow.
5. **Production Server**: Receives deployment instructions and acknowledges the deployment.
#### Conditional Deployment Status
* **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.
#### Diagram

## 🧱 Credits and Useful Resources
Useful resources about Laravel and DDD approach:
* [Laravel Beyond CRUD](https://spatie.be/products/laravel-beyond-crud)
## 🔒 Security Policy
This project has a [security policy](.github/SECURITY.md).
## 🙌 Want to Contribute?
Thank you for considering contributing to the wayofdev community! We are open to all kinds of contributions. If you want to:
* 🤔 [Suggest a feature](https://github.com/wayofdev/laravel-starter-tpl/issues/new?assignees=&labels=type%3A+enhancement&projects=&template=2-feature-request.yml&title=%5BFeature%5D%3A+)
* 🐛 [Report an issue](https://github.com/wayofdev/laravel-starter-tpl/issues/new?assignees=&labels=type%3A+documentation%2Ctype%3A+maintenance&projects=&template=1-bug-report.yml&title=%5BBug%5D%3A+)
* 📖 [Improve documentation](https://github.com/wayofdev/laravel-starter-tpl/issues/new?assignees=&labels=type%3A+documentation%2Ctype%3A+maintenance&projects=&template=4-docs-bug-report.yml&title=%5BDocs%5D%3A+)
* 👨💻 Contribute to the code
You are more than welcome. Before contributing, kindly check our [contribution guidelines](.github/CONTRIBUTING.md).
[](https://conventionalcommits.org)
## 🫡 Contributors
## 🌐 Social Links
* **Twitter:** Follow our organization [@wayofdev](https://twitter.com/intent/follow?screen_name=wayofdev) and the author [@wlotyp](https://twitter.com/intent/follow?screen_name=wlotyp).
* **Discord:** Join our community on [Discord](https://discord.gg/CE3TcCC5vr).
## ⚖️ License
[](./LICENSE.md)