Changes

From SME Server
Jump to navigationJump to search
Line 196: Line 196:  
http://docs.komodoide.com/Manual/debugger#debugging-programs-komodo-ide-only_remote-debugging_debugger-proxy
 
http://docs.komodoide.com/Manual/debugger#debugging-programs-komodo-ide-only_remote-debugging_debugger-proxy
   −
===Editors and IDEs===
+
===PHP remote debugging===
 +
 
 +
You can debug on your local workstation but it is extremely useful to be able to debug direct on the server environment.
 +
You may have one PHP version installed on your desktop but be running a different one on the server, and you may have a different server setup.
 +
 
 +
First you need to install the xdebug packages eg:
 +
 
 +
yum install php74-php-pecl-xdebug
 +
yum install php80-php-pecl-xdebug
 +
 
 +
Next you need a small template fragment to enable remote debugging:
 +
 
 +
mkdir -p /etc/e-smith/templates-custom/etc/php.ini
 +
nano /etc/e-smith/templates-custom/etc/php.ini/90XdebugSettings
 +
 
 +
Add this:
 +
 
 +
[Debugger]
 +
; /etc/e-smith/templates-custom/etc/php.ini
 +
xdebug.remote_enable                  = true
 +
xdebug.remote_host                    = 127.0.0.1
 +
xdebug.remote_port                    = 9000
 +
xdebug.remote_handler                  = dbgp
 +
xdebug.remote_log                      = /var/log/xdebug.log
 +
xdebug.remote_mode                    = req
 +
xdebug.max_nesting_level              = 5000
 +
 
 +
Expand templates and restart services:
 +
 
 +
signal-event webapps-update
 +
 
 +
We should see Xdebug here
 +
 
 +
php74 -v
 +
PHP 7.4.28 (cli) (built: Feb 15 2022 13:23:10) ( NTS )
 +
Copyright (c) The PHP Group
 +
Zend Engine v3.4.0, Copyright (c) Zend Technologies
 +
    with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies
 +
    with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
 +
 
 +
====Komodo IDE====
 +
 
 +
We can obtain the debug proxy from the installation, and move it to the server and then execute from there:
 +
 
 +
python /root/dbgp/bin/pydbgpproxy -d 127.0.0.1:9000 -i 192.168.10.1:9003
 +
 
 +
Or alternatively grab the lastest xdebug client here:
 +
 
 +
mkdir /root/xdbg-proxy
 +
cd /root/xdbg-proxy
 +
curl https://xdebug.org/files/binaries/dbgpProxy -o dbgpProxy
 +
chmod 0700 dbgpProxy
 +
./dbgpProxy -s 127.0.0.1:9000 -i 192.168.10.1:9003
   −
Some Open Source Editors/IDEs
+
In Komodo Go to Preferences, Debugger, Connections
   −
These all allow remote debugging.
+
Komodo should listen on:
 +
System provide port
   −
Komodo-IDE https://www.activestate.com/products/komodo-ide
+
Check 'I am running a debugger proxy'
 +
Listener address: IP.of.your.server:9003
 +
Proxy key: individual key name for this desktop
   −
Komodo Debug tools: https://code.activestate.com/komodo/remotedebugging/
+
Save and check that it connected to the debugger.
   −
Eclipse https://www.eclipse.org/
+
Now to debug a file:
   −
Netbeans https://netbeans.org/
+
https://your.server.ip/index.php?XDEBUG_SESSION_START=mydesktopkey
   −
Codium https://itsfoss.com/vscodium/ << Opensource version may not have extensions
+
Or
    +
https://your.server.ip/index.php?somevalue=3&XDEBUG_SESSION_START=mydesktopkey
   −
PHP debugging:
+
====Visual Studio/VS Codium====
    
Sample launch.json
 
Sample launch.json
 +
 +
Note for newer versions of Xdebug the default port is now 9003
 +
Pay careful attention to the path mapping,. This has to be absolutely correct or it will not work.
    
  {
 
  {
Line 227: Line 286:  
             "type"        : "php",
 
             "type"        : "php",
 
             "request"    : "launch",
 
             "request"    : "launch",
            "port"        : 9001,
+
            "stopOnEntry" : false,
            "stopOnEntry" : false,
   
             "proxy": {
 
             "proxy": {
 
             "enable" : true,
 
             "enable" : true,
             "host" : "192.168.10.1",
+
             "host" : "my.server.ip",
             "key" : "myvsc",
+
             "key" : "mycodiumkey",
 +
            "port": 9003,
 
             "allowMultipleSessions" : true
 
             "allowMultipleSessions" : true
 
             },
 
             },
 
             "pathMappings": {
 
             "pathMappings": {
             "/home/e-smith/files/ibays/testbay/html/Opencart_Admin_Rest_Api": "${workspaceFolder}"
+
             "/home/e-smith/files/ibays/testbay/html/phptestcode": "${workspaceFolder}"
 
             },
 
             },
 
         },
 
         },
Line 242: Line 301:  
  }
 
  }
   −
We then need to run the debug proxy from Komodo
+
Now you can run start the PHP debugger in Codium so it connects the to the debug server, and then trigger it with a URL like this:
 +
 
 +
https://my.SME.Server/testbay/phptestcode/myTestPhpFile.php?XDEBUG_SESSION_START=mycodiumkey
 +
 
 +
 
 +
===Editors and IDEs===
 +
 
 +
Some Open Source Editors/IDEs
   −
python /root/dbgp/bin/pydbgpproxy -d 127.0.0.1:9000 -i 192.168.10.1:9001 -l DEBUG
+
These all allow remote debugging.
   −
Now you can run start the PHO debugger in Codium and then trigger it with a URL like this:
+
Komodo-IDE https://www.activestate.com/products/komodo-ide
   −
https://my.SME.Server/testbay/myTestPhpFile.php?XDEBUG_SESSION_START=myvsc
+
Komodo Debug tools: https://code.activestate.com/komodo/remotedebugging/
 +
 
 +
Eclipse https://www.eclipse.org/
 +
 
 +
Netbeans https://netbeans.org/
   −
I can't see a remote Perl debugger as yet.
+
Codium https://itsfoss.com/vscodium/ - Use PHP Debug - felixfbecker.php-debug
 +
<br>
 +
For Codium I can't see a remote Perl debugger as yet.
    
----
 
----

Navigation menu