Install PHP engine to run your code.
Install Composer to manage your dependency.
Note: If Composer command can not be recognized after installation, please move and rename composer.phar to folder /usr/local/bin/ with the following command:
$ mv composer.phar /usr/local/bin/composer
Check the detail at Answer on StackOverflow.
Install xDebug which is an extension for PHP to assist with debugging and development, we will config this with PHP Debug later.
Now we need an IDE to write the code. There are many options, this tutorial will use Visual Studio Code.
For this tutorial, use all default install options.
Finally, install the extensions of PHP Server and PHP Debug for Visual Code,
- Go to Visual Code extension manager (left side, bottom icon)
- Type
PHPand select/installPHP Debug&PHP Serverplugin.
- PHP Server extension can help host/serve current workspace (or subfolder) with PHP easily.
If you have mulitple PHP versions installed, you can specify the location of your PHP executable by override the phpserver.phpPath in Visual Code User Settings. If empty, the extension will use the PHP executable which appears in the $PATH environment variable
- PHP Debug extension is a debug adapter between Visual Code and XDebug.
PHP Debug extension requires to configure with XDebug to make it work, please check the details at PHP Debug extension or a good blog post about configuration, and here is the brief steps:
- install PHP & xDebug as shown above.
- update your php.ini file with the following settings, make sure that zend_extension points to the correct location.
[xdebug]
zend_extension="<<path/to/xdebug>>"
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
Next: Authentication
