Skip to content

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 caseController to extendWhyTypical namespaceView/response convention
Admin CRUD pages, settings screens, listing and editing models in the backendWncms\Http\Controllers\Backend\BackendControllerProvides model naming, cache tag helpers, and unified CRUD patterns for backendApp\Http\Controllers\Backend\... or package backend controllersbackend.{models}.* Blade views
Public site pages rendered by the active theme (home, posts, pages, tags, etc.)Wncms\Http\Controllers\Frontend\FrontendControllerTheme-aware rendering, website context, and frontend conventionsApp\Http\Controllers\Frontend\... or package frontend controllersfrontend.* Blade views resolved via theme
JSON APIs consumed by external apps (Vue, Next.js, mobile)Wncms\Http\Controllers\Api\ApiControllerAPI concerns such as auth, standardized responses/resourcesApp\Http\Controllers\Api\V1\... or package API controllersJSON 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

Built with ❤️ for WNCMS