qossmic / deptrac Goto Github PK
View Code? Open in Web Editor NEWKeep your architecture clean.
Home Page: https://qossmic.github.io/deptrac
License: MIT License
Keep your architecture clean.
Home Page: https://qossmic.github.io/deptrac
License: MIT License
analog zu
--formatter-graphviz --formatter-graphviz-format=dot --formatter-graphviz-path=file.png --formatter-json
I get the following error (on PHP 5.5):
Warning: Invalid argument supplied for foreach() in phar:///path/to/deptrac.phar/src/Command/AnalyzeCommand.php on line 151
which seems to be caused by using the tilde in the exclude_files-section in my depfile.yml
:
exclude_files: ~
The same depfile works fine on a system using PHP 7.0.5.
Right now when running deptrac generates some noise related to generating the AstMap, e.g. for each file being parsed.
It would be nice if this output is hidden by default and then only being displayed when using -v
.
I want to omit generating a dependency graph image by running deptrac with the following options:
php deptrac.phar --formatter-graphviz=0 --formatter-graphviz-display=0
but it will still open image previewer with the dependency graph.
Iterate over classes not over dependencies (e.g. GraphvizOutputFormatter)
make build
gave me an error that phar.readonly
is "On" in php.ini.
After looking into my php.ini (/etc/php5/cli/php.ini) i noticed
;phar.readonly = On
As you can see its commented, so On seems to be the default behavior as well.
Setting it to Off and uncommenting it solved the issue for me.
My deptrac phar is bin/deptrac
(executable) and I have the following config:
# .depfile/top_layers.yml
paths:
- src
exclude_files: ~
layers:
- name: Domain
collectors:
- type: className
regex: .*\\Domain\\.*
- name: Application
collectors:
- type: className
regex: .*\\Application\\.*
- name: Infrastructure
collectors:
- type: className
regex: .*\\Infrastructure\\.*
- name: Tests
collectors:
- type: className
regex: .*\\Tests\\.*
ruleset:
Domain: ~
Application:
- Domain
Infrastructure:
- Application
- Domain
Tests:
- Infrastructure
- Application
- Domain
When running bin/deptrac analyze .dotfile/top_layers.yml
, I get:
Warning: Invalid argument supplied for foreach() in phar:///path/to/myproject/bin/deptrac/src/Command/AnalyzeCommand.php on line 151
Call Stack:
0.0007 357264 1. {main}() /path/to/myproject/bin/deptrac:0
0.0197 1119120 2. require('phar:///path/to/myproject/bin/deptrac/deptrac.php') /path/to/myproject/bin/deptrac:10
0.0764 3609344 3. Symfony\Component\Console\Application->run() phar:///path/to/myproject/bin/deptrac/deptrac.php:29
0.0802 3891216 4. Symfony\Component\Console\Application->doRun() phar:///path/to/myproject/bin/deptrac/vendor/symfony/console/Application.php:123
0.0824 3891216 5. Symfony\Component\Console\Application->doRunCommand() phar:///path/to/myproject/bin/deptrac/vendor/symfony/console/Application.php:192
0.0828 3891216 6. Symfony\Component\Console\Command\Command->run() phar:///path/to/myproject/bin/deptrac/vendor/symfony/console/Application.php:844
0.0836 3893664 7. SensioLabs\Deptrac\Command\AnalyzeCommand->execute() phar:///path/to/myproject/bin/deptrac/vendor/symfony/console/Command/Command.php:259
0.1034 4332464 8. SensioLabs\Deptrac\Command\AnalyzeCommand->collectFiles() phar:///path/to/myproject/bin/deptrac/src/Command/AnalyzeCommand.php:87
0.1383 5010408 9. array_filter() phar:///path/to/myproject/bin/deptrac/src/Command/AnalyzeCommand.php:158
0.1717 5045760 10. SensioLabs\Deptrac\Command\AnalyzeCommand->SensioLabs\Deptrac\Command\{closure}() phar:///path/to/myproject/bin/deptrac/src/Command/AnalyzeCommand.php:158
This stack trace appears quite a few time and I still get the graph as a result.
It is also very common to have dotfiles for this kind of tool configuration. In my case that would help to be a bit consistent.
No big deal though.
at the moment the dumped depfile (running deptrac init) is not very useful.
some will struggle why foo/vendors doesn't exist.
deptrac is a standalone application and shouldn't be used as a project dependency.
for now it would be great if we could print a warning.
Would it be possible to add a legend in the generated graph?
It would be nice to have a command to list all the classes included in a layer, ex:
$ deptrac view Controller
3 class found:
- App\Controller\Ctrl1
- App\Controller\Ctrl2
- App\Controller\Ctrl3
Actually before jumping into a "directory collector" a question comes: why excluding the test(s)
folder? I would say everything in src
should not depend on what is in tests
.
I think it would be nice to add a third color for the links violating the rules.
I personally would put it red... but then requires to change the color of the current red link into another one.
deptrac
requires all Symfony components in ~2.7. It can be interesting to add Symfony 3 components support.
Also, this library is incompatible with sensiolabs-de/deprecation-detector: it requires nikic/php-parser
~2.0, but deprecation-detector
requires nikic/php-parser
^1.3.
Somehow I'm declaring 4 layers, but on the graph I only get 3... I don't see any error on the configuration side (runs fine), how can this be?
It would be nice if there was a function to analyze only one specific file against some deptrac configuration. It would be a first step to integrate a validator in an IDE.
That would be awesome! Imagine you import some namespaced class and PhpStorm (or another favorite IDE) instantly marking this as an error in your file because it violates your defined architecture.
Let's say I have the following tree:
src
|-- Domain
|-- Application
| \-- Handler
\ Infrastructure
|-- Action
\-- Responder
There's the following layers & ruleset:
layers:
layers:
- name: Application
collectors:
- type: className
regex: .*\\Application\\.*
- name: Domain
collectors:
- type: className
regex: .*\\Domain\\.*
- name: Infrastructure
collectors:
- type: className
regex: .*\\Infrastructure\\.*
ruleset:
Application:
- Domain
Domain: ~
Infrastructure:
- Application
- Domain
This gives me the following schema:
Now I would like to go a step further and specify more advanced rules.
For example, I can break down Application
in two:
The global rules defined by the first graph are not changing, but inside Application
, I'm would like to specify that no Handlers
shouldn't depend on `Handlers:
But that doesn't affect the rules defined to the parent Application
, hence the global view would be:
Another cases slightly more complex: I'm breaking down Infrastructure
as following:
We hence have not 3 sublayers but 6:
Actions
Responders
no Actions & no Responders
no Actions
= no Actions & no Responders
U Responders
no Responders
= no Actions & no Responders
U Actions
Actions &
Responders`*: U
is union
In Infrastructure
, with those sublayers, I would like to define the following rules:
Actions
can depend on no Actions
Responders
can depend on no Actions & no Responders
Which gives the following graph:
As before, this shouldn't affect the rules defined on the parent layer Infrastructure
.
While this is partly doable right now, there is a lot of cons:
no Handlers
or no Actions
without being repetitive; repetition which may lead to: 1. an error in the regex, hence you get the layer wrongs, 2. missing a sublayer, hence you could think of having Application
devided in Handlers
and no Handlers
but due to a little mistake you have Handlers
U no Handlers
≠ Application
.You would actually get something like:
If I understand correctly from the code, Collectors don't have a configuration per se, but rather have access to all the arguments passed to the collector. As a result, they handle those values as they wish without any validation of any kind.
Example:
// src/Collector/ClassNameCollector.php
private function getRegexByConfiguration(array $configuration)
{
if (!isset($configuration['regex'])) {
throw new \LogicException('ClassNameCollector needs the regex configuration.');
}
return $configuration['regex'];
}
Wouldn't it be better to change that and have one configuration per collector? That way we could add a validation step when creating the collector configuration.
Copy/paste the curl command from the doc doesn't work:
$ curl -LS https://get.sensiolabs.de/deptrac.phar -o deptrac.phar
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
curl: (60) SSL certificate problem: Invalid certificate chain
More details here: http://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.
I may be wrong when saying that, I didn't run any blackfire profile neither really dig in the code, but I see the Parsing File x
each time I run the command, which I guess could be skipped somehow if there was any cache layer.
Deptrac needs a Collector, that watches method names.
Use case:
I don't want, that my WhatEverBundle uses the createQueryBuilder() Method.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.