Laravel启动器

laravel-starter-tpl — Laravel 启动器模板

作者 wayofdev

wayofdev 维护的 Laravel 启动器模板,将默认结构改为 DDD 分层,并集成 PHPUnit、Pest、PHPStan、Psalm、Deptrac、Deployer 与 Docker 开发环境。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

2 个预览视图
桌面端首页1 / 2
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 2

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-02查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

将 Laravel 默认结构改造为接近 DDD 的分层架构,包含 Domain、Bridge、Infrastructure、Support 等层

02

集成 PHPUnit、Pest PHP 与 Infection 变异测试,并上传报告到 Stryker Mutator Dashboard

03

配置 PHPStan(含 larastan)与 Psalm 两套静态分析工具,以及 Rector 自动化重构

04

通过 docker-compose 与 Makefile 完成应用容器化,依赖 docker-shared-services 提供本地 SSL 与 DNS

05

使用 Deployer 与 GitHub Environments 支持 staging 和 production 自动部署

06

提供 GitHub Actions CI 工作流与 pre-commit 钩子,覆盖编码规范、测试与静态分析

模板详细介绍

这是一个基于 Laravel 的启动器模板,定位为「有明确取向」的框架改造版本。它把 Laravel 默认的文件结构改为接近领域驱动设计(DDD)的分层方式,目的是让业务逻辑与基础设施代码分离,缓解 Eloquent 活动记录模式在 DDD 场景下的结构冲突。模板参考了 Spatie 的 Laravel Beyond CRUD 实践。

在框架层面,模板为所有 PHP 文件添加严格类型声明,把默认 Laravel 类标记为 final,调整配置文件注释风格,并移除 Sanctum、Pint、Sail、广播服务提供者及其路由、控制台路由和 Sanctum 迁移文件;同时引入 spatie/laravel-route-attributes,用 PHP 8 属性方式定义路由。

工程化方面,模板配置了 PHPUnit 与 Pest PHP 用于单元测试和架构测试,加入 Infection 做变异测试并上传报告到 Stryker Mutator Dashboard;静态分析使用 PHPStan(含 larastan、弃用规则、扩展安装器)和 Psalm(含 Laravel 与 PHPUnit 插件),并用 Rector 做自动化代码升级与重构。代码风格由 php-cs-fixer 配合 wayofdev/php-cs-fixer-config 规则集处理,Phive 用于管理 PHP 工具,pre-commit 提供 Git 提交前钩子。CI 由 GitHub Actions 承担,包含编码规范检查、单元测试、静态分析和自动 PR 标签;部署使用 Deployer,支持 GitHub Environments 的 staging 与 production 流程。

架构上,项目分为 Domain、Bridge、Infrastructure、Support、DatabaseSeeders、DatabaseFactories、Tests 等层,各层有明确依赖方向。使用前需要满足特定环境要求:macOS Monterey+、Linux 或带 WSL2 的 Windows,Docker 26.0.0 或更新版本,并且必须克隆、配置并运行 docker-shared-services 仓库,以通过 Traefik 提供系统级 DNS、路由和 TLS 支持。安装流程依赖 Makefile 命令生成 .env、安装依赖、生成应用密钥并启动容器,最终通过 https://laravel-starter-tpl.docker 访问。

该模板采用 MIT 许可,可免费使用、修改、商用和分发代码,但需保留版权声明与许可声明;演示图片、字体、图标等第三方素材以及域名、托管、数据库等外部服务需另行核对或可能产生费用。

Laravel启动器

适合你的项目吗?

适用场景

  • 希望以 DDD 分层方式组织 Laravel 业务代码,而不是使用默认目录结构的新项目
  • 需要在项目初期就具备单元测试、变异测试、静态分析与代码风格检查的团队
  • 希望通过 Docker 与 Makefile 统一本地开发环境,并使用本地 HTTPS 域名访问应用
  • 需要借助 Deployer 和 GitHub Environments 搭建 staging 与 production 部署流程的项目
  • 想参考 Spatie Laravel Beyond CRUD 实践来设计 Laravel 项目结构的开发者

