codegraph-php
PHP parser for CodeGraph - extracts code entities and relationships from PHP source files.
Features
- Parse PHP 7.x and 8.x source files
- Extract functions, classes, interfaces, traits, and enums
- Track relationships (calls, imports, inheritance, implementations)
- Support for namespaces and use statements
- Full integration with codegraph-parser-api
Supported PHP Constructs
| PHP Construct | Maps To |
|---|---|
function |
FunctionEntity |
class method |
FunctionEntity (with parent_class) |
class |
ClassEntity |
interface |
TraitEntity |
trait |
TraitEntity |
enum (PHP 8.1+) |
ClassEntity (with enum attribute) |
namespace |
ModuleEntity |
use statements |
ImportRelation |
extends |
InheritanceRelation |
implements |
ImplementationRelation |
Trait use |
ImplementationRelation |
Quick Start
use PhpParser;
use CodeParser;
use CodeGraph;
use Path;
Examples
Run the basic example:
Testing
# Run all tests
# Run specific test
# Run with verbose output
Benchmarks
License
Apache-2.0