Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nodes analyzer: v0.2 refatoring #16

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7292abd
v0.2 Refactoring
codeliner Mar 22, 2018
a1590d6
Rm no longer supported output formatters
codeliner Mar 22, 2018
4e15585
Catch IdentifierNotFound errors
codeliner Mar 22, 2018
fa6b8f8
Nodes and edges should be an array
codeliner Mar 22, 2018
02495d5
Use node name instead of title
codeliner Mar 22, 2018
8ee50eb
Replace pro icon with free one
codeliner Mar 22, 2018
4efa79b
Introduce parentColor
codeliner Mar 22, 2018
c85b8bd
Use NodeIcon and expand options to also use fa brand/regular, links
codeliner Mar 23, 2018
43d88f3
Check if event recorder calls others recording methods
codeliner Mar 23, 2018
37699d4
Check if invoked recorders are found
codeliner Mar 23, 2018
208c261
CS fixes
codeliner Mar 23, 2018
e74c7dd
Add finalizer
codeliner Mar 23, 2018
2763702
Configurable node class
codeliner Mar 23, 2018
f72a5a8
Configure travis.ci
codeliner Mar 23, 2018
d27b4fe
Add badges and support hints
codeliner Mar 23, 2018
0e31598
Add docs
codeliner Mar 24, 2018
526c0c1
Add more docs
codeliner Mar 25, 2018
995d29f
Add link to prooph-do
codeliner Mar 25, 2018
d5bdfa4
Always use $messageFlow->setEdge
codeliner Mar 26, 2018
b20e801
Add file info in case of an exception
codeliner Mar 26, 2018
80f12ab
Set edge for message producer services
codeliner Mar 29, 2018
842ffad
Rm namespace from message producer service name
codeliner Mar 29, 2018
acfc5d1
Detect event recorders fetched from inherited methods
codeliner Mar 29, 2018
af2b726
Get and remove node/edge methods
codeliner Mar 29, 2018
970df57
Remove linked edges of removed node
codeliner Mar 29, 2018
94b6e6e
Replace listener and producer collectors w/ messaging collector
codeliner Mar 30, 2018
6853a55
Configurable EventRecorder check function
codeliner Mar 30, 2018
c17dce9
Fix wrong unset in removeNode
codeliner Mar 31, 2018
5b5b059
Fix wrong unset in removeEdge
codeliner Mar 31, 2018
0d62b13
Detect message production if factory is used
codeliner Apr 2, 2018
9c986aa
Check if $node->var->name is set
codeliner Apr 2, 2018
75c4f17
Remove method filter public for event listener checks
codeliner Apr 2, 2018
42e7ba7
Message producers can create more than one message
codeliner Apr 2, 2018
3ff9b90
Allow symfony/console 3.2 as well
codeliner Apr 5, 2018
91a6cc8
All scan helper funcs should be public
codeliner May 4, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 6 additions & 119 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,131 +1,23 @@
language: php

sudo: false
dist: trusty

matrix:
fast_finish: true
include:
- php: 7.1
dist: trusty
sudo: true
env:
- DEPENDENCIES=""
- DRIVER="pdo_mysql"
- DB=mariadb_10.2
addons:
mariadb: '10.2'
- php: 7.1
dist: trusty
sudo: true
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- DRIVER="pdo_mysql"
- DB=mariadb_10.2
addons:
mariadb: '10.2'
- php: 7.1
dist: trusty
sudo: true
env:
- DEPENDENCIES=""
- DRIVER="pdo_mysql"
- DB=mariadb_10.2
- DB_ATTR_ERRMODE=2 # \PDO::ERRMODE_EXCEPTION
addons:
mariadb: '10.2'
- php: 7.1
sudo: true
env:
- DEPENDENCIES=""
- DRIVER="pdo_mysql"
- DB=mysql_5.7
- php: 7.1
sudo: true
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- DRIVER="pdo_mysql"
- DB=mysql_5.7
- php: 7.1
sudo: true
env:
- DEPENDENCIES=""
- DRIVER="pdo_mysql"
- DB=mysql_5.7
- DB_ATTR_ERRMODE=2 # \PDO::ERRMODE_EXCEPTION
- php: 7.1
env:
- DEPENDENCIES=""
- DRIVER="pdo_pgsql"
- DB=postgres_9.4
addons:
postgresql: '9.4'
- php: 7.1
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- DRIVER="pdo_pgsql"
- DB=postgres_9.4
addons:
postgresql: '9.4'
- php: 7.1
env:
- DEPENDENCIES=""
- DRIVER="pdo_pgsql"
- DB=postgres_9.4
- DB_ATTR_ERRMODE=2 # \PDO::ERRMODE_EXCEPTION
addons:
postgresql: '9.4'
- php: 7.1
dist: trusty
env:
- DEPENDENCIES=""
- DRIVER="pdo_pgsql"
- DB=postgres_9.5
addons:
postgresql: '9.5'
- TEST_COVERAGE=true
- php: 7.1
dist: trusty
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- DRIVER="pdo_pgsql"
- DB=postgres_9.5
addons:
postgresql: '9.5'
- php: 7.1
dist: trusty
- php: 7.2
env:
- DEPENDENCIES=""
- DRIVER="pdo_pgsql"
- DB=postgres_9.5
- DB_ATTR_ERRMODE=2 # \PDO::ERRMODE_EXCEPTION
addons:
postgresql: '9.5'
- php: 7.1
dist: trusty
env:
- DEPENDENCIES=""
- EXECUTE_CS_CHECK=true
- TEST_COVERAGE=true
- DRIVER="pdo_pgsql"
- DB=postgres_9.6
addons:
postgresql: '9.6'
- php: 7.1
dist: trusty
- php: 7.2
env:
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- DRIVER="pdo_pgsql"
- DB=postgres_9.6
addons:
postgresql: '9.6'
- php: 7.1
dist: trusty
env:
- DEPENDENCIES=""
- DRIVER="pdo_pgsql"
- DB=postgres_9.6
- DB_ATTR_ERRMODE=2 # \PDO::ERRMODE_EXCEPTION
addons:
postgresql: '9.6'

