Generate PlantUML sequence diagrams for PHP using XDebug callgrind files
To setup and run the application you will need:
- PHP ^7.0
- Composer
If you want to use the "image" export option, you will additionally need:
- checkout this repository
- run composer install
By default, running the command will take the entire input of the given callgrind file, and use it to produce a PlantUML format sequence diagram. Keep in mind that these will be very large for most applications. To limit the size of the diagram, see the filters section. Rendering large diagrams will require a lot of RAM and may require tweaking the memory settings for the JVM.
php application.php generate <callgrind-file>
On runtime, the user can choose between the following export formats:
- Screen
- File
- Image
When using this option, the PlantUML sequence diagram will be outputted to StdOUT in text representation. No further configuration is needed for this option.
When using this option, the PlantUML sequence diagram will be saved to the specified file location, and will contain the sequence diagram in text representation. After choosing this option you will be prompted with:
- Output file name
- Output file location
When using the image option, the application will use the PlantUML and Graphiz DOT application to produce a PNG image containing the sequence diagram. After choosing this option you will be prompted with:
- DOT file location
- JAR file location
- Max memory (for JRE)
- Max diagram size (for PlantUML)
- Output file name
- Output file location
To be able to control the size of you diagram (and focus on a specific part) you can apply filters.
This filter will recursively filter out calls that happen inside the given method call. The call itself will still be shown in the sequence diagram. Multiple not-deeper-than filters can be applied!
php application.php generate <callgrind-file> --not-deeper-than MyClass::someMethod
In this example, any calls happening within someMethod() in class MyClass will not be shown in the sequence diagram.
php application.php generate <callgrind-file> --not-deeper-than Some\NameSpace%
In this example, any calls happening within classes in the namespace Some\Namespace will not be shown in the sequence diagram.
php application.php generate <callgrind-file> --not-deeper-than MyClass::someMethod --not-deeper-than AnotherClass::anotherMethod
In this example, any calls happening within someMethod() in class MyClass, or within anotherMethod() in AnotherClass will not be shown in the sequence diagram.
When using this filter, only the given call and any calls happening inside of it will be shown in the sequence diagram.
php application.php generate <callgrind-file> --start-from MyApp\HomeController::homePageAction
This filter will filter out any calls to the PHP API that do not perform any deeper calls.
php application.php generate <callgrind-file> --exclude-native-function-calls 0