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 will 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. Next, let's review the user interface. In 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 are 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:

  • PHP IntelliSense by Felix Becker
  • PHP Intelephense by Ben Mewburn

I use PHP Intelephense but both extensions are more or less solving similar workflow actions so either will work. I recommend researching more and choosing according to your use case.

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 and check Apache and MySQL. 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/dahboard automatically, which is the intended behavior.

Next, 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 case.


Open Folder in VS Code

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

To get started, create an index.php file in this 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 one of the Treehouse Memberships or Techdegrees for free with a 7-day trial:

That's it for this short tutorial, thanks for reading and happy coding! πŸ™Œ

Follow me on Twitter @_jonathan_codes

back to all posts