· Travis Rodgers · Programming  · 3 min read

Setting VS Code to PHP 7 – Executable Not Found

After attempting to try out the new null coalescing operator in PHP 7, I realized that my Macbook Pro was still on 5.6. In this post I want to share with you not only how to upgrade your Mac to PHP 7, but how to adjust your PATH to recognize it, and update VS Code to PHP7. 

Setting VS Code to PHP 7

1. Upgrade PHP on your Mac

According to the PHP downloads page, the current stable version at the time of this post is 7.2. If your Mac has on OS of 10.10 or greater, go for it. 

Open up your Terminal and type in

curl -s https://php-osx.liip.ch/install.sh | bash -s 7.2

If you prefer an earlier PHP have an OS version before 10.10 then reference this page.

This will install the new version of PHP on your computer. 

2. Adjust your PATH

After you install the new version of PHP, verify the version by typing in the Terminal:

php -v

Uh, oh. You're probably still showing the old version.

Here's the deal:

php-osx doesn't overwrite the php binaries installed by Apple, but installs everything in /usr/local/php5. The new php binary is therefore in /usr/local/php5/bin/php (source)

So the PHP binaries installed by Apple are left right where they are, and the new PHP version is installed in a new folder. You need to adjust your PATH to that new location. 

You can do so by typing in the Terminal:

export PATH=/usr/local/php5/bin:$PATH

Now check your version again with php -v and you should see the new version. 

3. Update your new location in VS Code

Now you need to tell Visual Studio Code where your PHP executable is. 

On the Mac, "right-click" on Finder and choose "Go To Folder" and enter 

/usr/local/

In the local folder you will see the old PHP5 folder as well as the new PHP5 folder which will be something like php5-7.2.2-20180109-122639

If you look in that folder, and then into the bin folder, you will see your new php executable.

This is where we need to point VS code, and we do this in VS Code's settings, using "php.executablePath."

So open up your VS Code settings (command + comma) and enter the path to your new executable. So in my example I would put this in my settings.json:

```json "php.executablePath": "/usr/local/php5-7.2.2-20180109-122639/bin/php"```

And there you go, setting VS Code to PHP 7!

    Share:

    Related Posts

    View All Posts »
    5 Steps to Learn React in 2025

    5 Steps to Learn React in 2025

    React is one of the most popular front-end JavaScript libraries. Let's break down the essential steps to learn React in 2025.

    5 Reasons Laravel is Trending in 2024

    5 Reasons Laravel is Trending in 2024

    In this article, I want to give 5 reasons why I think many more people are finding a newfound enjoyment or a re-found enjoyment in the Laravel ecosystem.