feat(frameworks): CodeIgniter 3 support#167
Open
darkspock wants to merge 1 commit into
Open
Conversation
Adds a CodeIgniter 3 framework resolver alongside Laravel, so PHP
projects on CI3 (still a sizeable long tail) get the same depth of
indexing.
Three layers of extraction:
1. **Explicit routes** from `application/config/routes.php` —
`$route['pattern'] = 'controller/method'`, the HTTP-verb-scoped
`$route['x']['POST'] = '...'` variant, and CI3 wildcards
(`(:any)`, `(:num)`). Reserved keys (`default_controller`,
`404_override`, `translate_uri_dashes`) are skipped.
2. **Convention routes** synthesized from every public method on each
controller in `application/controllers/**`. CI3 routes by
convention much more than by `routes.php`, so without this the
graph would be near-empty for typical projects. URLs are lowercased
per CI3 routing rules; `_`-prefixed methods, `__construct` and
`__destruct` are excluded. Recognized bases: `CI_Controller`,
`MX_Controller` (HMVC), `MY_Controller`, `REST_Controller`, plus
common project-specific patterns.
3. **Magic-loaded models and libraries** — both `$this->load->model('X')`
/ `$this->load->library('X')` calls and the runtime property
accesses that follow (`$this->ModelName->method()`). On a real
~8k-PHP-file CI3 codebase, only ~0.2% of model usages are explicit
`load->model()` calls; the rest are property accesses on
pre-loaded models that pure AST analysis can't see. The resolver
filters on PascalCase to keep CI3 built-in properties (`$this->load`,
`$this->db`, `$this->input`, …) out — they're all lowercase. False
positives are limited to PascalCase property names that happen to
collide with a real class name elsewhere; in practice this catches
~99% of real usages with negligible noise.
Reference resolution: `controller/method` strings in routes.php
resolve to method nodes in `application/controllers/`, trying both
PascalCase (CI3 file-naming convention) and the literal segment as
fallback.
## Tests
13 new tests in `__tests__/frameworks.test.ts` covering: explicit
routes, HTTP-verb variants, reserved-key filtering, convention routes
(visibility filters, `index` → URL base), subdirectory URL building,
non-controller files, HMVC base classes, `$this->load->model/library()`
extraction, magic property access, dedup across both patterns, and
PascalCase normalization.
Validated end-to-end on a ~8k-PHP-file CI3 project: 2,528 route nodes
emitted, framework detected, and graph edges to `application/models/`
classes match grep with ~99% recall.
## Changelog
Added under `[Unreleased]` so the maintainer can rename when cutting
the next release.
ujjwall9837
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a CodeIgniter 3 framework resolver alongside Laravel. Same shape as the existing PHP support —
FrameworkResolverinsrc/resolution/frameworks/codeigniter.ts, one line in the registry, parameterized tests in the existing framework test file.What it captures
1. Explicit routes from
application/config/routes.php:$route['pattern'] = 'controller/method'$route['x']['POST'] = '...'(:any),(:num)default_controller,404_override,translate_uri_dashes2. Convention routes synthesized from every public method on each controller in
application/controllers/**. CI3 routes by convention much more than viaroutes.php, so without this the graph would be near-empty for typical projects. URLs are lowercased per CI3 routing rules;_-prefixed methods,__construct,__destructare excluded. Recognized controller bases:CI_Controller,MX_Controller(HMVC),MY_Controller,REST_Controller, plus common project-specific patterns (Admin_Controller,Public_Controller,Frontend_Controller,Backend_Controller).3. Magic-loaded models and libraries — both
$this->load->model('X')/$this->load->library('X')calls and the runtime property accesses that follow ($this->ModelName->method()). This is the part that matters most in practice: on a real ~8k-PHP-file CI3 codebase, only ~0.2% of model usages are explicitload->model()calls; the rest are property accesses on pre-loaded models that pure AST analysis can't see. The resolver filters on PascalCase to keep CI3 built-in properties ($this->load,$this->db,$this->input, …) out — they're all lowercase.Reference resolution
controller/methodstrings inroutes.phpresolve to method nodes inapplication/controllers/, trying both PascalCase (CI3 file-naming convention) and the literal segment as fallback.Tests
13 new tests in
__tests__/frameworks.test.ts:publiconly,_-prefix excluded),index→ URL base, subdirectory URL building, non-controller files, HMVC base classesload->model('X'),load->library('X'), dedup, lowercase → PascalCase normalization$this->Foo->bar()captured, lowercase built-ins ($this->db,$this->session,$this->load) excludedAll 81 tests across
frameworks.test.ts,resolution.test.ts, andframeworks-integration.test.tspass.tsc --noEmitclean.Validation on a real CI3 codebase
Indexed an ~8k-PHP-file CI3 project (61k PHP files total before filters):
Restomodel) via the graphgrep99.6% recall vs grep, with edges that grep can't give you (resolves through the framework, not just text matches).
Notes
## [Unreleased]rather than a specific version — easier to rename at release time.package.json/package-lock.json— leaving release cadence to you.importsfor consistency with how Laravel emits its handler references; the resolution pipeline routes these through the standard name-matcher.Test plan
npm test— 81/81 framework + resolution + integration tests passnpx tsc --noEmit— cleanlaravelResolver) — not run here, but the changes are additive andlaravel.tsis untouched