Perfex CRM module authors can adopt CodeIgniter 4.7.6 (PHP 8.2+, strict typing, PSR-4 namespaces, and route filters) without forcing buyers to install IgniteCore. By adding a self-contained ignite/ directory and a manifest.php v1 contract inside an existing module, your routes accelerate on IgniteCore when available and fall back 100% natively to CodeIgniter 3.1.11 when IgniteCore is absent.
Why Dual-Mode Architecture Solves Perfex CRM Dependencies
Perfex CRM runs on CodeIgniter 3.1.11, where App_Controller.php halts if CI_VERSION differs from 3.1.11, and both kernels share colliding constants (APPPATH, FCPATH, ENVIRONMENT) and helper names. Booting CI4 inside CI3 is not viable, yet requiring every buyer to install a second runtime adds friction.
IgniteCore solves this via a Pre-Boot Front-Dispatcher (modules/ignite_core/bootstrap/dispatcher.php) and a zero-coupling Dual-Mode SDK:
- Zero hard dependency: Standard Perfex entry files (
{slug}.php, CI3 controllers,config/my_routes.php, models, views) remain untouched and fully operational on CI3. - Mutually exclusive execution: Matched routes enabled in
runtime/writable/cache/route_manifest.phpboot pure CodeIgniter 4.7.6 insidemodules/ignite_core/runtime/, while unmatched routes pass straight to rootindex.phpon CI3. - Future-proof
ignite/naming: Usingmodules/{slug}/ignite/instead ofci4/keeps module contracts intact when IgniteCore upgradesruntime/system/to CodeIgniter 4.8+, 5.x, or 6.x.
Standard Dual-Mode Directory Layout
Keep CI3 code at the module root and isolate the PHP 8.2+ CI4 layer under ignite/:
modules/your_module/
├── your_module.php # Standard Perfex CI3 bootstrap, hooks, and menus
├── config/
│ ├── my_routes.php # Standard CI3 routes (100% preserved fallback)
│ └── csrf_exclude_uris.php # Modular CSRF exclusions shared by CI3 & CI4
├── controllers/ # Legacy CI3 controllers
└── ignite/ # Zero-coupling Dual-Mode runtime layer
├── manifest.php # Schema v1 discovery, PSR-4, and route contract
├── Config/Routes.php # CodeIgniter 4 RouteCollection definitions
├── Filters/ # Optional module-specific CI4 Route Filters
└── Controllers/ # Pure CI4 PSR-4 controllers (PHP 8.2+)
The ignite/manifest.php Schema v1 Contract
Ignite_core_manifest_builder::discoverModuleManifests() scans active rows in tblmodules (active = 1) for modules/{slug}/ignite/manifest.php, loading each inside an isolated try/catch block so a broken manifest never disrupts the CRM.
<?php
declare(strict_types=1);
return [
'schema_version' => 1,
'module_slug' => 'your_module',
'display_name' => 'Your Module',
'engine_min' => '4.7.0',
'psr4' => [
'Modules\\YourModule\\Ignite' => __DIR__,
],
'routes_file' => __DIR__ . '/Config/Routes.php',
'events_file' => null,
'commands' => [],
'benchmark_ci3_targets' => [
[
'id' => 'your_module_ci3_status',
'name' => 'Your Module (CI3)',
'endpoint' => '/your_module/api/v1/status',
],
],
'route_entries' => [
[
'key' => 'api_v2_status',
'methods' => ['GET'],
'type' => 'exact', // 'exact' | 'prefix' | 'regex'
'match' => 'api/v2/your_module/status',
'default' => true,
'priority' => 100, // Lower evaluates first
'label' => 'Your Module CI4 Status Endpoint',
],
],
];
schema_version,engine_min,psr4,routes_file,events_file,commands: Declare contract v1, minimum CI4 engine (4.7.0), dynamic PSR-4 namespace registration, CI4 routes file, optional boot events file, and optional Spark commands.benchmark_ci3_targets: Optional array (up to 5 endpoints starting with/) surfaced alongside CI4 routes in Setup > IgniteCore > Diagnostics & Guard.route_entries: Each item maps to a toggle intblignite_core_route_toggles. Settype(exact,prefix, orregex),methods(['GET'],['POST'],['ANY']),priority(sorted ascending), anddefault(truefor newapi/v2/*routes,falsefor opt-in Strangler Fig routes overlappingmy_routes.php).
Base Controllers, Shared Bridges, and Route Filters
IgniteCore provides shared infrastructure under IgniteCore\ (modules/ignite_core/runtime/app/).
1. Built-in Base Controllers
IgniteCore\Controllers\BaseAdminController: Injects$this->auth,$this->options,$this->lang, and$this->outbox, syncsactive_language, and providesjsonSuccess()andjsonError().IgniteCore\Controllers\BaseClientController: Injects$this->auth,$this->options, and$this->langfor Client Portal endpoints withjsonSuccess().IgniteCore\Controllers\BaseApiController: Injects$this->optionsand providesapiSuccess(mixed $data, array $meta = [], int $statusCode = 200)plus RFC 9457apiProblem()(application/problem+json).
2. Shared-State Bridges via service()
| Service Call | Bridge Class | Capabilities |
|---|---|---|
service('perfexAuth') |
PerfexAuthService |
staff(), isAdmin(), staffCan($capability, $feature), contact(), isStaffLoggedIn(), isClientLoggedIn(), touchStaffActivity() |
service('perfexOptions') |
PerfexOptionsService |
get($name, $default) and set($name, $value, $autoload) with preloaded tbloptions cache |
service('perfexLang') |
PerfexLangService |
setLanguage(), loadModule($slug), line($key, $slug, ...$args) for native *_lang.php packs |
service('perfexOutbox') |
PerfexEventOutboxService |
enqueue($eventName, $payload, $ci3HookName) into tblignite_core_event_outbox for CI3 after_cron_run hook relay |
3. All 6 Built-in Route Filters
Configured in runtime/app/Config/Filters.php:
staffAuth(PerfexStaffAuthFilter): Validates Perfex Staff SSO viatblsessions(unprefixed ID +INT(10)UNIX timestamp) and throttleslast_activityupdates.staffCan(PerfexStaffPermissionFilter): Default-deny RBAC filter (such asstaffCan:view,your_module) checkingtblstaff_permissions.clientAuth(PerfexClientAuthFilter): Validates Client Portal contact sessions (tblcontacts).perfexCsrf(PerfexCsrfFilter): Validates Perfexcsrf_cookie_nameagainst POST/JSONcsrf_token_nameorX-CSRF-TOKENwithout regenerating the cookie, returning419on AJAX mismatch.apiAuth(PerfexApiAuthFilter): Stateless API guard closing any active PHP session and settingX-IgniteCore-Kernel,X-Content-Type-Options: nosniff, andReferrer-Policy.sessionReadOnly(SessionReadOnlyFilter): Callssession_write_close()right after auth checks to prevent AJAX session locking.
<?php
use CodeIgniter\Router\RouteCollection;
/** @var RouteCollection $routes */
$routes->get(
'api/v2/your_module/status',
'\Modules\YourModule\Ignite\Controllers\StatusController::index',
['filter' => 'apiAuth']
);
$routes->post(
'admin/your_module/save_settings',
'\Modules\YourModule\Ignite\Controllers\AdminSettingsController::save',
['filter' => ['perfexCsrf', 'staffAuth', 'staffCan:edit,your_module']]
);
Migrating CSRF Exclusions to config/csrf_exclude_uris.php
Because my_routes.php only loads in CI3, move stateless API exclusions out of $app_csrf_exclude_uris into modules/{slug}/config/csrf_exclude_uris.php:
<?php
defined('BASEPATH') or exit('No direct script access allowed');
return [
'api/v2/your_module/.+',
];
Both Perfex InitModules and Ignite_core_manifest_builder::collectPerfexCsrfExcludeUris() merge every module's file into route_manifest.php, keeping CSRF rules consistent across CI3 and CI4.
Scaffolding and Managing Modules with Spark CLI
IgniteCore ships four Spark CLI commands (php modules/ignite_core/spark, guarded by PHP_SAPI !== 'cli'):
php modules/ignite_core/spark ignite:doctor
php modules/ignite_core/spark ignite:make-module your_module
php modules/ignite_core/spark ignite:manifest
php modules/ignite_core/spark ignite:entry status
ignite:doctor: Verifies PHP >= 8.2,ext-intl,ext-mbstring,ext-mysqli, DB connectivity,tblsessionsschema, and entry mode.ignite:make-module <slug> [--target <dir>]: Scaffoldsignite/manifest.php,Config/Routes.php, andControllers/StatusController.php.ignite:manifest: Discovers active Dual-Mode modules and recompilesruntime/writable/cache/route_manifest.php.ignite:entry [status|attach-index|detach]: Manages the 3-lineindex.phpmarker on Nginx, OpenLiteSpeed, or CyberPanel servers.
Zero Hard-Dependency Guarantee
Perfex CRM only loads root {slug}.php, config/my_routes.php, and CI3 controllers/, never scanning ignite/. Buyers without IgniteCore run 100% on CI3; if IgniteCore is added later, ignite:manifest activates CI4 routes automatically; and if IgniteCore is disabled or passed ?ignite_fallback=1, the 5-layer Circuit Breaker routes traffic cleanly back to CI3.
Frequently Asked Questions
Will my Dual-Mode module break on PHP 8.1 or without IgniteCore?
No, as long as your CI3 files support PHP 8.1+. Perfex CI3 never includes modules/{slug}/ignite/, and IgniteCore's Circuit Breaker only boots CI4 when PHP_VERSION_ID >= 80200, ext-intl, and ext-mbstring are present.
How do CI4 controllers notify legacy CI3 module hooks?
Call service('perfexOutbox')->enqueue('event_name', ['id' => 42], 'your_ci3_hook'). IgniteCore queues the payload in tblignite_core_event_outbox, and Perfex's after_cron_run hook relays up to 50 events per cycle to hooks()->do_action().
What happens if a CI4 module route throws an unhandled exception?
Config\Exceptions::handler() logs attribution via PerfexIncidentGuard::record(). With Auto-Quarantine enabled (3 incidents in 300 seconds), IgniteCore automatically disables that module's CI4 routes and reverts traffic to CI3.
Why use ignite/ instead of ci4/?
Naming the directory ignite/ and namespace Modules\{StudlySlug}\Ignite keeps module contracts compatible across future CodeIgniter 4.8+, 5.x, or 6.x runtime upgrades.
If your business runs third-party Perfex add-ons whose original authors have not added ignite/manifest.php support yet, HeadRandom provides custom upgrading and porting of existing Perfex modules to run on IgniteCore CodeIgniter 4.
Related Guides
- IgniteCore for Perfex CRM - Product Overview - Dual-Mode CodeIgniter 4.7.6 runtime, 5-layer Circuit Breaker, and Admin Control Plane.
- Accelerating Perfex CRM APIs: Data Builder & IgniteCore Dual-Mode Case Study - Production walkthrough of
modules/data_builder/ignite/. - Data Builder for Perfex CRM - Visual Reporting, REST API & GraphQL - Explore Data Builder's REST API, GraphQL, and MCP capabilities.
Need a Custom Perfex CRM Module, Bug Fix, or CodeIgniter 4 Upgrade?
Avoid broken updates, PHP 8.2-8.4 errors, and risky core edits. HeadRandom provides custom Perfex CRM module development, upgrade, and bug-fixing services for any third-party or custom module on your Perfex CRM installation, plus upgrading Perfex CRM from CodeIgniter 3 to CodeIgniter 4 via IgniteCore for Perfex CRM.
Develop new custom modules from scratch, patch bugs or hook conflicts on existing client modules, and update legacy code for clean PHP 8.2-8.4 compatibility with zero core file hacks. View Perfex CRM module development scope.
Migrate your Perfex CRM runtime to CodeIgniter 4 (4.7.6) using IgniteCore for Perfex CRM (independent module by HeadRandom) with Dual-Mode CI3 fallback, 32% to 75% lower latency, 50% less RAM, and custom CI4 porting for third-party modules. See CI3 to CI4 upgrade options.
Combine 2+ HeadRandom services (Custom Module, IgniteCore CI4 Upgrade, or Website Care) to save 30% automatically.