- lesson-001-hello-world: "hello world" example from Tutorialspoint
- lesson-002-post-request: handling of form registration using POST method, example from guru99.com
- lesson-003-mysql: test a connection to MySQL. Before that, I used the GUI of MySQL Workbench to create a new user and set Authentication Type: Standard
- lesson-004-swiftmailer: send email with SwiftMailer.
- lesson-005-sqlsrv: test a connection to SQL Server.
- Download from https://getcomposer.org/, install it and setup environment variable Path.
- How to initialize a composer.json: CMD to your repo/project root folder. Run command composer init, press Enter and follow instructions in the console after that. During this you will instruct the console what vendor, project name and which version (from Github) on which your project depends.
- After creating composer.json successfully. You can run command composer update. As the result, composer will create a vendor folder (same place as composer.json), then downloads necessary libraries described in the JSON and places them in it, then create a composer.lock file.
- You should add /vendor/ into .gitignore file, but composer.lock file shouldn't be ignored. Please Google to know why.
- PHP code that would use any of depended libraries, must have this code:
<?php require_once 'vendor/autoload.php'; ?>
- Add the directory that contains php.exe into Path environment parameter.
- Ctrl+R (Run) "CMD", and run this command: php your_file.php.
- Download XAMPP from this page. Install it.
- Copy your PHP files to htdocs folder in XAMPP installation folder.
- Open xampp-control.exe
- Start Apache server. If it failed in starting, please check current opening websites in IIS (Internet Information Services) and turn of the ones that use any of the ports used by Apache.
- Use web browser and access localhost/... ([...] is replaced by the directory to your PHP file.)
- Windows 10
- Visual Studio Code 1.41.1
- XAMPP v3.2.4
- Download Xdebug binary file from https://xdebug.org/download (choose a file that matches the PHP version used by XAMPP; make sure your computer has corresponding C++ installed)
- Place that binary in ...\xampp\php\ext (xampp is the folder where XAMPP is installed)
- Open xampp-control.exe, click Config button, select php.ini. Place settings below at the end of the file. You have to change some "dir" parameters value to match your environment. Please note that in this example, I have XAMPP installed in E:\php\xampp directory.
[XDebug]
;zend_extension points to the Xdebug binary file you downloaded.
zend_extension="E:\php\xampp\php\ext\php_xdebug-2.9.2-7.4-vc15-x86_64.dll"
xdebug.stopOnEntry = true
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = Off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="E:\php\xampp\tmp"
xdebug.show_local_vars=0
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log = "E:\php\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "E:\php\xampp\tmp"
xdebug.remote_cookie_expire_time = 36000
- On Visual Studio Code, open Extensions (Ctrl+Shift+X), and type "PHP Debug" to search for that extension and install it.
- In order to activate debugger, you have to use Visual Studio Code to open a folder, rather than a file. Please open the folder containing the file you want to debug, then open that file, and create debug breakpoint on it.
- Visual Studio Code needs a launch.json file locating in the opened folder before debugging. You can create one by using Debug and Run (Ctrl+Shift+D) in Visual Studio Code and following its instruction. In this case, just click on create a launch.json file option, then select the environment of "PHP Debug" extensions (which you named upon installing "PHP Debug"), which is "PHP" in my case.
- Click Debug -> Start Debugging menu.
- Start Apache web server with XAMPP controller.
- Use web browser and browse for http://localhost/dashboard/phpinfo.php to confirm your settings of Xdebug. Just Ctrl+F "Xdebug" appearing in the site.
- Browse the PHP where you place breakpoints. Check if the breakpoint is hit in Visual Studio Code.
The method is similar to the case of using XAMPP. You have to paste your files to ext folder of your installed PHP, instead of the ext folder at your XAMPP's place. The php.ini file used in this case, of course, belongs to your installed PHP, not XAMPP. Besides, please change some values in your configuration which would be pasted in php.ini so that it would make sense.