В этом видео я показываю, как с помощью AI-агента, Laravel, PHP и Filament создать собственную CMS-админку вместо использования тяжёлого универсального решения вроде WordPress.
Это не видео против WordPress. WordPress по-прежнему отлично подходит для многих сайтов. Но если проекту нужна своя архитектура, API, кастомная логика или минимальный набор функций без лишнего legacy, то Laravel может быть более правильным выбором.
Видео
GitHub
Исходный код проекта: https://github.com/CRIK0VA/Lumina
Промпты
Ниже будут размещены промпты, которые использовались в видео.
1. Инструкции для AI-агента
# Project Intelligence Manifest: LuminaCMS (Laravel + Filament)
## Core Mission
Replace the bloated WordPress ecosystem with a high-performance, strictly-typed Laravel 13 backend and Filament PHP admin panel.
## System Architecture Roles
- **Primary Agent:** Senior Laravel Architect.
- **Ruleset:** Follow SOLID, DRY, and KISS principles.
- **Strict Typing:** `declare(strict_types=1);` is mandatory for all PHP files.
- **Tech Stack:** Laravel 13, Filament v5, Spatie MediaLibrary, Spatie Translatable.
## Development Roadmap & Prompts
To maintain architectural integrity, refer to the following instruction files in order:
1. **Step 1: Core Foundation** -> `prompts/01-core-admin.md` (Models, Migrations, Filament Basics)
2. **Step 2: Media Management** -> `prompts/02-media-library.md` (Spatie Media Library integration)
3. **Step 3: Globalization** -> `prompts/03-localization.md` (Multi-language support)
4. **Step 4: Quality & Security** -> `prompts/04-audit-and-security.md` (Refactoring & Hardening)
## General Instructions for AI
- Always use **Filament Resources** for CRUD, avoid manual Blade controllers for the admin part.
- All business logic MUST reside in the `App\Services` namespace.
- Use **FormRequests** for all validation logic.
- API endpoints must return **JsonResource** collections.
- When generating code, prioritize performance (prevent N+1 queries) and security (mass assignment protection).
## Reference Manual
If you are unsure about a specific implementation, check the official documentation for Filament PHP and Spatie packages first.
2. Основной промпт для создания CMS
**Role:** Senior Full-Stack Architect & Laravel Expert.
**Context:** You are building a high-performance "Lumina CMS" designed to replace WordPress for modern web projects. The goal is to provide a clean, bloat-free admin experience using Laravel 13 and Filament PHP.
**Project Core Requirements:**
1. **Framework:** Laravel 13 (latest stable) with Type-Safe declarations.
2. **Admin UI:** Filament PHP v5 (latest).
3. **Frontend Flexibility:** Hybrid approach. Implement Blade-based routing/views for monolithic use and Laravel Sanctum-powered API endpoints with strict JSON contracts for headless use.
**Database & Domain Schema:**
Please generate the following entities and their respective Filament Resources:
1. **User Management:**
- Standard Laravel Auth + Roles (Admin, Editor).
- Filament Resource for managing users.
2. **Hierarchical Page System:**
- Table: `pages` (title, slug, content: longText, status: enum[draft, published], published_at).
- Support for parent-child relationships (nested sets or simple parent_id).
- SEO metadata fields (title, description).
3. **Polymorphic Taxonomy System:**
- Instead of hardcoded categories, implement a flexible Taxonomy system.
- Tables: `taxonomies` (name, slug, type: e.g., 'category', 'tag') and `taxonomables` (morphTo).
- Filament Resource to manage these taxonomies and attach them to Pages.
4. **Global Settings Store (The "wp_options" alternative):**
- Table: `settings` (key: string unique, value: text/json, type: string for casting).
- Create a dedicated "Site Settings" Page in Filament (not a standard CRUD, but a Single-Record Page) to edit global values like Site Name, Contact Email, and Social Links.
**Architecture Constraints:**
- **Service Layer:** Do not put business logic in Controllers or Filament Resources. Use a `PageService` and `SettingService` to handle data operations.
- **API Design:** Create a `v1` API namespace. Provide endpoints for:
- GET `/api/pages` (with pagination and taxonomy filters).
- GET `/api/pages/{slug}`.
- GET `/api/settings` (public settings only).
- **Coding Style:** PSR-12, strict typing (declare(strict_types=1)), and utilize Laravel 13's newest features (e.g., streamlined routing and simplified configuration).
**Output Instructions:**
1. Start by providing a high-level file structure.
2. Provide Migration files.
3. Provide Models with relationships (HasMany, MorphToMany).
4. Provide Filament Resource classes with optimized Form and Table schemas.
5. Provide the API Controller and the JSON Resource for Page data.
**Important:** Focus on a clean UX in the Filament Admin that mimics the utility of WordPress but with 10x the performance and 0x the bloat.
3. Промпт для Media Library
**Role:** Senior Laravel Developer.
**Task:** Implement a robust Media Management system for the "Lumina CMS" using Laravel 13 and Filament PHP.
**Core Requirements:**
1. **Engine:** Use `spatie/laravel-medialibrary` as the core file management provider.
2. **Integration:** - Update the `Page` model to implement `HasMedia` interface and use the `InteractsWithMedia` trait.
- Define a "featured_image" collection for Pages with automatic conversions (thumbnail: 150x150, medium: 600x400, webp format).
3. **Filament UI:**
- Integrate `SpatieMediaLibraryFileUpload` components into the PageResource form.
- Create a dedicated "Media Library" Filament Page where the admin can browse, upload, and delete all files in the system independently of specific models.
4. **Storage:** Configure the system to use the `public` disk by default, but ensure it's "Cloud-ready" (prepared for S3/DigitalOcean Spaces).
**Architecture Constraints:**
- **MediaService:** Create a service class to handle file processing logic, such as cleaning up orphaned files or generating custom download links.
- **API Support:** Update the Page JSON Resource to include `media` URLs and responsive image definitions.
- **Optimization:** Use Spatie's "Responsive Images" feature to ensure high performance on the frontend.
**Output:**
1. Necessary composer commands for installation.
2. Updated Page Migration and Model.
3. Code for the Filament Media Library browse page.
4. API response examples including media metadata.
4. Промпт для Localization
**Role:** Localization & Architecture Expert.
**Task:** Implement multi-language support for the "Lumina CMS" to allow seamless content translation (e.g., English and Russian).
**Core Requirements:**
1. **Translation Engine:** Use `spatie/laravel-translatable` to handle model translations via JSON columns.
2. **Database:** Update `pages` and `taxonomies` tables to make `title`, `slug`, and `content` translatable. Ensure migrations use the `json` data type for these columns.
3. **Filament Integration:**
- Enable Filament's native localization features.
- Add a language switcher (Locale Switcher) to the header of the Admin Panel.
- Use the `Translatable` trait in Filament Resources so that admins can switch languages directly on the Edit/Create forms.
4. **URL Strategy:** - Implement a middleware to detect and set the locale from the URL (e.g., `/en/about-us` vs `/ru/about-us`).
- Ensure slugs are unique per locale.
**Architecture Constraints:**
- **Global Settings:** Ensure the `Settings` system created in Prompt #1 also supports translatable values for site-wide strings.
- **API Localization:** The API must respect the `Accept-Language` header to return content in the requested locale.
- **Fallback Logic:** Implement a fallback mechanism to show the default language if a translation is missing.
**Output:**
1. Updated Migrations for JSON columns.
2. Updated Models with `$translatable` property.
3. Configuration code for Filament's Locale Switcher.
4. Middleware code for locale detection and API response logic.
5. Промпт для Audit & Security
**Role:** Senior Security Engineer & Laravel Performance Expert.
**Task:** Conduct a deep architectural audit of the previously generated code for the "Lumina CMS". Identify and fix potential bottlenecks, security risks, and technical debt.
**Audit Checklist & Optimization Requirements:**
1. **Mass Assignment & Validation:**
- Ensure every resource uses dedicated `FormRequest` classes with strict validation rules (unique slugs, email formats, size limits for media).
- Check all Models for proper `$fillable` or `$guarded` properties to prevent mass assignment vulnerabilities.
2. **Performance (N+1 Query Prevention):**
- Review Filament Tables and API Controllers. Ensure all relationships (Taxonomies, Media) are Eager Loaded (`with()`) to prevent N+1 query issues.
- Implement Query Caching for the `Settings` store using Laravel's Cache Facade.
3. **Security Hardening:**
- Implement `RateLimiting` for all API endpoints to prevent Brute-Force/DoS.
- Ensure all API responses use `JsonResource` to mask sensitive internal database structures.
- Verify that all Morph relationships (Taxonomies) are restricted to a defined `MorphMap` in the `AppServiceProvider`.
4. **Code Quality (SOLID):**
- Refactor any remaining business logic from Controllers/Filament Resources into the Service Layer.
- Use strictly typed properties and return types everywhere (PHP 8.4/Laravel 13 syntax).
- Replace any "magic" strings with Class Constants or Enums (e.g., Page Status, User Roles).
5. **Final Polish:**
- Generate a `database/seeders` class to create a "Ready-to-use" demo environment with 50+ pages, nested categories, and a default admin user.
**Output:** Provide the refactored code for only the components that failed the audit, and explain *why* these changes improve the system's stability compared to a standard WordPress installation.
Почему Laravel вместо WordPress
WordPress удобен, когда нужен быстрый сайт на готовой теме или с готовыми плагинами. Но для кастомных проектов он часто тянет за собой много лишнего: ненужные таблицы, лишнюю функциональность, плагины, legacy и ограничения архитектуры.
Laravel-подход удобен тем, что проект сразу строится под конкретную задачу. Нужны только страницы, API и настройки — делаем только их. Нужна медиа-библиотека или локализация — добавляем отдельным шагом.
Что получилось
В результате AI-агент сгенерировал рабочий каркас CMS:
- Laravel-проект;
- Filament-админку;
- модели и миграции;
- CRUD-разделы;
- демо-данные;
- базовые тесты;
- API;
- поддержку медиа и локализации.
Такой проект можно использовать как стартовую болванку и дальше расширять под конкретный сайт, MVP, админку или backend для мобильного приложения.
Заключение
AI и vibe coding позволяют быстро собрать основу проекта без ручного написания однотипного CRUD-кода. Но разработчик всё равно должен проверять архитектуру, безопасность, миграции, логику и финальное качество.
WordPress остаётся хорошим инструментом для своих задач. Но если нужен кастомный, чистый и расширяемый backend, Laravel + Filament могут быть более подходящим решением.