适合人群

  • 熟悉 Laravel 并接受 DDD 分层约定的后端开发者
  • 需要开箱即用质量工具链(测试、静态分析、CI)的团队
  • 使用 Docker 工作流并愿意先部署 docker-shared-services 的开发者
  • 需要 staging/production 自动部署配置的项目维护者

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    需要 macOS Monterey+、Linux 或带 WSL2 的 Windows,以及 Docker 26.0.0 或更新版本

  2. 2

    必须先克隆、配置并运行 docker-shared-services 仓库,以提供系统级 DNS、路由和 TLS 支持

  3. 3

    使用 Makefile 命令生成 .env 文件,可传入 APP_NAME、SHARED_SERVICES_NAMESPACE、COMPOSE_PROJECT_NAME 等参数

  4. 4

    执行 make 或分步运行 make hooks、make install、make key、make prepare、make up 完成构建与启动

  5. 5

    启动后通过 https://laravel-starter-tpl.docker 访问 Laravel 欢迎页

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发该版本代码。
  • 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 使用前必须克隆、配置并运行独立的 docker-shared-services 仓库,以通过 Traefik 提供系统级 DNS、路由与 TLS 支持,否则本地环境无法正常解析域名和启用 HTTPS。
  • 安装说明再次强调需先配置并运行 docker-shared-services 仓库,才能获得系统级 TLS 与 DNS 支持,属于使用该模板的前置外部依赖。
  • 要求 Docker 版本为 26.0.0 或更新,低于该版本的 Docker 环境无法按文档流程运行。
  • 仅支持 macOS Monterey 及以上、Linux,或带 WSL2 的 Windows;其他操作系统环境不在支持范围内。
  • staging 与 production 自动部署依赖 GitHub Actions 及 GitHub Environments,需在 GitHub 平台上配置相应环境与密钥,属于外部服务依赖。
  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

**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.

README 原文

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.

README 原文

**Docker**: Version 26.0.0 or newer.

README 原文

**Operating System**: macOS Monterey+, Linux, or Windows with WSL2.

README 原文

This repository utilizes GitHub Actions for continuous deployment to both staging and production servers.

README 原文
https://github.com/wayofdev/laravel-starter-tpl/blob/develop/LICENSE.mdhttps://github.com/wayofdev/laravel-starter-tpl/blob/develop/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-03。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
GitHub
资料与维护参考分
资料较完整 · 87 / 100
技术栈
Laravel
网站类型
启动器
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2026-10-01
截图检查日期
2026-10-03

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Laravel。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

审核声明: [email protected] · 2026-10-04

查看当时使用的来源资料

SHA-256: 2c3695b0c0a02ccd2cff4d78be49d10d04ae8b213833b61d433e84dcaee0fe7d

2026-10-03T19:21:33.354Z

来源文件 / 仓库
<p align="center">
    <br>
    <a href="https://wayof.dev" target="_blank">
        <picture>
            <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/wayofdev/.github/master/assets/logo.gh-dark-mode-only.png">
            <img width="400" src="https://raw.githubusercontent.com/wayofdev/.github/master/assets/logo.gh-light-mode-only.png" alt="WayOfDev Logo">
        </picture>
    </a>
    <br>
</p>

<p align="center">
    <strong>Build</strong><br>
    <a href="https://actions-badge.atrox.dev/wayofdev/laravel-starter-tpl/goto" target="_blank"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fwayofdev%2Flaravel-starter-tpl%2Fbadge&style=flat-square&label=github%20actions"/></a>
    <a href="https://github.com/wayofdev/laravel-starter-tpl/actions/workflows/deploy-staging.yml?query=workflow%3ADeploy" target="_blank"><img alt="Deploy to Staging Status" src="https://img.shields.io/github/actions/workflow/status/wayofdev/laravel-starter-tpl/deploy-staging.yml?branch=develop&style=flat-square&label=deploy%20to%20staging&logo=github"/></a>
    <a href="https://github.com/wayofdev/laravel-starter-tpl/actions/workflows/deploy-release.yml?query=workflow%3ADeploy" target="_blank"><img alt="Deploy to Production Status" src="https://img.shields.io/github/actions/workflow/status/wayofdev/laravel-starter-tpl/deploy-release.yml?style=flat-square&label=deploy%20to%20prod&logo=github"/></a>
