Install Php Enviroment on Windows 10
Post Date : 2022-08-06T09:47:49+07:00
Modified Date : 2022-08-06T09:47:49+07:00
Category: php-tutorial
Tags:
Todo
- Install XAMPP
- Add custom configuration for vhost
- Create PHP Path Variable
- Install XDebug
- Debug with PHPStorm
1. Install XAMPP
2. Add custom configuration for vhost
C:\xampp\apache\conf\httpd.conf
Add this line at the end
Include “C:/custom_virtual_host.conf”
Add your first virtual host
<Directory "C:/www">
AllowOverride All
Options None
Require all granted
</Directory>
# Default
<VirtualHost *:80>
DocumentRoot "C:/www/localhost"
ServerName localhost
LogLevel warn
ErrorLog "C:/www/localhost_error.log"
CustomLog "C:/www/localhost_access.log" combined
</VirtualHost>
Create new file C:/www/localhost/index.php
phpinfo();
Restart XAMPP and open your localhost
3. Create PHP Path Variable

Edit Path

Add Path

Open your terminal
php -i
4. Install XDebug
Install PHP Xdebug
Follow the instruction from xdebug
4.1. Installation
PHP 7.x
Download php_xdebug-3.0.4-7.4-vc15-x86_64.dll
Move the downloaded file to C:\xampp\php\ext
Edit C:\xampp\php\php.ini and add the line
zend_extension = C:\xampp\php\ext\php_xdebug-3.0.4-7.4-vc15-x86_64.dll
Restart the webserver
PHP 8.x
Download php_xdebug-3.0.4-8.0-vs16-x86_64.dll
Rename **php_xdebug.dll**
Move the downloaded file to C:\xampp\php\ext
Update C:\xampp\php\php.ini to have the line:
zend_extension = xdebug
Restart the Apache Webserver
4.2. Debug
https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug
Your php.ini
; XDebug
zend_extension = xdebug
xdebug.mode = debug
xdebug.start_with_request = yes
5. Debug with PHPStorm
Add CLI Intepreter
Settings => Search “PHP”
Select your PHP version

Create your server setting
Settings => Search “server” Select PHP > Servers > Add Insert

Add your Debug Configuration
Run -> Edit Configuration
Add New -> PHP Web Page
Select your server and set the default open URL

Let’s debug
Presse Shift + F9 or Debug Icon to start. Your URL may look like this
http://phonebook.phpguru.local/?XDEBUG_SESSION_START=13163
Then make sure you clicked on “Start Listening Debug PHP Connection” next to the debug icon

You can start adding your debug breakpoint, and it will look like this

Some shorcuts:
- Shift + F9 : start debug
- Shift + F8 : toggle debug breakdown
- F8 : step over
Enjoy!!!