Base Controller
WNCMS’s base controller is a thin foundation that centralizes view resolution. In most cases, you should not extend this class directly. Instead, extend one of its child controllers that encapsulate layer-specific behavior.
Which controller should I extend?
| Use case | Controller to extend | Why | Typical namespace | View/response convention |
|---|---|---|---|---|
| Admin CRUD pages, settings screens, listing and editing models in the backend | Wncms\Http\Controllers\Backend\BackendController | Provides model naming, cache tag helpers, and unified CRUD patterns for backend | App\Http\Controllers\Backend\... or package backend controllers | backend.{models}.* Blade views |
| Public site pages rendered by the active theme (home, posts, pages, tags, etc.) | Wncms\Http\Controllers\Frontend\FrontendController | Theme-aware rendering, website context, and frontend conventions | App\Http\Controllers\Frontend\... or package frontend controllers | frontend.* Blade views resolved via theme |
| JSON APIs consumed by external apps (Vue, Next.js, mobile) | Wncms\Http\Controllers\Api\ApiController | API concerns such as auth, standardized responses/resources | App\Http\Controllers\Api\V1\... or package API controllers | JSON responses / API resources |
When to extend the base class directly
- Building a new controller layer (e.g., a specialized subsystem) that other controllers will extend.
- Creating a shared abstraction that adds cross-cutting helpers before layering (rare).
If you don’t fit one of these, use a child controller above.
Next steps
- Backend: see Backend Controller
- Frontend: see Frontend Controller
- API: see API Controller
- Scaffolding: see Create a Controller