back to all posts

PHP Development Quickstart

by jonathan barrios / September 20th, 2019

Is PHP dead?

No. PHP is NOT dead and in fact, it's actually worth learning.

Data Shows


πŸ‘‡ PHP cannot die if 79% of the web is still using it

βœ… According to W3Techs’ data, PHP is used by 78.9% of all websites with a known server-side programming language. That translates to 8 out of every 10 websites on the Internet.

Survey Says


βœ… Stack Overflow’s 2019 Developer Survey shows us that VS Code is, by far, the most popular code editor in 2019.

stack overflow 2019 survey

PHP ❀️ VS Code

In this short tutorial, we'll set-up a PHP development environment using VS Code, a few extensions, and XAMPP. Visual Studio Code extensions are available within your development environment, which is truly amazing. Let's do this! πŸ”₯πŸ”₯πŸ”₯

First, download and install Visual Studio Code from code.visualstudio.com. Let's review the user interface, Iin the top-left we have the main navigation icons which are, from top to bottom:

  • Explorer ⇧ ⌘ E or Shift + Command + E
  • Search ⇧ ⌘ F or Shift + Command + F
  • Source Control βŒƒ ⇧ G or Control + Shift + G
  • Debug ⇧ ⌘ D or Shift + Command + D
  • Extensions ⇧ ⌘ X or Shift + Command + X

If you're on Windows, hover your mouse over each icon to display the shortcut.


Top Three Themes

First, I recommend installing a theme from the extensions tab. To install extensions, navigate to the Extensions tab(⇧ ⌘ X) and type the name of the theme in the search bar, select it then install it. These are my top three themes, so try them all:

  • VS Code Icons Theme by VS Code Icons Team
  • Night Owl by Sara Drasner @sarah_edo
  • Cobalt2 by Wes Bos @wesbos

To activate a theme:

  • access the command palette(⇧ ⌘ P)
  • type the name of the theme
  • Select the theme to activate

Extensions

Next, we have a choice of IntelliSense extensions:


I use PHP Intelephense but both extensions are great abd more or less offer similar workflow actions so either will work. I recommend researching more on your own and choosing according to your preference.

If you want to get into debugging PHP, I recommend PHP Debug by Felix Becker with the help of Jose Soto's article titled Debugging: Configure VS Code + XDebug + PHPUnit on tighten.co.


Install and Run XAMPP

Next, download and install XAMPP, which is available on Windows, Linux and Mac OS X. Once you open the XAMPP application, click start. Next, head over to the Services tab to check and start Apache and MySQL. Next, head over to the Network tab and enable port 80 and 443. Finally, open a browser and enter localhost:8080 which will reroute you to localhost:8080/dashboard automatically, which is the intended behavior.

Finally, head over to the Volumes tab and click on the mount button. Once mounted, open the volume and open the htdocs folder. In this folder, create a new working directory such as php-dev or a naming convention that suits your preference.


Open Folder in VS Code

Now we can get started by opening your newly created php-dev folder in Visual Studio Code.

Next, create an index.php file in the newly created directory and add the following code:


<?php
  echo "FTW";

Save your document and open a browser using this address: localhost:8080/php-dev and you should see FTW in the browser indicating that we are victorious! FTW is For The Win BTW. πŸ¦„


Treehouse Techdegree

If you're interested in learning more about web development, check out Treehouse's PHP TechDegree.


I hope you enjoyed PHP Development Quickstart, Follow me on Twitter @_jonathan_codes and if you want to learn more about PHP, check out Treehouse's PHP TechDegree.

back to all posts