cakephp3 debugging tool

Asked 2 years ago, Updated 2 years ago, 46 views

Please let me know if there are any debug tools recommended for cakephp3 such as visual studio.
For example, you might want to set a breakpoint and briefly look at the contents of the variables stored at that time (on the JavaScript and php sides).
I'm using Atom, but can I use such a function?
We are currently checking the output of php to debug.log and JavaScript to console.log.

php cakephp

2022-09-30 16:28

1 Answers

Since CakePHP is PHP, Xdebug is available.

Major editors such as Atom, VSCode and PhpStorm support Xdebug.

Properly configured, the web server communicates to the development machine, allowing you to perform typical breakpoint steps, continue, view and tamper with variables.

Note that certain versions of CakePHP 3.4.x may not debug successfully for projects that frequently issue requests to servers, such as Ajax.

Build a Virtual Machine Environment
For example, CentOS LAMP built with a bridge connection on VirtualBox

Configure the xdebug extension and corresponding php.ini for the virtual machine
Example: php7.0, via remi

$yum-y install --enablerepo=remi-php70php-developphp-pecl-xdebug

Example: If you are referring to the php.d folder, you can write it directly in php.ini

$sudovi/etc/php.d/15-xdebug.ini
 [xdebug]
xdebug.default_enable=1
xdebug.idekey="vscode"
xdebug.remote_enable=1
xdebug.remote_port = 9000
xdebug.remote_autostart=1
xdebug.remote_host=<Development Machine (Host Machine) IP>

Apache Restart

$sudo systemctl restart httpd.service

Set the editor side properly and start debugging the editor (waiting for xdebug communication)

Example: Visual Studio code

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port"—9000,
            "serverSourceRoot": "/var/www/html/<AppRoot>",
            "localSourceRoot": "${workspaceRoot}"
        }
    ]
}


2022-09-30 16:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.