VSCode with felixfbecker PHP Debugger

Costas

Administrator
Staff member
1-
PHP:
<?php

phphinfo();

2-
CTRL+A > CTRL+C then CTRL+V to
https://xdebug.org/wizard

3-
will tell you which DLL you need

4-
download it, place under php\ext

5-
open the php.ini, add these lines at the end

zend_extension= c:\xampp\php\ext\php_xdebug-3.1.2-8.1-vs16-x86_64.dll (replace with what you download)
xdebug.mode = debug
xdebug.start_with_request = yes

6-
restart the server

7-
at VSCodum install felixfbecker.php-debug


8-
the htdocs must have the '.vscode\launch.json'. To create one, once you are in the VSCode with the felixfbecker.php-debug installed
press CTRL+SHIFT+D
there is a text saying 'create a launch.json file' click it! (otherwise if exists click the wheel, to edit it)
now the '.vscode\launch.json' created.


place a breakpoint > Run > Debug

--

alternative - http://www.nusphere.com/products/phped.htm

otherwise go for 550mb application Jetbrains.PhpStorm using a chrome addon. 🤣
 

Costas

Administrator
Staff member
xdebug profiler GUIs

KCacheGrind (2013) - http://kcachegrind.sourceforge.net/html/Home.html

QCacheGrind (KCacheGrind) Windows build (2013) - https://sourceforge.net/projects/qcachegrindwin/

WinCacheGrind (2015) - https://github.com/ceefour/wincachegrind
https://www.sitepoint.com/php-frontend-for-xdebug-profiling/

webgrind (2021) - https://github.com/jokkedk/webgrind
PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms.
For quick'n'dirty optimizations it does the job. Here's a screenshot showing the output from



Documentation Ā» Profiling - Xdebug - https://xdebug.org/docs/profiler



only for linux
https://github.com/NoiseByNorthwest/php-spx
https://github.com/sj-i/php-profiler
(facebook) xhprof - http://pecl.php.net/package/xhprof
even providing windows DLL, mentioning that is not working.​

after a test found only xdebug profiler can work on Windows, the setup as :
1-download xdebug for your php version
2-copy to ext dir, update the php.ini as :
zend_extension="c:\xampp\php8\extensions\php_xdebug-{your_xdeubg_filename}.dll"
xdebug.output_dir = "c:\xampp\tmp"
xdebug.use_compression = false
xdebug.profiler_output_name = callgrind.out.%u
xdebug.mode=profile
3-anytime you would like to profile, add as $_GET, XDEBUG_TRIGGER or XDEBUG_PROFILE (ex. http://localhost/?XDEBUG_TRIGGER)
a file will be exported to c:\xampp\tmp
analyze the file with WinCacheGrind or QCacheGrind (KCacheGrind for linux)

xdebug profiler doc

or similar JetBrains phpstorm - xdebug howto


ref
https://stackoverflow.com/questions/21133/simplest-way-to-profile-a-php-script
 

Costas

Administrator
Staff member
Nginx and PHP Setup on Windows
https://gist.github.com/odan/b5f7de8dfbdbf76bef089776c868fea1

XDebug Setup for PHP 8
https://odan.github.io/2020/12/03/xampp-xdebug-setup-php8.html

--mirror for both

tested&working with the following pack :
Code:
http://nginx.org/download/nginx-1.26.2.zip
https://windows.php.net/downloads/releases/php-8.4.3-Win32-vs17-x64.zip
https://xdebug.org/files/php_xdebug-3.4.1-8.4-ts-vs17-x86_64.dll  (for different php version use - https://xdebug.org/wizard)
profiler & script or web debug
https://download-cdn.jetbrains.com/webide/PhpStorm-2024.3.1.1.exe



'C:\Windows\SYSTEM32\VCRUNTIME140.dll' 14.xx is not compatible with this PHP build linked with 14.yy

download the Latest Microsoft Visual C++ Redistributable x64
 

Costas

Administrator
Staff member
Working with COM Interop in PHP

JavaScript:
1) the .net dll must be
* COM visible (aka 'Register for COM interop')
* signed
* the same architecture as the server php distro (otherwise will throw 'Class not registered')

2) at php.ini enable the extension (distributed by default)
extension=com_dotnet

3) on server register the .net dll by executing
//when the dll architecture (by step 1) is x64
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe testPRJ.dll /codebase
//this will create : HKEY_CLASSES_ROOT\CLSID\{8b6b5508-431a-4fe8-9628-2a250116d7a5}\InprocServer32

4) when there is in csharp :
namespace testPRJ
{
    //[ComVisible(true)]
    //[Guid("8b6b5508-431a-4fe8-9628-2a250116d7a5 <-- YOUR-NEW-GUID-HERE")]    (https://www.guidgenerator.com/)
    [ClassInterface(ClassInterfaceType.AutoDual)]
    public class class1
    {
        public string SayHiMyName(string name)
        { return "Hi " + name; }

5) by php we call it as
$x = new COM('testPRJ.class1');
$res = $x->SayHiMyName('pipiscrew');
var_dump($res);

tested&working with php-8.4.3-Win32-vs17-x64



references :
https://www.php.net/manual/en/ref.com.php
https://docs.aspose.com/pdf/net/php-via-com-interop/
 
Top