Free

Free coded apps to suit all. No sign up, no email, usable offline, updates when I can, feedback welcome. Send feedback

How-to

How to enable a PHP extension on a local server

Enable a PHP extension on your local server by ticking its box on the PHP page of Server by Zaweba; the change applies with a graceful Apache restart.

How to enable a PHP extension on a local server

To enable a PHP extension in Server by Zaweba, open the PHP page, choose the PHP version your site uses and tick the extension's box. Every extension in that version's ext folder is listed as a tick box, and the change applies with a graceful Apache restart a moment later. There's no php.ini line to hunt for.

Extensions add abilities to PHP: image handling, international text, database drivers, caching and debugging among them. Frameworks and content systems often refuse to install until a particular one is on, and the error message names it. Turning that one on is usually the whole fix.

Picking the version first

Server ships four PHP versions, 5.6, 7.4, 8.2 and 8.3. Each keeps its own php.ini and its own set of extensions, which is why different sites can run different versions at the same time. The catch is that ticking an extension for PHP 8.3 does nothing for a site on 8.2. Check the site's version in the sites list, then pick the same one on the PHP page.

The list you see comes from that version's ext folder, so it shows what's really available for that build. An older version may have a slightly different set from a newer one.

Ticking the box

Find the extension the error message named and tick it. Server writes the change into php.ini as a single-line edit, leaving everything else in the file alone, including anything you've added yourself. Shortly after your last change Apache restarts gracefully, so you can tick several in a row and it restarts once.

Two extensions are handled a little differently behind the scenes. Opcache and xdebug are Zend extensions, which PHP has to load with a different line in php.ini. Server writes them as zend_extension for you, which is one of the small details that trips people up when they edit the file by hand.

Unticking works the same way in reverse. If a site behaves oddly after you turned something on, untick it and see whether the problem goes.

Checking it worked

The surest check is a phpinfo page. The new-site wizard can make a starter index.php that shows phpinfo, and its output lists every loaded extension with its own section. Refresh it after the restart and look for the name.

If the extension still isn't there, look at the PHP error log for that version on the Logs page. PHP writes a line there when it can't load something at start-up. And confirm you ticked the box under the right version, which is the most common slip.

A word on xdebug and opcache

Xdebug is a debugging extension. It's very useful while you're stepping through code, but it slows every request, so it's sensible to tick it when you need it and untick it afterwards.

Opcache keeps compiled scripts in memory so pages come back faster. On a local server you're changing files all the time, so if an edit doesn't seem to show up, it's worth knowing opcache is one of the things in play.

When the tick boxes aren't enough

Some extensions need a setting of their own as well as being switched on. For those, the PHP page can open php.ini in Notepad so you can add the extra line. Because Server only ever changes single lines, your additions survive its later edits. If a php.ini gets into a state you can't untangle, the PHP page can start a fresh one and keeps the old copy for reference.

The extension tick boxes are part of the Windows version of Server by Zaweba. The separate build for macOS and Linux leaves them out, so on those systems extensions come from the PHP that build provides.

For most jobs, though, it really is one tick, a short pause and a refresh.