PHPackages                             overtrue/laravel-skeleton - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. overtrue/laravel-skeleton

ActiveProject[API Development](/categories/api)

overtrue/laravel-skeleton
=========================

A Laravel starter project template.

4.0.2(2y ago)14111719[1 issues](https://github.com/overtrue/laravel-skeleton/issues)[9 PRs](https://github.com/overtrue/laravel-skeleton/pulls)MITPHPPHP ^8.1.1

Since Dec 29Pushed 2y ago3 watchersCompare

[ Source](https://github.com/overtrue/laravel-skeleton)[ Packagist](https://packagist.org/packages/overtrue/laravel-skeleton)[ GitHub Sponsors](https://github.com/overtrue)[ RSS](/packages/overtrue-laravel-skeleton/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (14)Versions (19)Used By (0)

Laravel API 基础模板
================

[](#laravel-api-基础模板)

开箱即用的 Laravel API 基础结构。

> 🚨自己用的哈，仅供参考，不提供咨询解答服务。

特点
--

[](#特点)

- DDD（领域模型驱动）结构；
- 内置生成器，一键生成模块；
- 内置 laravel/sanctum 的授权机制；
- 高度完善的控制器、模型、模块模板；
- 集成常用基础扩展；
- 内置模型通用高阶 Traits 封装;
- 自动注册 Policies；
- 内置用户系统和基础接口；
- 内置管理后台接口；

安装
--

[](#安装)

1. 创建项目

```
$ composer create-project overtrue/laravel-skeleton -vvv
```

2. 创建配置文件

```
$ cp .env.example .env
```

3. 创建数据表和测试数据

```
$ php artisan migrate --seed
```

> 这一步将会创建管理员账号 `username:admin / password:changeThis!!` 和一个 demo 设置项。

然后访问 `http://laravel-skeleton.test/api/settings` 将会看到演示的设置项信息。

使用
--

[](#使用)

### 创建新领域

[](#创建新领域)

```
php artisan make:domain Post
```

> 该命令将会创建 `domain/Post` 目录，包含 `Actions`, `Models`, `Policies`, `Filters` 等目录。

### 创建领域类

[](#创建领域类)

所有官方的生成命令都增加了 `-d` 参数，用于指定领域名称，例如：

```
php artisan make:model Post -d Post
```

另外，还有一些自定义的生成命令：

```
php artisan make:action MarkPostAsDraft -d Post
```

### 创建应用类

[](#创建应用类)

```
php artisan make:app Post
php artisan make:endpoint GetPost -a Post
php artisan make:middleware MustBePublished -a Post
php artisan make:request CreatePost -a Post
php artisan make:resource Post -a Post
```

### 内置接口

[](#内置接口)

#### 用户登录（获取 token）

[](#用户登录获取-token)

##### POST /api/auth/login

[](#post-apiauthlogin)

- Request (`application/json`)

```
{
  "username": "admin",
  "password": "changeThis!!"
}
```

- Response 200 (application/json)

```
{
    "type": "bearer",
    "token":"oVFV407i4jSTxjFO2tNxzh8lDaxVLbIkZZiDwjgMSYhvvkbUUXw8y0XgeYtxLAp4paznq0oxSMDdXmco"
}
```

#### 用户注册

[](#用户注册)

##### POST /api/auth/register

[](#post-apiauthregister)

- Request (`application/json`)

```
{
   "username": "demo",
   "password": "123456"
}
```

- Response 200 (`application/json`)

```
{
    "type": "bearer",
    "token":"oVFV407i4jSTxjFO2tNxzh8lDaxVLbIkZZiDwjgMSYhvvkbUUXw8y0XgeYtxLAp4paznq0oxSMDdXmco"
}
```

#### 登出

[](#登出)

##### POST /api/auth/logout

[](#post-apiauthlogout)

- Request (`application/json`) + Headers

```
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1...

```

- Response 204

#### 获取当前登录用户

[](#获取当前登录用户)

##### GET /api/me

[](#get-apime)

- Request (`application/json`) + Headers

```
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1...

```

- Response 200 (`application/json`)

```
{
  "id": 1,
  "username": "admin",
  "nickname": "超级管理员",
  "avatar": "\/img\/default-avatar.png",
  "email": null,
  "gender": "none",
  "phone": null,
  "birthday": null,
  "settings": [],
  "is_admin": true,
  "last_active_at": null,
  "last_refreshed_at": null,
  "banned_at": null,
  "email_verified_at": null,
  "created_at": "2020-03-17T09:37:45.000000Z",
  "updated_at": "2020-03-17T09:37:45.000000Z",
  "deleted_at": null
}
```

❤️ Sponsor me
-------------

[](#heart-sponsor-me)

If you like the work I do and want to support it, [you know what to do ❤️](https://github.com/sponsors/overtrue)

如果你喜欢我的项目并想支持它，[点击这里 ❤️](https://github.com/sponsors/overtrue)

Project supported by JetBrains
------------------------------

[](#project-supported-by-jetbrains)

Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.

[![](https://camo.githubusercontent.com/3cf726e7cdadba47755b7f7ea4227945a92a2fa48aadf4a2573140ec6501c989/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f73746f726167652f70726f64756374732f636f6d70616e792f6272616e642f6c6f676f732f6a625f6265616d2e737667)](https://www.jetbrains.com/?from=https://github.com/overtrue)

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 67.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~245 days

Recently: every ~312 days

Total

8

Last Release

969d ago

Major Versions

1.0.0 → 2.0.02020-03-26

2.0.3 → 3.0.02020-09-21

3.0.0 → 4.0.02023-07-06

PHP version history (4 changes)1.0.0PHP ^7.1.3

2.0.0PHP ^7.2

3.0.0PHP ^7.4

4.0.0PHP ^8.1.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/c507e57eab402e81335012357b7d7df6c5cafda3073adcc94b475037127d263f?d=identicon)[overtrue](/maintainers/overtrue)

---

Top Contributors

[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (724 commits)")[![overtrue](https://avatars.githubusercontent.com/u/1472352?v=4)](https://github.com/overtrue "overtrue (226 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (122 commits)")[![ramzeng](https://avatars.githubusercontent.com/u/38133602?v=4)](https://github.com/ramzeng "ramzeng (2 commits)")[![skyeryg](https://avatars.githubusercontent.com/u/3971550?v=4)](https://github.com/skyeryg "skyeryg (1 commits)")

---

Tags

laravellaravel-skeletonapilaravelSPA

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/overtrue-laravel-skeleton/health.svg)

```
[![Health](https://phpackages.com/badges/overtrue-laravel-skeleton/health.svg)](https://phpackages.com/packages/overtrue-laravel-skeleton)
```

###  Alternatives

[bagisto/bagisto

Bagisto Laravel E-Commerce

26.2k161.6k7](/packages/bagisto-bagisto)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[unopim/unopim

UnoPim Laravel PIM

9.4k1.8k](/packages/unopim-unopim)[aimeos/aimeos-headless

Aimeos headless ecommerce system

2.5k2.3k](/packages/aimeos-aimeos-headless)[nickurt/laravel-postcodeapi

Universal PostcodeApi for Laravel 11.x/12.x/13.x

97221.2k](/packages/nickurt-laravel-postcodeapi)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
