-
-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathXDebugExtension.php
More file actions
84 lines (75 loc) · 3.04 KB
/
Copy pathXDebugExtension.php
File metadata and controls
84 lines (75 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/*
* This file is part of the PHPBench package
*
* (c) Daniel Leech <daniel@dantleech.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace PhpBench\Extensions\XDebug;
use PhpBench\Compat\SymfonyOptionsResolverCompat;
use PhpBench\Console\Command\Handler\RunnerHandler;
use PhpBench\DependencyInjection\Container;
use PhpBench\DependencyInjection\ExtensionInterface;
use PhpBench\Executor\Benchmark\RemoteExecutor;
use PhpBench\Executor\CompositeExecutor;
use PhpBench\Executor\Method\RemoteMethodExecutor;
use PhpBench\Extension\ConsoleExtension;
use PhpBench\Extension\CoreExtension;
use PhpBench\Extension\RunnerExtension;
use PhpBench\Extensions\XDebug\Command\Handler\OutputDirHandler;
use PhpBench\Extensions\XDebug\Command\ProfileCommand;
use PhpBench\Extensions\XDebug\Executor\ProfileExecutor;
use Symfony\Component\OptionsResolver\OptionsResolver;
class XDebugExtension implements ExtensionInterface
{
public const PARAM_OUTPUT_DIR = 'xdebug.command_handler_output_dir';
public function configure(OptionsResolver $resolver): void
{
$resolver->setDefaults([
self::PARAM_OUTPUT_DIR => '.phpbench/xdebug-profile',
]);
$resolver->setAllowedTypes(self::PARAM_OUTPUT_DIR, ['string']);
SymfonyOptionsResolverCompat::setInfos($resolver, [
self::PARAM_OUTPUT_DIR => 'Output directory for generated XDebug profiles',
]);
}
public function load(Container $container): void
{
$container->register(XDebugUtil::class, function (Container $container) {
return XDebugUtil::fromEnvironment();
});
$container->register(ProfileCommand::class, function (Container $container) {
return new ProfileCommand(
$container->get(RunnerHandler::class),
$container->get(self::PARAM_OUTPUT_DIR),
$container->get(XDebugUtil::class)
);
}, [
ConsoleExtension::TAG_CONSOLE_COMMAND => []
]);
$container->register(self::PARAM_OUTPUT_DIR, function (Container $container) {
return new OutputDirHandler(
$container->getParameter(self::PARAM_OUTPUT_DIR),
$container->getParameter(CoreExtension::PARAM_WORKING_DIR)
);
});
$container->register(ProfileExecutor::class, function (Container $container) {
return new CompositeExecutor(
new ProfileExecutor(
$container->get(RemoteExecutor::class),
$container->get(XDebugUtil::class),
$container->getParameter(CoreExtension::PARAM_WORKING_DIR)
),
$container->get(RemoteMethodExecutor::class)
);
}, [
RunnerExtension::TAG_EXECUTOR => [
'name' => 'xdebug_profile'
]
]);
$container->mergeParameter(RunnerExtension::PARAM_EXECUTORS, require(__DIR__ . '/config/executors.php'));
}
}