OverviewHistoryStatsSecurity
npx skills add ...
Documentation
SKILL.md
npx skills add bxmaximum/bitrix-framework-skills --skill bitrix-project-structure
Where code lives in a Bitrix project — /local vs /bitrix, php_interface files, Loader includeModule/requireModule, PSR-4 autoload of module lib/, Composer, file priority. Use when deciding where to put code or why a class does not load.
npx skills add bxmaximum/bitrix-framework-skills --skill bitrix-project-structure
Baseline: main 23.0+ · Verified: main 26.800.0
/bitrix/ — kernel and marketplace modules; replaced by updates. Never edit (bitrix-framework)./local/ — all project code; same relative path in /local/ wins over /bitrix/./upload/ — user/module files.Give /local/php_interface/ the same access protection as /bitrix/php_interface/.
php_interface filesinit.php: only constants needed before modules, and runtime addEventHandler() for hooks that belong to no module. Everything else → a module (install/, include.php, .settings.php).after_connect_d7.php is included inside the default connection object: use $this->queryExecute("SET …") (charset, sql_mode, time zone). Only one file runs — a /local copy disables the /bitrix one, so carry its statements over. Other connections run their own file via 'include_after_connected' => '/abs/path.php' in connections.Loader)| Situation | Call |
|---|---|
| Module required; failure is a bug | Loader::requireModule('vendor.module') — throws LoaderException |
| Optional integration | if (Loader::includeModule('crm')) { … } |
| Shareware/demo status | Loader::includeSharewareModule() |
includeModule() returns false if the module is not registered in b_module (files alone are not enough) or its include.php returns false. On success it registers the PSR-4 root, includes include.php, registers module services. Load once at the entry point (controller, agent, command), not deep in services. Legacy CModule::IncludeModule() — compat only.
lib/vendor.module → Vendor\Module\ → lib/; one-word mymodule → Bitrix\Mymodule\.Vendor\Module\Public\Service\PostService → lib/Public/Service/PostService.php.lib/ dirs are PascalCase). PostTable is also looked up as post.php.require kernel lib/ files by path — kernel updates rename them (e.g. lists 26.200 moved to PascalCase).Loader::registerNamespace('Vendor\\Legacy', $absDir) or Loader::registerAutoLoadClasses('vendor.module', ['COldClass' => 'classes/old.php']) in include.php.composer.json outside DOCUMENT_ROOT (e.g. project root), .settings.php → 'composer' => ['value' => ['config_path' => '../composer.json']]; the kernel includes its vendor/autoload.php.bitrix.php (Symfony Console) — bitrix-console-commands./bitrix/.php_interface files, .settings*.php: /local/ first, then /bitrix/.components/… overrides the component's own templates/./local/modules/<id> wins when both exist.require them from /local/routes/web.php (bitrix-routing).