Bitrix Controllers
Baseline: main 23.0+. Features newer than baseline are marked Since.
Progressive disclosure: open only the rule files that match the task. Do not read every rules/*.md.
How to use
- Identify the layer the task touches.
- Open the matching
rules/*.mdbelow. - Prefer framework-native Bitrix patterns over custom abstractions.
Choose a rule file
When to read rules/basics.md
Read rules/basics.md (Location, thin controller, autowire) when the task involves:
- Location and Naming
- Minimal Controller
- Action Parameter Autowiring
- Controller Lifecycle
- Additional Autowire Types
- Front-end Call
When to read rules/filters.md
Read rules/filters.md (Filters and attributes) when the task involves:
- Default Prefilters
- Action Filters
- PHP 8 Attribute Filters (preferred)
#[ActionAccess]/AccessCheck(module ACL)
When to read rules/errors-response.md
Read rules/errors-response.md (Errors, responses, scope) when the task involves:
- Errors
- Response Types
- Scope (AJAX / REST / CLI)
- Checklist
Cross-cutting invariants (apply regardless of rule file)
- Never configure the same action both via filter attributes and
configureActions()— the controller fails withInvalid configuration of actions. - Do not register one controller both as an HTTP route target (
/local/routes/web.php) and in the AJAXcontrollers.defaultNamespaceof.settings.php. Keep separateWeb\*andAjax\*controllers, each with its owngetAutoWiredParameters(). - Rendering helpers
renderView()/renderComponent()/renderExtension()— Since main 25.700.0. They return HTML (HttpResponse-based) and are for HTTP routes only;BX.ajax.runAction()expects JSON. For AJAX userenderComponentAjax()— JSON withhtml,assets,additionalParams,componentResult.renderExtension()/renderView()/renderComponent()acceptwithSiteTemplate: falseto skip the site template.renderExtension()requirescontrollerEntrypointin the extension'sconfig.php; it renders in the browser (not SSR). PageNavigationautowire (global, nav idnav) accepts a page size only within 1–50 (setPageSizes(range(1, 50))); an out-of-rangesizeis silently ignored and the default 20 is used.- Request DTOs are wired with
new ValidationParameter(...)ingetAutoWiredParameters()— not a#[ValidationParameter]attribute (that class does not exist). #[ActionAccess]requires the controller to implementAccessCheckControllerInterface. Without it the engine throwsSystemException.
Checklist
- Opened only the rule file(s) needed for this task.
- Followed DI /
/local// security canons fromAGENTS.md. - Respected the cross-cutting invariants above (no attribute +
configureActions()mix, separate Web/Ajax controllers).