<?php
// php code here
?>
<?php
ini_set('display_startup_errors', '1');
ini_set('display_errors', '1');
error_reporting(E_ALL);
ini_set('log_errors', '1');
ini_set('error_log', 'php_errors.log');
in php.ini file:
error_reporting = E_ALL
display_errors = On
display_startup_errors = On
log_errors = On
; If you set the error_log directive to a relative path, it is a path relative
; to the document root rather than php's containing folder.
error_log = php_errors.log
Steps:
-
Aquire xdebug.so file: We can install it using package manager. Ex:
sudo pacman -S xdebug
this will create .so file mostly in following location:/usr/lib/php/modules/xdebug.so
. If you failed in above step, then please follow wizard and complete this step. -
configuring php ini file: Get the location of the ini file using
php --ini
, in my case its/etc/php/php.ini
. Somewhere I read that its better to have separate ini file for xdebug, so create/etc/php/conf.d/99-xdebug.ini
usingtouch /etc/php/conf.d/99-xdebug.ini
. And add the following content in 99-xdebug.ini file:
zend_extension=xdebug
xdebug.mode=debug
xdebug.start_with_request = yes
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.log=/tmp/xdebug.log ; optional, to see WTF is happening
Verify that the newly created ini file is being loaded by reading output of php --ini
command.
- Configuring VSCode:
At the root of the project, create
.vscode/launch.json
file, and add following content:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/absolute/path/to/the/codeigniter-project": "${workspaceFolder}"
}
}
]
}
Note that inside pathMappings you need to update the key to absolute path to you code ignite app (root of the project).
- Final Step
- Start the vs code debuger (
Listen for Xdebug
) - Open terminal at the root of the project and start serving the app:
./spark serve --port 8000
- Put some breakpoints in source code in vscode
- Load the application in browser
http://localhost:8000
and navigate to the pages related code where you put breakpoints. - Congratulations you hit the breakpoint. Thank me now :)
link: https://github.com/wilmoore/php-version/wiki/Exploring-PHP
which php
which php-fpm
which pear
which pecl
which phar
which php-cgi
which php-config
which phpize
man php
man php-fpm
man php-config
man phpize
curl
intl
mysqli
pdo_mysql
zip
max_execution_time = 3600
memory_limit = 1024M
post_max_size = 512M
upload_max_filesize = 10M
-
as which user php-fpm service runs?
-
in ubuntu
- php-fpm location:
/etc/php/8.1/fpm
- php.ini location:
/etc/php/8.1/fpm/php.ini
- starting php-fpm service:
service php8.1-fpm start
- php-fpm location: