承接 desino/boilerplate 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

desino/boilerplate

Composer 安装命令:

composer require desino/boilerplate

包简介

Desino in-house Laravel boilerplate: auth, user management, app config, and Blade scaffolding via Artisan.

README 文档

README

Latest Version on Packagist Total Downloads License

In-house Laravel starter kit by Desino. Publishes authentication, user management, app configuration, Blade layouts, and related scaffolding into an existing Laravel application via a single Artisan command.

Current stable release: v1.0.3 (Packagist: latest stable tag)

Requirements

  • PHP ^8.1
  • Laravel ^10, ^11, ^12, ^13, or ^14

Installation

Install the package with Composer (installs the latest stable release, currently v1.0.3):

composer require desino/boilerplate

To require a minimum version or pin exactly:

composer require desino/boilerplate:^1.0.3
# or
composer require desino/boilerplate:1.0.3

If you already installed an older tag, update in place:

composer update desino/boilerplate --with-dependencies

The service provider is auto-discovered. No manual registration is required.

Usage

Run the publish command once on a fresh or prepared Laravel app:

php artisan make:desino-boilerplate

Use --force to overwrite files that already exist (default: skip existing files).

This copies stubs into your application (controllers, models, migrations, views, frontend assets, routes, middleware, seeders, config, and translations). With --force, routes/web.php is replaced by the package stub; otherwise an existing routes/web.php is skipped.

Recommended dependencies

The publish command adds laravel/ui to your app composer.json require section (from composer.require.stub) when it is not already present. Edit the stub to add more packages if needed.

Then run:

composer update

Frontend assets

The command publishes resources/js, resources/css, and resources/sass (jQuery, Bootstrap 5, Font Awesome, bootstrap-select, datepicker CSS). resources/js/bootstrap.js exposes jQuery and bootstrap on window.

If your app has no package.json, the full stub is published. Otherwise missing entries from package.json.stub are merged into devDependencies, scripts, and overrides (existing packages are left unchanged).

The publish command removes Laravel Vite defaults when present: vite.config.js, vite.config.ts, public/hot, public/build, and Vite-related npm packages/scripts (this boilerplate uses Laravel Mix instead).

Build compiled assets expected by the layout (public/css/app.min.css, public/js/app.min.js):

npm install
npm run prod

The publish command copies default images to public/images/ (logo.png, loading.svg, etc.). Add public/favicon.ico in the host app if needed.

Environment

APP_URL=http://localhost

# Optional: force HTTPS URLs in production
MYAPP_FORCE_HTTPS=true

# Database (standard Laravel)
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
DB_CHARSET=utf8
DB_COLLATION=utf8_unicode_ci

Database

Ensure the default Laravel users migration has been run, then run the published migrations:

php artisan migrate

The boilerplate adjusts the users table (first_name, last_name, usertype, status, audit columns) and creates app_configs.

Providers

The package Desino\Boilerplate\BoilerplateServiceProvider is registered automatically via Composer (Artisan command only). You do not add it to bootstrap/providers.php.

The publish command copies CheckUserIsActive and CheckUserIsAdmin into app/Http/Middleware/. You must register them manually in bootstrap/app.php (steps below). The command does not modify bootstrap/app.php, because project layouts differ.

The publish command appends this to bootstrap/providers.php when missing (Laravel 11+):

App\Providers\BladeDefaultVariablesServiceProvider::class,

On Laravel 10, add that class to the providers array in config/app.php if bootstrap/providers.php does not exist.

Middleware (Laravel 11, 12, and 13)

Laravel 11+ registers middleware in bootstrap/app.php inside ->withMiddleware(). The steps are the same for Laravel 11, 12, and 13.

Middleware Registration Purpose
CheckUserIsActive $middleware->web(append: [...]) Logs out deactivated users on every web request
CheckUserIsAdmin $middleware->alias([...]) as checkIfAdmin Admin-only routes (used with auth in routes/web.php)

Step 1 — Confirm middleware files exist

After php artisan make:desino-boilerplate, you should have:

  • app/Http/Middleware/CheckUserIsActive.php
  • app/Http/Middleware/CheckUserIsAdmin.php

Step 2 — Open bootstrap/app.php

At the top of the file, ensure this import exists (add it if missing):

use Illuminate\Foundation\Configuration\Middleware;

Step 3 — Register inside ->withMiddleware()

Find the Application::configure(...) chain. It must include ->withMiddleware(...).

If you already have an empty closure (common default):

->withMiddleware(function (Middleware $middleware) {
    //
})

Replace the // (or add below it) with:

->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [
        \App\Http\Middleware\CheckUserIsActive::class,
    ]);

    $middleware->alias([
        'checkIfAdmin' => \App\Http\Middleware\CheckUserIsAdmin::class,
    ]);
})

If ->withMiddleware() is missing entirely, add it to the configure chain (between ->withRouting(...) and ->withExceptions(...), for example):

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->web(append: [
            \App\Http\Middleware\CheckUserIsActive::class,
        ]);

        $middleware->alias([
            'checkIfAdmin' => \App\Http\Middleware\CheckUserIsAdmin::class,
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })
    ->create();

