PHP
Last updated
Was this helpful?
Last updated
Was this helpful?
→
Download the version that you want from the . You may consider reading a little about thread safe (for Apache) and not thread safe versions (for IIS, nginx or command line).
On Windows, you'll download a zip file, you just have to extract it somewhere (more in a program folder). You can add the direetory in the environment PATH but it's not mandatory. For example, you can add the following line in a command window:
Once you're clear on your PHP installation setup, you should be able to get something like this:
By default, there is no php.ini
file in the installation folder, you can copy the development one to create your own file.
Create a bat file, for example start-php-fcgi.bat:
Once it is installed, you should be able to get the following:
You can install packages system or project wide. Here are some tools that are good to have system wide:
Composer configuration file is called composer.json
.
XDebug is required to debug your code in your IDE (Eclipse PDT, VS Code, etc.).
Copy the file in the ext directory of your PHP installation directory.
Edit your php.ini
file to add the following lines to activate the debugging (if you don't know which php.ini file you're using make a phpinfo() file)
You just have to set php.validate.executablePath
in your user settings in VS Code if it's not in the PATH (which could be a good practice if several PHP versions must be present on the machine).
phpcs is a good tool to validate the code that is written.
You can also change the behaviour directly in the file.
For example, custom_ruleset.xml file content:
You can configure it in VS Code or from the command line:
Add in your php.ini
file:
From your project directory:
Install locally: composer require phpunit/phpunit --dev
Check the tool is running file: php vendor/phpunit/phpunit/phpunit --version
(or php vendor/bin/phpunit
on a non-Windows environment)
Edit composer.json
file and execute composer install
to regenerate autoload file
Create phpunit.xml.dist
file:
Launch the tests: php vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist --log-junit junit.xml
You can also use Symfony PHPUnit bridge: composer install symfony/phpunit-bridge --dev
(and create a bin/console and update your gitignore)
is the dependency (package) manager for PHP.
Go on and select the version related to your PHP one, for example php_xdebug-2.6.0-7.2-vc15-nts-x86_64.dll
.
Visual Studio Code is an indredible tool provided by Microsoft. You can review for more information.
If you want to see a preview or get up to speed quickly, you can watch .
It can be easily configured, see the .
You can define your own ruleset, see .
There is a PHP extension and a PHP library to access MongoDB, see .
(Windows) Download the zip file for the good version from and copy the dll inside the zip file to your extension folder.
Reference: .
Reference: .
: A simple PHP Dependency Injection Container
is a testing framework for PHP. It is open source: . It is available on .
Read
With coverage (): php vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist --coverage-html .build/coverage-report --coverage-clover .build/coverage.xml
Integration in SonarCloud:
We can also use phpdbg (that is now shipped with PHP): phpdbg -qrr vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist
(comparison with xdebug here: )
For Mocks :