Skip to content

Commit

Permalink
Merge pull request #11 from hirokinoue/handle-xdebug
Browse files Browse the repository at this point in the history
パフォーマンスを改善する
  • Loading branch information
hirokinoue authored Mar 3, 2024
2 parents 9645c5c + a5cf9cd commit 553dc86
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ $ ./vendor/bin/dependency-visualizer -h

Usage: dependency-visualizer [options] <target php file>
Options:
-d: Load Xdebug.
-h: Show this help.
-l: Output log to current directory.
-m: Draw methods in diagram.
Expand Down
12 changes: 12 additions & 0 deletions bin/dependency-visualizer
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Hirokinoue\DependencyVisualizer;

use Composer\XdebugHandler\XdebugHandler;
use Hirokinoue\DependencyVisualizer\Config\Config;
use Hirokinoue\DependencyVisualizer\Exporter\Exporter;
use Hirokinoue\DependencyVisualizer\Exporter\PlantUmlExporter;
Expand All @@ -21,13 +22,19 @@ list($options, $file) = parseArgs($argv);
if ($options['help']) {
echo 'Usage: dependency-visualizer [options] <target php file>' . PHP_EOL;
echo 'Options:' . PHP_EOL;
echo ' -d: Load Xdebug.' . PHP_EOL;
echo ' -h: Show this help.' . PHP_EOL;
echo ' -l: Output log to current directory.' . PHP_EOL;
echo ' -m: Draw methods in diagram.' . PHP_EOL;
echo ' -s: Output analysis results in string format.' . PHP_EOL;
exit(0);
}

if ($options['loadXdebug'] === false) {
$xdebug = new XdebugHandler('dependency-visualizer');
$xdebug->check();
unset($xdebug);
}
Config::initialize(\getcwd());

ini_set('memory_limit', Config::memoryLimit());
Expand All @@ -36,6 +43,7 @@ Logger::initialize($options['log']);

Logger::info('autoload file has been loaded', ['path' => $loadedFile ?? '']);
Logger::info('start analyzing', ['target' => $file]);
Logger::info('Xdebug is ' . (extension_loaded('xdebug') ? 'enabled.' : 'disabled.'));

try {
$dependencyVisualizer = DependencyVisualizer::create($file);
Expand Down Expand Up @@ -63,6 +71,7 @@ function exporterFactory($options): Exporter {

function parseArgs($args): array {
$options = [
'loadXdebug' => false,
'help' => false,
'log' => false,
'drawMethod' => false,
Expand All @@ -71,6 +80,9 @@ function parseArgs($args): array {
$file = '';
foreach ($args as $arg) {
switch ($arg) {
case '-d':
$options['loadXdebug'] = true;
break;
case '-h':
$options['help'] = true;
break;
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"require": {
"php": "^7.4|^8.0",
"nikic/php-parser": "^5.0",
"monolog/monolog": "^2.5"
"monolog/monolog": "^2.5",
"composer/xdebug-handler": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
Expand Down
139 changes: 138 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 553dc86

Please sign in to comment.