Botble Conventions
Use this as the always-on baseline for Botble CMS work. Prefer existing project patterns and official Botble helpers over generic Laravel code.
Load References
Read references/quick-reference.md when implementing or reviewing Botble code. Read task-specific skills for plugin, theme, API, ecommerce, seeder, translation, testing, or review work.
Architecture
- Treat
platform/core, platform/packages, platform/plugins, and platform/themes as modular boundaries.
- Use Botble artisan generators when available:
php artisan cms:make:model, cms:make:form, cms:make:table, cms:make:controller, cms:make:request, cms:make:route.
- Dump Composer autoload after adding or moving platform modules.
- Use the root
vite-build.mjs runner without editing it. Declare plugin, package, or theme assets in the module's vite.build.mjs descriptor.
- Delete legacy
webpack.mix.js files after migrating their entries to Vite.
- Set
vue: true when a Vite entry imports Vue SFCs. Do not bundle another Vue runtime; Botble externalizes it to window.Vue.
Critical Rules
- Extend
Botble\Base\Models\BaseModel, never plain Eloquent Model.
- Use
Model::query() instead of the DB facade for model data.
- Eager load relations with
->with([...]) before rendering lists, cards, or API payloads.
- Prefer implicit route model binding. Type raw ID parameters as
int|string, use wherePrimaryKey() for custom ID constraints, and use $model->getKey() when ID type matters.
- Define casts with a
casts(): array method in Laravel 12+ style unless the project already uses a different local convention.
- Use
foreignId() for foreign key columns in migrations.
Botble Enums
Botble uses Botble\Base\Supports\Enum, not PHP native enums. The enum $value property is protected.
Correct:
$model->status->getValue()
(string) $model->status
$model->status->label()
BaseStatusEnum::PUBLISHED()
$model->status->getValue() === BaseStatusEnum::PUBLISHED
Wrong:
$model->status->value
$model->status === BaseStatusEnum::PUBLISHED
Raw request values and query bindings do not need enum object conversion.
Translations
- Plugins/packages/core: use
trans('plugins/name::file.key'), not __().
- Themes: use
__('Text') with flat JSON language files.
- Never convert a string translation key to an array value.
- Preserve
:placeholders exactly.
- Escape apostrophes in single-quoted PHP translations, for example
l'exemple.
Security
- Use
{{ $value }} for escaped output.
- Use
BaseHelper::clean($html) before any {!! !!} output.
- Use
@json($data) when embedding data into JavaScript.
- Send
X-CSRF-TOKEN for AJAX requests that mutate state.
- Read cookies through
request()->cookie() and validate names/values against an allowlist.
- Do not add CDN assets; bundle libraries locally or use Botble helpers such as
BaseHelper::googleFonts().
- Keep dependencies current and check
npm outdated when changing frontend dependencies.
Media
- Always render media paths through
RvMedia::getImageUrl($path).
- Use presets with
RvMedia::getImageUrl($path, 'thumb').
- Never use raw
<img src="{{ $model->image }}">.
Frontend
- Use jQuery
.on() event handlers, not .click(), .bind(), or .hover().
- Do not add inline JavaScript or CSS attributes.
- Delete unused code instead of commenting it out.
- Pair Tabler badge classes, for example
bg-green text-green-fg.
Quality Gate
Before handing work back, run the narrowest useful checks:
- PHP syntax for changed PHP files:
php -l path/to/file.php.
- Formatting:
./vendor/bin/pint or the project equivalent.
- Tests:
vendor/bin/phpunit, php artisan test, or targeted tests.
- Assets:
npm run dev for development or npm run production for a production build. Botble's Vite pipeline has no watch mode or dev server.
1---2name: botble-conventions3description: Core Botble CMS coding conventions, architecture rules, security practices, translations, enum handling, media URLs, frontend constraints, and review guardrails. Use whenever editing Botble CMS projects, especially files under platform/, packages, plugins, themes, resources/views, routes, database migrations, seeders, or tests.4---56# Botble Conventions78Use this as the always-on baseline for Botble CMS work. Prefer existing project patterns and official Botble helpers over generic Laravel code.910## Load References1112Read `references/quick-reference.md` when implementing or reviewing Botble code. Read task-specific skills for plugin, theme, API, ecommerce, seeder, translation, testing, or review work.1314## Architecture1516- Treat `platform/core`, `platform/packages`, `platform/plugins`, and `platform/themes` as modular boundaries.17- Use Botble artisan generators when available: `php artisan cms:make:model`, `cms:make:form`, `cms:make:table`, `cms:make:controller`, `cms:make:request`, `cms:make:route`.18- Dump Composer autoload after adding or moving platform modules.19- Use the root `vite-build.mjs` runner without editing it. Declare plugin, package, or theme assets in the module's `vite.build.mjs` descriptor.20- Delete legacy `webpack.mix.js` files after migrating their entries to Vite.21- Set `vue: true` when a Vite entry imports Vue SFCs. Do not bundle another Vue runtime; Botble externalizes it to `window.Vue`.2223## Critical Rules2425- Extend `Botble\Base\Models\BaseModel`, never plain Eloquent `Model`.26- Use `Model::query()` instead of the `DB` facade for model data.27- Eager load relations with `->with([...])` before rendering lists, cards, or API payloads.28- Prefer implicit route model binding. Type raw ID parameters as `int|string`, use `wherePrimaryKey()` for custom ID constraints, and use `$model->getKey()` when ID type matters.29- Define casts with a `casts(): array` method in Laravel 12+ style unless the project already uses a different local convention.30- Use `foreignId()` for foreign key columns in migrations.3132## Botble Enums3334Botble uses `Botble\Base\Supports\Enum`, not PHP native enums. The enum `$value` property is protected.3536Correct:3738- `$model->status->getValue()`39- `(string) $model->status`40- `$model->status->label()`41- `BaseStatusEnum::PUBLISHED()`42- `$model->status->getValue() === BaseStatusEnum::PUBLISHED`4344Wrong:4546- `$model->status->value`47- `$model->status === BaseStatusEnum::PUBLISHED`4849Raw request values and query bindings do not need enum object conversion.5051## Translations5253- Plugins/packages/core: use `trans('plugins/name::file.key')`, not `__()`.54- Themes: use `__('Text')` with flat JSON language files.55- Never convert a string translation key to an array value.56- Preserve `:placeholders` exactly.57- Escape apostrophes in single-quoted PHP translations, for example `l'exemple`.5859## Security6061- Use `{{ $value }}` for escaped output.62- Use `BaseHelper::clean($html)` before any `{!! !!}` output.63- Use `@json($data)` when embedding data into JavaScript.64- Send `X-CSRF-TOKEN` for AJAX requests that mutate state.65- Read cookies through `request()->cookie()` and validate names/values against an allowlist.66- Do not add CDN assets; bundle libraries locally or use Botble helpers such as `BaseHelper::googleFonts()`.67- Keep dependencies current and check `npm outdated` when changing frontend dependencies.6869## Media7071- Always render media paths through `RvMedia::getImageUrl($path)`.72- Use presets with `RvMedia::getImageUrl($path, 'thumb')`.73- Never use raw `<img src="{{ $model->image }}">`.7475## Frontend7677- Use jQuery `.on()` event handlers, not `.click()`, `.bind()`, or `.hover()`.78- Do not add inline JavaScript or CSS attributes.79- Delete unused code instead of commenting it out.80- Pair Tabler badge classes, for example `bg-green text-green-fg`.8182## Quality Gate8384Before handing work back, run the narrowest useful checks:8586- PHP syntax for changed PHP files: `php -l path/to/file.php`.87- Formatting: `./vendor/bin/pint` or the project equivalent.88- Tests: `vendor/bin/phpunit`, `php artisan test`, or targeted tests.89- Assets: `npm run dev` for development or `npm run production` for a production build. Botble's Vite pipeline has no watch mode or dev server.