sqd / phpgists
Set of php functions and tools to help with CCN projects
1.0.0
2019-11-12 14:42 UTC
Requires (Dev)
- phpunit/phpunit: 8.3.*
This package is auto-updated.
Last update: 2024-09-18 21:30:19 UTC
README
This is a set of PHP functions and tools to help build my PHP projects.
run a phpunit test
You can install phpunit globally with composer global require phpunit
.
Once it's installed, run something like : phpunit .\tests\ArrayTest.php
to run the ArrayTest tests for example.
Configure debugging with vscode and xdebug
On Windows
- download xdebug and place in your php ext directory (where there are a lot of php_xxx.dll files)
- in your php.ini add the following lines (you can change the port if you want)
zend_extension=[absolute path to your php_xdebug.dll]
xdebug.remote_enable=1
xdebug.remote_autostart = 1
xdebug.remote_port=9900
xdebug.remote_log=[choose an absolute path to xdebug.log]
To debug a script, no need to use xdebug, just use the default vscode script config
On Linux
sudo apt-get install php-xdebug
- add the following lines in /etc/php/7.x/mods-available/xdebug.ini
xdebug.show_error_trace = 1
xdebug.remote_enable=1
xdebug.remote_autostart = 1
sudo service apache2 restart
How to use XDebug
- check that xdebug is ok by running
php -i | grep xdebug
- in vscode configure xdebug on port 9900 (the one you put in php.ini)
To debug something with xdebug (typically a phpunit test):
- place a breakpoint somewhere
- run the xdebug listener in vscode
- run the command you want like
phpunit ./tests/ArrayTest.php
- if you want to run only some functions, in the test file, add a
--filter pattern
argument in the phpunit command line
Documentation
Install phpDocumentor on Windows
- download the phpdoc.phar from the phpDocumentor website and add it to your PATH
- create in the same folder as phpdoc.phar, a phpdoc.cmd with this line :
@php "%~dp0phpdoc.phar" %*
)
Generate the HTML doc
- cd in the project and run
phpdoc.cmd -d ./src -t ./docs
Tools
There are some useful tools to help developping this module for example :
php ./tools/main.php create_test Array
to create a new test file to test the functions in file 'Array.php'