File tree Expand file tree Collapse file tree 13 files changed +92
-17
lines changed
Unit/Extension/Core/Application Expand file tree Collapse file tree 13 files changed +92
-17
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ Changelog
33
44## Unreleased
55
6+ Features:
7+
8+ - [Application] Disable XDebug by default, very much improve performance.
9+ Fixes #317
10+
611Improvements:
712
813 - [Completion] Do not evaluate left operand when completing expression,
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use Symfony\Component\Debug\Debug;
55use Symfony \Component \Console \Input \ArgvInput ;
66use Symfony \Component \Console \Output \ConsoleOutput ;
77use Phpactor \Application ;
8+ use Composer \XdebugHandler \XdebugHandler ;
89
910foreach ([
1011 __DIR__ . '/../../../autoload.php ' ,
Original file line number Diff line number Diff line change 1717 "symfony/yaml" : " ^3.3" ,
1818 "microsoft/tolerant-php-parser" : " dev-master" ,
1919 "monolog/monolog" : " ^2.0@dev" ,
20- "phpactor/completion" : " ^1.0@dev"
20+ "phpactor/completion" : " ^1.0@dev" ,
21+ "composer/xdebug-handler" : " ^1.1"
2122 },
2223 "config" : {
2324 "platform" : {
Original file line number Diff line number Diff line change @@ -51,8 +51,8 @@ path. The autoloader helps Phpactor locate classes.
5151
5252* Default* : ` true `
5353
54- By default Phpactor will deregister the included autoloader to prevent
5554any potential conflicts. However, some autoloaders may add global dependencies
55+ By default Phpactor will deregister the included autoloader to prevent
5656on the code available through that autoloader (e.g. Drupal). In such cases
5757set this to ` false ` and hope that everything is * fine* .
5858
@@ -86,6 +86,13 @@ The default logging level.
8686
8787Where the log file is
8888
89+ #### xdebug_disable
90+
91+ * Default* : ` true `
92+
93+ Disable XDebug if it's enabled. This can (likely will) have a very positive
94+ effect on performance.
95+
8996### Code Transform Extension
9097
9198#### code_transform.class_new.variants
Original file line number Diff line number Diff line change @@ -39,6 +39,12 @@ public function check(): array
3939 $ diagnostics ['bad ' ][] = 'Git not detected. Some operations which would have been better scoped to your project repository will now include vendor paths. ' ;
4040 }
4141
42+ if (extension_loaded ('xdebug ' )) {
43+ $ diagnostics ['bad ' ][] = 'XDebug is enabled. XDebug has a negative effect on performance. ' ;
44+ } else {
45+ $ diagnostics ['good ' ][] = 'XDebug is disabled. XDebug has a negative effect on performance. ' ;
46+ }
47+
4248 return $ diagnostics ;
4349 }
4450}
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ class CoreExtension implements Extension
3939 const LOGGING_ENABLED = 'logging.enabled ' ;
4040 const LOGGING_FINGERS_CROSSED = 'logging.fingers_crossed ' ;
4141 const AUTOLOAD_DEREGISTER = 'autoload.deregister ' ;
42+ const XDEBUG_DISABLE = 'xdebug_disable ' ;
4243
4344 public static $ autoloader ;
4445
@@ -54,6 +55,7 @@ public function configure(Schema $schema)
5455 self ::LOGGING_FINGERS_CROSSED => true ,
5556 self ::LOGGING_PATH => 'phpactor.log ' ,
5657 self ::LOGGING_LEVEL => LogLevel::WARNING ,
58+ self ::XDEBUG_DISABLE => true ,
5759 ]);
5860 }
5961
Original file line number Diff line number Diff line change 1818use Symfony \Component \Console \Input \InputInterface ;
1919use Phpactor \Config \Paths ;
2020use Phpactor \Extension \ClassToFile \ClassToFileExtension ;
21+ use Composer \XdebugHandler \XdebugHandler ;
2122
2223class Phpactor
2324{
2425 public static function boot (InputInterface $ input ): PhpactorContainer
2526 {
27+
2628 $ config = [];
2729
2830 $ configLoader = new ConfigLoader ();
@@ -32,6 +34,12 @@ public static function boot(InputInterface $input): PhpactorContainer
3234 $ config ['cwd ' ] = $ input ->getParameterOption ([ '--working-dir ' , '-d ' ]);
3335 }
3436
37+ if (!isset ($ config [CoreExtension::XDEBUG_DISABLE ]) || $ config [CoreExtension::XDEBUG_DISABLE ]) {
38+ $ xdebug = new XdebugHandler ('PHPACTOR ' , '--ansi ' );
39+ $ xdebug ->check ();
40+ unset($ xdebug );
41+ }
42+
3543 $ extensionNames = [
3644 CoreExtension::class,
3745 ClassToFileExtension::class,
Original file line number Diff line number Diff line change 2222 </whitelist >
2323 </filter >
2424
25+ <php >
26+ <env name =" PHPACTOR_ALLOW_XDEBUG" value =" 1" />
27+ </php >
28+
2529</phpunit >
Original file line number Diff line number Diff line change 66use Phpactor \Application ;
77use Symfony \Component \Console \Output \BufferedOutput ;
88use Symfony \Component \Console \Input \ArrayInput ;
9+ use Symfony \Component \Process \Process ;
910
1011class BaseBenchCase extends IntegrationTestCase
1112{
12- protected function runCommand (array $ input ): BufferedOutput
13+ protected function runCommand (string $ command ): string
1314 {
1415 chdir ($ this ->workspaceDir ());
15- $ application = new Application ();
16- $ output = new BufferedOutput ( );
17- $ application -> setAutoExit ( false );
18- $ application ->run (new ArrayInput ( $ input ), $ output );
19- return $ output ;
16+
17+ $ process = new Process ( __DIR__ . ' /../../bin/phpactor ' . $ command );
18+ $ process -> setWorkingDirectory ( $ this -> workspaceDir () );
19+ $ process ->run ();
20+ return $ process -> getOutput () ;
2021 }
2122}
You can’t perform that action at this time.
0 commit comments