cache:
directories:
Expand All @@ -136,18 +28,13 @@ cache:
before_script:
- mkdir -p "$HOME/.php-cs-fixer"
- phpenv config-rm xdebug.ini
- VENDOR=$(echo $DB | cut -d'_' -f 1)
- if [[ $DB == 'mysql_5.7' ]]; then bash .travis.install-mysql-5.7.sh; fi
- if [[ $DRIVER == 'pdo_mysql' ]]; then mysql -e 'create database event_store_tests;'; fi
- if [[ $DRIVER == 'pdo_pgsql' ]]; then psql -c 'create database event_store_tests;' -U postgres; fi
- composer self-update
- composer update $DEPENDENCIES

script:
- cp phpunit.xml.$VENDOR phpunit.xml
- if [[ $TEST_COVERAGE == 'true' ]]; then php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml; else ./vendor/bin/phpunit; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/docheader check src/ tests/; fi
- ./vendor/bin/php-cs-fixer fix -v --diff --dry-run
- ./vendor/bin/docheader check src/ tests/

after_success:
- if [[ $TEST_COVERAGE == 'true' ]]; then php vendor/bin/coveralls -v; fi
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Copyright (c) 2016-2017, prooph software GmbH
Copyright (c) 2016-2017, Sascha-Oliver Prolic
Copyright (c) 2017-2018, prooph software GmbH
Copyright (c) 2017-2018, Sascha-Oliver Prolic
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
51 changes: 30 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# prooph message flow analyzer

