Debian Codegraph @

codelitephp/resources/TestXDebugSettings.php

raw symbols SCIP
1 <?php
2
3 class TestXDebugSettings {
4 public $_ideKey;
5 public $_zendDebuggerLoaded;
6 public $_xdebugLoaded;
7 public $_remoteConnectBack;
8 public $_remoteEnable;
9 public $_remoteHost;
10 public $_remotePort;
11
12 public function __construct(){
13 $this->_zendDebuggerLoaded = "0";
14 $this->_xdebugLoaded = "0";
15 $this->_ideKey = "";
16 $this->_remoteConnectBack = "0";
17 $this->_remoteEnable = "0";
18 $this->_remoteHost = "";
19 $this->_remotePort = "0";
20 }
21
22 /**
23 * @brief a helper method for reading directive using ini_get
24 * If the directive could not be found, return $defaultValue
25 * @param string $directive
26 * @param string $defaultValue
27 * @return mixed
28 */
29 private function readIni($directive, $defaultValue){
30 $val = get_cfg_var($directive);
31 if($val === false){
32 return $defaultValue;
33 }
34 return (string)$val;
35 }
36
37 /**
38 * @brief test XDebug INI settings
39 */
40 private function TestDirectives(){
41 $this->_remoteConnectBack = $this->readIni("xdebug.remote_connect_back", "0");
42 $this->_ideKey = $this->readIni("xdebug.ide_key", "");
43 $this->_remoteEnable = $this->readIni("xdebug.remote_enable", "0");
44 $this->_remoteHost = $this->readIni("xdebug.remote_host", "");
45 $this->_remotePort = $this->readIni("xdebug.remote_port", "");
46 }
47
48 /**
49 * @brief ensure that Zend Debugger is not loaded
50 */
51 private function TestZendDebuggerLoaded(){
52 $loadedModules = get_loaded_extensions(true);
53
54 foreach($loadedModules as $module){
55 if(strtolower($module)== "zend debugger"){
56 $this->_zendDebuggerLoaded = "1";
57 return;
58 }
59 }
60 }
61
62 /**
63 * @brief ensure that xdebug is loaded into PHP
64 */
65 private function TestXDebugLoaded(){
66 $loadedModules = get_loaded_extensions(true);
67
68 foreach($loadedModules as $module){
69 if(strtolower($module)== "xdebug"){
70 $this->_xdebugLoaded = "1";
71 return;
72 }
73 }
74 }
75
76 /**
77 * @brief run a small test to test the PHP settings to help the user
78 * ensures that everything is setup properly for debugging with XDebug
79 */
80 public function Test(){
81 // XDebug can not co-exist with Zend Debugger
82 $this->TestZendDebuggerLoaded();
83 // Ensure that XDebug is loaded
84 $this->TestXDebugLoaded();
85 // Test xdebug directives
86 $this->TestDirectives();
87 // Print the result as JSON output
88 echo json_encode($this);
89 }
90 }
91 $tester = new TestXDebugSettings();
92 $tester->Test();