Code Monkey home page Code Monkey logo

php-plantumlwriter's Introduction

php-plantumlwriter

Build Status Scrutinizer Code Quality SensioLabsInsight License

Description

A tool to create PlantUML class diagrams from your PHP source.

Currently the following language features are supported:

  • Property and method visibility
  • Static properties and methods
  • Method return types from doc comment
  • Parameter types from type hinting and doc comment
  • Parameter default values
  • Class constants with value
  • Property types from doc comment
  • Property default values
  • Implemented interfaces and parent classes
  • Abstract classes

Requirements

To generate the PlantUML code a decent version of PHP will suffice. And you need Composer to install the dependencies:

But for image generation you need:

Phar generation

php-plantumlwriter uses Box 2 library to generate a single .phar file containing everything required for the usage.

To create the .phar file from sources just run:

$ box build

Usage

To generate the PlantUML code for WriteCommand.php run

php bin/php-plantumlwriter write src/Flagbit/Plantuml/Command/WriteCommand.php > WriteCommand.puml

which will output

@startuml
class Flagbit.Plantuml.Command.WriteCommand {
    #configure()
    #execute(input: Symfony.Component.Console.Input.InputInterface, output: Symfony.Component.Console.Output.OutputInterface)
}
class Flagbit.Plantuml.Command.WriteCommand extends Symfony.Component.Console.Command.Command
@enduml

Now you can convert your puml file to a png file.:

java -jar plantuml.jar WriteCommand.puml

The resulting png should look like this:

WriteCommand Class Diagram

If you have a large class with lots of methods you can suppress method printing using the --without-methods flag:

php bin/php-plantumlwriter write --without-methods path/to/your/LargeClass.php

Other available options are --without-properties and --without-constants.

You can also generate a whole directory at once:

php bin/php-plantumlwriter write path/to/directory

Or multiple files or directories:

php bin/php-plantumlwriter write path/to/ClassOne.php path/to/ClassTwo.php path/to/directory

Known Issues

  • Imported classes are currently not handled correctly if read from doc comment (use-Statement is not fully evaluated) which affects return values and property types. use Namespace\B will be evaluated and expanded but use Namespace\B as C is not yet de-aliased.
  • The Namespace Seperator is "." and not "".
  • Traits are not yet supported. See #4

Future Plans

  • Add support for class relations, maybe with quantifiers. This could be parsed from the doc comments. We could also guess the foreign quantifier (@var OtherClass as "..1" and @var OtherClass[] as "..*"), but we can't determine our quantifier. If doctrine annotations are present we can use them.
  • Evaluate Implementation of Visitor Pattern
  • Implement own set of Interfaces

Alternatives

php-plantumlwriter's People

Contributors

davidfuhr avatar emanueleminotto avatar bravoman avatar

Watchers

hadi avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.