bagisto-package-development
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePackage Development in Bagisto
Bagisto包开发
A Bagisto package is a self-contained Laravel module under
with its own models, controllers, routes, views, migrations and providers. All 41
core packages follow one shape — copy the closest existing package rather than
scaffolding a generic Laravel one.
packages/Webkul/<Name>/Bagisto包是位于下的独立Laravel模块,拥有自己的模型、控制器、路由、视图、迁移和提供者。所有41个核心包都遵循统一的结构——复制最接近的现有包,而不是搭建通用的Laravel模块。
packages/Webkul/<Name>/Reference files — load only what the current task needs
参考文件——仅加载当前任务所需的文件
| File | Load when |
|---|---|
| core.md | Creating a package — directory layout, |
| data-layer.md | Migrations, models, contracts, proxies, repositories |
| ui.md | Routes, controllers, Blade views |
| features.md | Admin menus, ACL, system configuration |
| 文件 | 加载时机 |
|---|---|
| core.md | 创建包时——目录结构、 |
| data-layer.md | 涉及迁移、模型、契约、代理、仓库时 |
| ui.md | 涉及路由、控制器、Blade视图时 |
| features.md | 涉及后台菜单、ACL、系统配置时 |
The shape of a package
包的结构
packages/Webkul/<Name>/src/
├── Config/ # system.php, admin-menu.php, acl.php
├── Contracts/ # one interface per model
├── Database/ # Migrations/, Seeders/, Factories/
├── DataGrids/ # admin listings
├── Http/Controllers/ # separate Admin/ and Shop/
├── Models/ # Eloquent models + Proxy classes
├── Providers/ # <Name>ServiceProvider + ModuleServiceProvider
├── Repositories/ # all database access
├── Resources/ # views/, lang/{22 locales}/, assets/
└── Routes/ # admin-routes.php, shop-routes.phppackages/Webkul/<Name>/src/
├── Config/ # system.php, admin-menu.php, acl.php
├── Contracts/ # 每个模型对应一个接口
├── Database/ # Migrations/, Seeders/, Factories/
├── DataGrids/ # 后台列表
├── Http/Controllers/ # 分为Admin/和Shop/目录
├── Models/ # Eloquent模型 + 代理类
├── Providers/ # <Name>ServiceProvider + ModuleServiceProvider
├── Repositories/ # 所有数据库操作
├── Resources/ # views/, lang/{22 locales}/, assets/
└── Routes/ # admin-routes.php, shop-routes.phpThe rules that are not negotiable
不可协商的规则
- Dual registration. Every package registers twice: its main
in
ServiceProvider, and itsbootstrap/providers.phpinModuleServiceProvider. Miss either and the package half-loads in a way that is hard to diagnose. See core.md.config/concord.php - Three-part models. Every entity is a Contract, a Model implementing it, and
a Proxy. Repositories return the Contract from , and cross-package type hints use the Proxy — that is what makes a model replaceable without editing core. See data-layer.md.
model() - Docblocks, member order, comments, the repository rule and translations
are owned by the skill. They apply to every Bagisto file, not only to a package, and they are the most common review rejection.
bagisto-coding-standards - Fix what you touch. A pre-existing violation in a file you edit is yours: scan the whole class's member order and docblocks, not just your own lines.
- 双重注册:每个包需要注册两次:主注册到
ServiceProvider,bootstrap/providers.php注册到ModuleServiceProvider。任何一个遗漏都会导致包加载不完全,且难以排查问题。详情请见core.md。config/concord.php - 三段式模型:每个实体包含Contract、实现Contract的Model以及Proxy。仓库从方法返回Contract,跨包类型提示使用Proxy——这正是无需修改核心代码即可替换模型的关键。详情请见data-layer.md。
model() - 文档块、成员顺序、注释、仓库规则和翻译由****技能负责。这些规则适用于所有Bagisto文件,不仅限于包,也是代码审查中最常见的拒绝原因。
bagisto-coding-standards - 修改触及的内容:如果你编辑的文件中存在预先存在的违规问题,你需要修复它:检查整个类的成员顺序和文档块,而不仅仅是你修改的行。
Related skills
相关技能
- — docblocks, member order, comments, repository access, localization. Load it alongside this one for any PHP.
bagisto-coding-standards - — admin listing pages.
bagisto-datagrid-developmentsketches the DataGrid; that skill owns columns, filters, actions, export and the security rules.features.md - — including the Blade layer: any
bagisto-coding-standards, in any package..blade.php - /
bagisto-pest-testing— tests for what you build.bagisto-playwright-testing - — the completion gate.
bagisto-change-verification
REQUIRED SUB-SKILL: Use bagisto-change-verification before calling any change done.
- ——文档块、成员顺序、注释、仓库访问、本地化。处理任何PHP代码时,请同时使用该技能。
bagisto-coding-standards - ——后台列表页面。
bagisto-datagrid-development概述了DataGrid;该技能负责列、过滤器、操作、导出和安全规则。features.md - ——包括Blade层:任何包中的
bagisto-coding-standards文件。.blade.php - /
bagisto-pest-testing——为你构建的内容编写测试。bagisto-playwright-testing - ——完成验证环节。
bagisto-change-verification
必需子技能:在标记任何修改完成前,请使用bagisto-change-verification。