VS Code Up & Running with PHP Interpreter

in #wordpress7 years ago

I'm setting up a WordPress site for a local organization. WordPress is completely new to me, so one of my first tasks was to get a basic development environment working. While poking around all the php files, my code editor of choice, VS Code, nagged me with the error "Cannot validate since no PHP executable is set. Use the setting 'php.validate.executablePath' to configure the PHP executable."

My goal is always to keep my local machine clean with minimal installations. For the last year, most of my projects only required Node, VS Code, and a browser. WordPress requires that I get knee deep into php and MySQL. The most common approaches to WordPress development environments seem to include installing a WAMP, LAMP, or XAMP solution that bundles together all the key pieces of a Content Management System (CMS): database, web server (Apache), PHP interpreters, and the phpMyAdmin tool.

I just didn't want to install all that and burden my future self with the task of keeping the environment versions in sync with my various projects. So I turned to Docker. That's been a journey, as well, since I'm just as new to Docker as I am to WordPress. I'll save my Docker configuration for another post. For now, though, the key piece is that Docker didn't plug in the gap that VS Code was looking for.

Resolving the VS Code error required only a few simple steps (for my Windows 10 machine):

  1. Go to http://windows.php.net/download/
  2. Download the latest version of PHP for Windows, x64 Non Thread Safe (x86 if you're using a 32-bit machine)
  3. Unzip the the contents into a local folder (I created "C:\Program Files\php")
  4. In VS Code, go to File> Preferences > Settings. This will open the settings.json file. Add
    "php.validate.executablePath": "<<Enter the php.exe path>>"
    My Case: "php.validate.executablePath": "C:/Program Files/php/php.exe"

Note: When copying/pasting file paths from Windows File Explorer, the path will have backslashes. This won't work in JSON since the backslashes are interpreted as escape characters. You'll need to change them to forward slashes.

Now back to taking one more step down the WP path...

Sort:  

Followed. I'll be watching this post series closely. I do everything in Wordpress the hard way but need to move to a better build solution soon. Thanks for posting this. Cheers, @rebele93

I'm just finished my first full day doing WP development with Docker without an issue. If I can get through tomorrow without an issue, I'll start drafting the Docker post. It's really cool, I can even store the database in my local folder and migrate it to the production environment when I'm ready.

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 64349.20
ETH 2673.53
USDT 1.00
SBD 2.83