A static code analyzer to extract message flow of a prooph project
[![Build Status](https://travis-ci.org/prooph/message-flow-analyzer.svg?branch=master)](https://travis-ci.org/prooph/message-flow-analyzer)
[![Coverage Status](https://coveralls.io/repos/github/prooph/message-flow-analyzer/badge.svg?branch=master)](https://coveralls.io/github/prooph/message-flow-analyzer?branch=master)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/prooph/improoph)

A static code analyzer to extract a message flow of a prooph project. Results can be visualized in the [prooph Mgmt UI](https://github.com/prooph/event-store-mgmt-ui).

![Model Exploration](https://github.com/prooph/proophessor/blob/master/assets/prooph_do_exploration.gif)

## Installation

Expand All @@ -16,12 +22,12 @@ An example of a default config can be found in the [test example project](https:
## Run

```bash
php vendor/bin/prooph-analyzer project:analyze
php vendor/bin/prooph-analyzer project:analyze -vvv
```

## Why?

The prooph message flow analyzer scans your project for prooph messages and collects information how these messages flow through your project source code :)
The prooph message flow analyzer scans your project for prooph messages and collects information how these messages flow through your system :)

The analysis contains information about:

Expand All @@ -32,19 +38,11 @@ The analysis contains information about:

The message flow is written to an output file (`prooph_message_flow.json` by default).

For now that's it. But imagine what you can do with this information! We'll add different output formatters to generate config for d3js or draw.io.
The message flow analyzer will also be part of the upcoming `event-store-mgmt-ui` and will allow you to connect the message flow with your event streams
for debugging and monitoring.

## How?

The package uses the excellent libraries [roave/better-reflection](https://github.com/Roave/BetterReflection)
and [nikic/php-parser](https://github.com/nikic/PHP-Parser) (which is used by Roave/BetterReflection internally, too)

## WIP

`prooph/message-flow-analyzer` and the `event-store-mgmt-ui` are work in progress. There is no roadmap defined yet. If you think your project could benefit
from a stable version and you or your company would like to support development then [get in touch](http://getprooph.org/#get-in-touch).

## Filters

Expand All @@ -59,21 +57,32 @@ interesting in the class it can add this information to the `MessageFlow`.

Again `prooph/message-flow-analyzer` ships with default class visitors (see example config) which can be found in the [Visitor dir](https://github.com/prooph/message-flow-analyzer/tree/master/src/Visitor).

## Documentation

Documentation is [in the doc tree](docs/), and can be compiled using [bookdown](http://bookdown.io).

```console
$ php ./vendor/bin/bookdown docs/bookdown.json
$ php -S 0.0.0.0:8080 -t docs/html/
```

## Run it against proophessor-do

You can see `prooph/message-flow-analyzer` in action by running it against [proophessor-do](https://github.com/prooph/proophessor-do).
You can see the `prooph/message-flow-analyzer` in action by running it against [proophessor-do](https://github.com/prooph/proophessor-do) or [proophessor-do-symfony](https://github.com/prooph/proophessor-do-symfony).

## Support

- Ask questions on Stack Overflow tagged with [#prooph](https://stackoverflow.com/questions/tagged/prooph).
- File issues at [https://github.com/prooph/message-flow-analyzer/issues](https://github.com/prooph/message-flow-analyzer/issues).
- Say hello in the [prooph gitter](https://gitter.im/prooph/improoph) chat.

1. Clone proophessor-do
2. Add `prooph/message-flow-analyzer: dev-master` to the `require-dev` config of proophessor-do's `composer.json`
3. Run composer install
4. Copy [prooph_analyzer.json](https://github.com/prooph/message-flow-analyzer/blob/master/tests/Sample/DefaultProject/prooph_analyzer.json) into root dir of proophessor-do
5. Copy [ExcludeBlacklistedFiles.php](https://gist.github.com/codeliner/6bae2c3a5de0a9f93e1d2143f7196f75#file-excludeblacklistedfiles-php) into `src/Infrastructure/ProophAnalyzer`.
This is needed because proophessor-do contains a prepared factory for mongodb connection but mongo is not installed by default so the mongo classes cannot be loaded.
6. Add `"Prooph\\ProophessorDo\\Infrastructure\\ProophAnalyzer\\ExcludeBlacklistedFiles"` as last entry in the `prooph_analyzer.json` `fileInfoFilters` array.
7. Run `php vendor/bin/prooph-analyzer project:analyze` and watch the generated output file `prooph_message_flow.json`
## Contribute

If this is too much work right now and you only want to see the result: [prooph_message_flow.json](https://gist.github.com/codeliner/6bae2c3a5de0a9f93e1d2143f7196f75#file-prooph_message_flow-json)
Please feel free to fork and extend existing or add new plugins and send a pull request with your changes!
To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.

## License

Released under the [New BSD License](LICENSE).


4 changes: 2 additions & 2 deletions bin/prooph-analyzer
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<?php
/**
* This file is part of the prooph/message-flow-analyzer.
* (c) 2017-2017 prooph software GmbH <[email protected]>
* (c) 2017-2017 Sascha-Oliver Prolic <[email protected]>
* (c) 2017-2018 prooph software GmbH <[email protected]>
* (c) 2017-2018 Sascha-Oliver Prolic <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"require": {
"roave/better-reflection": "^2.0",
"nikic/php-parser": "^3.1",
"symfony/console": "^3.3 || ^4.0"
"symfony/console": "^3.2 || ^4.0"
},
"autoload": {
"psr-4": {
Expand Down
25 changes: 25 additions & 0 deletions docs/analyzer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# CLI Command

The prooph message flow analyzer ships with a CLI command to analyze a project or parts of it.

## Options

Run the following command to get an overview of your options.

```bash
php vendor/bin/prooph-analyzer project:analyze --help
```

## Run With Defaults

```bash
php vendor/bin/prooph-analyzer project:analyze -vvv
```
By default the analyzer uses current working dir as the root of the analysis.
It looks for a config file called `prooph_analyzer.json`. More on this in the configuration section.

A successful run produces a `prooph_message_flow.json` with the results. This file can be imported into
the [prooph Mgmt UI](https://github.com/prooph/event-store-mgmt-ui) message flow app.

*Note: It is recommended to always run the command in very verbose mode **-vvv** to get detailed exception traces in case of an error.*

14 changes: 14 additions & 0 deletions docs/bookdown.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"title": "Message Flow Analyzer",
"content": [
{"intro": "introduction.md"},
{"analyzer": "analyzer.md"},
{"messageflow": "message-flow.md"},
{"config": "configuration.md"},
{"troubleshooting": "troubleshooting.md"}
],
"tocDepth": 1,
"numbering": false,
"target": "./html",
"template": "../vendor/prooph/bookdown-template/templates/main.php"
}
Loading