</p>
<p align="center">
    <strong>Project</strong><br>
    <a href="https://github.com/wayofdev/laravel-starter-tpl" target="_blank"><img src="https://img.shields.io/github/v/release/wayofdev/laravel-starter-tpl?style=flat-square" alt="Latest Stable Version"></a>
    <a href="https://github.com/wayofdev/laravel-starter-tpl" target="_blank"><img alt="Commits since latest release" src="https://img.shields.io/github/commits-since/wayofdev/laravel-starter-tpl/latest?style=flat-square"></a>
    <a href="https://github.com/wayofdev/laravel-starter-tpl" target="_blank"><img alt="PHP Version Require" src="https://poser.pugx.org/wayofdev/laravel-package-tpl/require/php?style=flat-square"></a>
</p>
<p align="center">
    <strong>Quality</strong><br>
    <a href="https://app.codecov.io/gh/wayofdev/laravel-starter-tpl" target="_blank"><img alt="Codecov" src="https://img.shields.io/codecov/c/github/wayofdev/laravel-starter-tpl?style=flat-square&logo=codecov"></a>
    <a href="https://dashboard.stryker-mutator.io/reports/github.com/wayofdev/laravel-starter-tpl/develop" target="_blank"><img alt="Mutation testing badge" src="https://img.shields.io/endpoint?style=flat-square&label=mutation%20score&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fwayofdev%2Flaravel-starter-tpl%2Fmaster"></a>
    <a href=""><img src="https://img.shields.io/badge/phpstan%20level-8%20of%209-brightgreen?style=flat-square" alt="PHP Stan Level 8 of 9"></a>
</p>
<p align="center">
    <strong>Community</strong><br>
    <a href="https://discord.gg/CE3TcCC5vr" target="_blank"><img alt="Discord" src="https://img.shields.io/discord/1228506758562058391?style=flat-square&logo=discord&labelColor=7289d9&logoColor=white&color=39456d"></a>
    <a href="https://x.com/intent/follow?screen_name=wayofdev" target="_blank"><img alt="Follow on Twitter (X)" src="https://img.shields.io/badge/-Follow-black?style=flat-square&logo=X"></a>
</p>
<br>

# 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.

<br>

🙏 If you find this repository useful, consider giving it a ⭐️. Thank you!

<br>

## 🚀 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

<br>

## 🚩 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.

<br>

## 💿 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 \
    [email protected]: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 \
     [email protected]: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.

<br>

## 🧰 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

![Architecture Diagram](.github/assets/deptrac.svg)

<br>

## 🤖 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

![deployments](.github/assets/deployments.png)

<br>

## 🧱 Credits and Useful Resources

Useful resources about Laravel and DDD approach:

* [Laravel Beyond CRUD](https://spatie.be/products/laravel-beyond-crud)

<br>

## 🔒 Security Policy

This project has a [security policy](.github/SECURITY.md).

<br>

## 🙌 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).

[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=for-the-badge)](https://conventionalcommits.org)

<br>

## 🫡 Contributors

<p align="left">
<a href="https://github.com/wayofdev/laravel-starter-tpl/graphs/contributors">
<img align="left" src="https://img.shields.io/github/contributors-anon/wayofdev/laravel-starter-tpl?style=for-the-badge" alt="Contributors Badge"/>
</a>
<br>
<br>
</p>

## 🌐 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).

<br>

## ⚖️ License

[![Licence](https://img.shields.io/github/license/wayofdev/laravel-starter-tpl?style=for-the-badge&color=blue)](./LICENSE.md)

<br>
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。