The easiest way to play with PHP 8.2!

December 3, 2022 by Jeff3 minutes

PHP 8.2 logo

Perhaps you’d just like to play with some of the new features or see how well an existing project runs. Either way, it would be great if you could get a PHP 8.2 environment up and running with a minimum of hassle. IndigoStack is a fantastic way to do exactly that!

What’s IndigoStack?

👉 In case you’re new to IndigoStack, it’s a Mac app which allows you to create a reliable local development stack quickly and easily, by building stacks from a range of services including Nginx, Apache, MySQL, Redis… and a whole range of PHP versions including the very latest PHP 8.2. Even better, you can run multiple PHPs all at the same time.

Here’s how!

We’re going to set up a site at https://helloworld.test which will serve a simple project using PHP 8.1. Then we’ll set up a second site, at https://helloworld-82.test which will serve the same project, but using PHP 8.2.

Firstly, download Indigo if you haven’t already. We’ll also create an index.php file with the following contents. Save it in a folder anywhere you like.

<?php
phpinfo();

Create a new stack

Click the + at the bottom of the stack column to create a new stack; let’s call it “Playing with PHP”.

Creating a new stack

Add services

Now we’re ready to add our services. The centre column is the rack. Click the + at the bottom to add Nginx, PHP 8.1 and PHP 8.2. You can add anything else your specific project might need as well.

Adding services

At this point you might notice that the Nginx service has a warning triangle. That’s to remind you that you need to configure a site for it to serve.

Add the sites

Go ahead and click on the Nginx service and add our first site; call it helloworld.test. Point it at the folder containing your index.php that you created earlier, and choose “PHP 8.1” from the PHP service dropdown.

Creating the first site

Next repeat this to add a second site, helloworld-82.test. Point it at the same folder, but choose “PHP 8.2”.

Creating the first site

Start the stack

Click the back arrow at the top to return to the stack overview, and flip the switch to start the stack!

The first time around Indigo will need to prepare your services. This might take a while so be patient. When it’s done, you should see a bunch of green lights… success!

The stack overview

Try your sites

When you hover the sites’ cards, you’ll see a pop-out set of actions. Click the Safari icon in each, and the sites will open in your browser!

Sites in Safari

Wrap-up

Congratulations, you’ve just created two sites, pointing at the same underlying code but running two different versions of PHP. Now you can dive in and play with some of the new features of PHP 8.2!

Need help?

If you got stuck at any point, jump into our forums for help!