Step 4 — Confirm routes use the alias

Published routes/web.php should wrap admin routes like this:

Route::middleware(['auth', 'checkIfAdmin'])->group(function () {
    // users, appconfig, ...
});

Step 5 — Clear caches (if routes/middleware were cached)

php artisan optimize:clear

Troubleshooting

Symptom What to check
Inactive users can still browse CheckUserIsActive is inside web(append: [...]), not only registered as an alias
Admin routes return 404 / no middleware Alias is exactly checkIfAdmin and routes use 'checkIfAdmin', not 'admin'
Changes have no effect Run php artisan optimize:clear and retry in a private browser window

Laravel 10 only (legacy Http/Kernel)

If your app still has app/Http/Kernel.php and no bootstrap/app.php middleware configuration:

  1. Add to $middlewareAliases:
'checkIfAdmin' => \App\Http\Middleware\CheckUserIsAdmin::class,
  1. Append to the web key in $middlewareGroups:
\App\Http\Middleware\CheckUserIsActive::class,

Seed defaults

php artisan db:seed --class=DesinoBoilerplateSeeder

Creates default pagination config (items_per_page_users = 25).

Post-install checklist

  1. composer update (installs laravel/ui after composer.json merge)
  2. Configure .env (database, MYAPP_FORCE_HTTPS)
  3. Register middleware in bootstrap/app.php (see Middleware)
  4. Confirm bootstrap/providers.php includes BladeDefaultVariablesServiceProvider (auto-added when possible)
  5. Confirm routes/web.php was published (or merge admin routes from the package stub)
  6. npm install && npm run prod (after package.json merge; see Frontend assets)
  7. php artisan migrate
  8. php artisan db:seed --class=DesinoBoilerplateSeeder
  9. php artisan config:cache (optional, production)

User roles and status

Constant Value Meaning
User::ROLE_ADMIN 1 Super admin
User::ROLE_NRMLUSR 2 Normal user
User::STATUS_ACTIVE 1 Can log in
User::STATUS_INACTIVE 0 Blocked (middleware logs out)

Published structure

Path Description
app/Http/Controllers/Auth/* Login, password reset, registration (register disabled in routes)
app/Http/Controllers/UserController.php User CRUD, activate/deactivate
app/Http/Controllers/AppConfigController.php Pagination and app settings
app/Http/Middleware/CheckUserIsActive.php Active account enforcement
app/Http/Middleware/CheckUserIsAdmin.php Admin-only routes
database/seeders/DesinoBoilerplateSeeder.php Default config and admin user
routes/web.php Web routes including auth and admin group
app/Models/User.php Extended user model
app/Models/AppConfig.php Key/value app configuration
app/Services/AppMiscService.php Flash messages, breadcrumbs, config helper
config/myapp.php App-specific settings
lang/en/messages.php UI translations
resources/js, resources/css, resources/sass Frontend source (compile to public/)
webpack.mix.js Published when missing (Laravel Mix build)

Configuration

config/myapp.php:

'myapp_force_https' => env('MYAPP_FORCE_HTTPS', false),

When true, AppServiceProvider forces https for generated URLs.

Routes (summary)

Method URI Name Access
GET / home Public
GET/POST /login, /logout, password reset Laravel UI Guest / auth
GET/POST /manual-login manuallogin Guest
GET/POST /appconfig appconfig.config Admin
GET/POST /users, /users/create, /users/edit/{id} users.* Admin
POST /users/activate, /users/deactivate, /users/delete users.* Admin

Public registration is disabled (Auth::routes(['register' => false])).

SFTP export (optional)

AppMiscService::exportToFTP() exports tables to CSV on the sftp_export disk. Configure config/filesystems.php for your SFTP server before use.

Security notes

  • Run make:desino-boilerplate only on trusted environments; use --force carefully.
  • Do not run the command twice without resolving duplicate migrations.
  • Keep MYAPP_FORCE_HTTPS=true behind a reverse proxy that sets X-Forwarded-Proto correctly.

Releasing on Packagist (maintainers)

Composer installs git tags, not branch master. After merging changes to master:

  1. Update CHANGELOG.md for the new version.
  2. Commit, push, then tag and push the tag (example v1.0.3):
git tag -a v1.0.3 -m "v1.0.3: short summary of changes"
git push origin master
git push origin v1.0.3
  1. On packagist.org/packages/desino/boilerplate, click Update if the new tag does not appear within a few minutes (or enable the GitHub webhook in package settings for automatic updates).
  2. Verify: composer require desino/boilerplate:^1.0.3

First-time setup: submit https://github.com/desino/LaravelBoilerPlate on packagist.org/packages/submit.

See CHANGELOG.md for version history.

License

MIT — see LICENSE.

Support

Contact: india@desino.be

desino/boilerplate 适用场景与选型建议

desino/boilerplate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 39 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 10 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「boilerplate」 「laravel」 「desino」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 desino/boilerplate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 desino/boilerplate 我们能提供哪些服务?
定制开发 / 二次开发

基于 desino/boilerplate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 39
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-08