Writing Perfex CRM modules strictly with CodeIgniter 3 globals limits IDE autocompletion, blocks unit testing, and complicates Composer dependency management. With the IgniteCore SDK, you can scaffold dual-mode modules that run clean CodeIgniter 4 PSR-4 controllers, services, and migrations when IgniteCore is present, while gracefully falling back to standard CI3 hooks on unbridged Classic installations without shipping two separate zip packages.
New to the runtime model? Check why teams choose CI4 dual-mode on Classic over early Next 1.0 rewrites.
| Module Component | Legacy CI3 Location | IgniteCore Dual-Mode Location |
|---|---|---|
| Bootstrap & Menu Hooks | modules/{slug}/{slug}.php | modules/{slug}/{slug}.php (shared thin loader) |
| Controllers & Filters | controllers/*.php (CI_Controller) | ci4/app/Controllers/*.php (BaseController) |
| Database Models | models/*_model.php | ci4/app/Models/*.php (IgniteModel) |
| Route Registration | config/routes.php | ci4/app/Config/Routes.php |
| Manifest & Capability Check | Header docblock only | ignitecore.json + docblock metadata |
1. Scaffold the Dual-Mode Directory Layout
Keep your root module file clean and declarative so Perfex Classic discovers activation, deactivation, and uninstall hooks natively. Inside the same module folder, place your CodeIgniter 4 namespace under ci4/ and declare an ignitecore.json manifest so IgniteCore auto-registers PSR-4 paths on boot. Follow the IgniteCore installation guide to prepare your local dev sandbox first.
- Add
defined('BASEPATH') or exit('No direct script access allowed');at the top of all Classic entry scripts andinstall.php. - Define a unique PSR-4 root namespace (such as
Vendor\ModuleSlug) inignitecore.jsonto prevent class collisions. - Use IgniteCore’s
ignite_is_active()helper inside your menu hook to route admin links to CI4 or CI3 fallback controllers.
2. Share Auth, Permissions, and Database Connections
Your CI4 controllers must enforce the exact same Perfex staff roles and client permissions as Classic views. Inject IgniteCore’s PerfexAuthFilter on admin routes, query db_prefix() dynamically via IgniteDatabase, and validate modules with the IgniteCore Compatibility Scanner before packaging releases.
- Apply
perfex_authandperfex_perm:your_capability,viewroute filters instead of checking$_SESSIONmanually. - Never hardcode
tbltable prefixes; always resolve table names through$this->db->prefixTable()or IgniteCore helpers. - Wrap CI4 schema migrations inside idempotent
if (! $this->db->tableExists(...))guards matchinginstall.php.
Common Pitfalls and Quick Fixes
- Class not found errors inside
ci4/controllers: Verify yourignitecore.jsonPSR-4 folder path matches the directory casing on Linux servers (Controllersvscontrollers). - CSRF 403 failures on AJAX POST requests from Classic admin views: Pass Perfex’s
csrfDatatoken in headers or configure the IgniteCore CSRF bridge for matching admin routes. - Unscoped Composer packages crashing older modules: Run
composer install --no-devinside your module only for unique libraries, or rely on IgniteCore’s shared SDK packages.
Frequently Asked Questions
Do I need to maintain two separate databases for dual-mode modules?
No. Both the CI3 fallback layer and the CodeIgniter 4 runtime connect to the exact same Perfex CRM MySQL database and table prefix. IgniteCore reads Classic’s database configuration automatically so records created in CI4 appear immediately inside standard Classic admin reports.
Can a dual-mode module render inside Perfex’s native admin sidebar layout?
Yes. IgniteCore provides a view wrapper helper that injects your CodeIgniter 4 module HTML cleanly inside Perfex’s standard header, sidebar navigation, and footer assets, keeping custom Tailwind or Bootstrap styles scoped tightly without breaking core admin page layouts or global JavaScript.
How should I test dual-mode CI4 modules before releasing to customers?
Run PHPUnit tests against your PSR-4 domain services, execute Playwright smoke tests on both CI4-enabled and CI3-fallback Perfex instances, and scan the final zip package with the IgniteCore Compatibility Scanner to verify zero PHP syntax errors, missing guards, or hook conflicts.
Can existing Perfex CI3 modules be converted incrementally to dual-mode?
Yes. You can leave legacy views and admin hooks running in CI3 while moving complex APIs, report exporters, and webhook handlers into ci4/ one endpoint at a time using IgniteCore’s progressive Strangler Fig migration pattern without halting active feature releases.

Leave a Reply