PHPackages                             jhofm/ph-puml - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. jhofm/ph-puml

ActiveProject[Testing &amp; Quality](/categories/testing)

jhofm/ph-puml
=============

Generates PlantUML class diagrams from PHP code

v0.6.0(5y ago)274804[19 issues](https://github.com/jhofm/ph-puml/issues)[1 PRs](https://github.com/jhofm/ph-puml/pulls)MITPHPPHP ^7.4

Since Dec 25Pushed 3y ago2 watchersCompare

[ Source](https://github.com/jhofm/ph-puml)[ Packagist](https://packagist.org/packages/jhofm/ph-puml)[ RSS](/packages/jhofm-ph-puml/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (12)Versions (10)Used By (0)

PhPuml
======

[](#phpuml)

[![Packagist](https://camo.githubusercontent.com/c503ef1e8e1ab93f527e1dfe3207dda7250bf293d7d19a33d94c7a666e6b8625/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a686f666d2f70682d70756d6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jhofm/ph-puml)[![Packagist](https://camo.githubusercontent.com/a0c9edf3a2d641dab820b89a656c6a6c95102a548f84b3af7a6c3afa723a6580/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a686f666d2f70682d70756d6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jhofm/ph-puml)[![Packagist](https://camo.githubusercontent.com/90063be0fabc695f99ab1b959a863734b1b96ee5fe1a95a04c29cce07b0245c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6a686f666d2f70682d70756d6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jhofm/ph-puml)[![CI Workflow](https://camo.githubusercontent.com/bc3d4c01c91bcca616a818e7f5c6445b5f0c222d9eaf808d5a80de9787c598e5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6a686f666d2f70682d70756d6c2f43492e7376673f7374796c653d666c61742d737175617265)](https://github.com/jhofm/ph-puml/actions)

About PhPuml
------------

[](#about-phpuml)

PhPuml generates PlantUML class diagrams from PHP code.

Here's a class diagram of the tool, created by itself:

[![PhPuml class diagram](./doc/img/ph-puml.svg)](./doc/img/ph-puml.svg)

Features
--------

[](#features)

- Convenient installation via composer
- Generate PlantUml files without having PlantUML installed or generate all supported formats (png, svg, latex, etc) using a `plantuml.jar` executable
- Packages from Namespaces
- Generates inheritance relationships for classes, interfaces and traits
- Generates class properties &amp; method signatures, including type hints from @var doc comments
- Dependencies are inferred from constructor argument types (assumes dependency injection)
- Associations are inferred from "new" expressions (&lt;&lt;creates&gt;&gt;) and "throw" statements (&lt;&lt;throws&gt;&gt;)
- Types renderable with fully qualified or short names (independently configurable for interfaces, traits, classes, properties and method arguments)
- Works on Linux (tested), Windows (tested), macOS (probably)

Installation
------------

[](#installation)

The easiest way to install PhPuml is as a composer project.

```
$ composer create-project jhofm/ph-puml
```

A [phar](https://www.php.net/manual/en/book.phar.php) version of the tool is created a part of the build process, but currently not reliably downloadable. However with the project already installed, you can create the phar yourself using [clue/phar-composer](https://github.com/clue/phar-composer).

```
$ curl -JL -o phar-composer.phar https://clue.engineering/phar-composer-latest.phar
$ php phar-composer.phar ph-puml
$ php ph-puml.phar
```

Quick Start
-----------

[](#quick-start)

The `ph-puml` script will output PlantUML syntax describing all PHP files found in the current folder when run without any parameters.

```
$ cd mycode/src
$ ph-puml
```

You can specify a relative or absolute path to a target directory or file as the first argument.

```
$ ph-puml mycode/src
```

The second optional argument is the output path. The console's standard output will be used if none is specified.

The following two commands produce the same result:

```
$ ph-puml mycode/src > class.puml
$ ph-puml mycode/src class.puml
```

Advanced features
-----------------

[](#advanced-features)

### Output formats

[](#output-formats)

PhPuml generates PlantUML puml file syntax by default, but you can also export most output formats supported by PlantUML directly.

Currently, these are:

- eps (Postscript)
- latex (LaTeX/Tikz)
- latex:nopreamble (LaTeX/Tikz without preamble)
- png (PNG image)
- svg (SVG vector image)
- scxml (SCXML state chart, seems broken in PlantUML Version 1.2020.26)
- txt (ASCII art)
- utxt (ASCII art with unicode letters)
- vdx (VDX image)
- xmi (XMI metadata description)

This requires a Java Runtime Environment on the machine running PhPuml. See the [PlantUML guide](https://plantuml.com/starting) for more information. You also need to either:

- provide a path to a `plantuml.jar` file

```
$ ph-puml /my/code/dir -p /somedir/plantuml.jar -f svg > ~/mycode.svg
```

- or install the optional [jawira/plantuml](https://packagist.org/packages/jawira/plantuml) package

```
$ composer create-project jhofm/ph-puml
$ cd ph-puml
$ composer require jawira/plantuml
$ ph-puml /my/code/dir -f svg > ~/mycode.svg
```

### Path filters

[](#path-filters)

If the input path is a directory, PhPuml will determine the code files to analyze using a set of inclusion and exclusion rules. By default, files in the directory tree with the file extension `.php` are included, as long as none of their parent folders are called `vendor`.

You can override the filter rules with command line options. All rules are regular expressions. You can use several at the same time. For example the following command will NOT skip files from `vendor` folders, and analyze files in the `includes` folder with the file extension `.inc` as well.

```
$ ph-puml -e -i "/\.php$/" -i "/^includes/.*\.inc$/"
```

The command will fail when attempting to parse files that do not contain valid PHP code.

### Namespaces

[](#namespaces)

Namespaced classes, interfaces and traits are rendered with fully qualified names by default, while property and method argument types are not. This behaviour can be customized using the `namespaced-types`/`t` option.

```
$ ph-puml -t cmp # render all types as FQNs
$ ph-puml -t # render short types only
$ ph-puml -t c # render only classlikes (classes, interfaces & traits) as FQNs
```

### Relations to external types

[](#relations-to-external-types)

Relations to types that have not been analyzed are not rendered by default to reduce clutter in the generated diagram. This included built-in Types like \\Exception etc. Add the following option to include these relations.

```
$ ph-puml -x false # include relations to types that were not analyzed
```

### Help

[](#help)

PhPuml uses `symfony/command`, so a help page including all supported arguments and options is available.

```
$ ph-puml -h
```

Omitting namespaces for classes, interfaces or traits may cause relations to be drawn wrong if unqualified type names are repeated in the analyzed sources.

Limitations
-----------

[](#limitations)

- Auto generated class diagrams will probably never exactly meet your needs, but provide a starting point for manual refinement (and save mind-numbing work).
- PhPuml is able to handle huge amounts of code files, but limiting diagrams to as few classes as needed is always good idea.
- Cleaner code will yield better results. Type hints and Namespaces help a whole lot, for example.
- There's a lot of polishing still to be done, like inferring additional relation types or providing more customisations.

Troubleshooting
---------------

[](#troubleshooting)

- `Uncaught Error: Class Composer\InstalledVersions not found`: PhPuml requires Composer 2
- `require(): Failed opening required ...`: Run composer install

Acknowledgements
----------------

[](#acknowledgements)

This would have been exponentially more difficult to do without [Nikita Popov](https://github.com/nikic)'s [PHP-Parser](https://github.com/nikic/PHP-Parser), so many thanks for that. [Symfony](https://github.com/symfony) helped a lot, too. Basically every dependency i use is maintained by kings, queens and total legends. &lt;3

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance6

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

8

Last Release

1953d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e045a9a1c560eed33f74acc626f6756780538a55988e9f5741d6d14b0f23daca?d=identicon)[jhofm](/maintainers/jhofm)

---

Top Contributors

[![jhofm](https://avatars.githubusercontent.com/u/8502402?v=4)](https://github.com/jhofm "jhofm (12 commits)")

---

Tags

architectureclass-diagramcode-qualitygeneratorphpplantumlplantuml-diagramsplantuml-generatorumluml-diagram

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/jhofm-ph-puml/health.svg)

```
[![Health](https://phpackages.com/badges/jhofm-ph-puml/health.svg)](https://phpackages.com/packages/jhofm-ph-puml)
```

###  Alternatives

[behat/behat

Scenario-oriented BDD framework for PHP

4.0k96.8M2.0k](/packages/behat-behat)[symfony/maker-bundle

Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.

3.4k111.1M567](/packages/symfony-maker-bundle)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
