PHP Development

PHP Extensions and Their Crucial Role in Web Development

By the Domain India teamPublished 8 min read
Knowledge base article
Contents (6 sections)

PHP on its own is a small language core. Almost everything a real website needs, from talking to MySQL to resizing images and handling Hindi or Tamil text correctly, comes from extensions. This guide explains what extensions are, which ones matter for common applications, how to check what your server has, and how to add one, both on shared hosting and on a server you manage yourself.

Key takeaways

Extensions are compiled modules that add functions and classes to PHP, such as pdo_mysql, mbstring, intl, gd, curl and zip. Check what is loaded with php -m or extension_loaded(). On your own VPS you install them with the package manager (apt or dnf) and restart PHP-FPM. On Domain India shared hosting you can't install extensions yourself: pick the PHP version that has what you need, and ask support if something is missing.

1. What a PHP extension is

An extension is a module, usually written in C, that PHP loads at startup. It adds functions (mb_strlen()), classes (PDO, Imagick) or behaviour (OPcache). There are three kinds:

  • Always built in. Some extensions can't be switched off, such as json (always on since PHP 8.0), pcre and hash.
  • Bundled. Shipped with PHP's source and enabled when PHP is built or packaged, such as mbstring, intl, gd, pdo_mysql, curl and zip.
  • Third-party. Maintained outside PHP and installed separately, such as redis, imagick, mongodb, apcu and xdebug.

Extensions are different from libraries you install with Composer. A library is PHP code in your project; an extension is part of the PHP binary on the server. See PHP extensions vs PHP libraries.

2. The extensions most applications need

ExtensionWhat it doesTypically needed by
pdo_mysql and mysqliConnect to MySQL and MariaDBWordPress, Laravel, almost every PHP app
mbstringHandles multibyte text (UTF-8) correctlyLaravel, WordPress, any site with Indian-language text
intlFormats numbers, dates and currencies by locale; Unicode normalisationLaravel, Symfony, e-commerce
curlMakes HTTP requests to APIs and payment gatewaysPayment integrations, plugins, updates
openssl and sodiumEncryption, hashing and secure random numbersLogin systems, tokens, signed data
gd or imagickResize, crop and convert imagesWordPress media, thumbnails, CAPTCHAs
zipRead and write ZIP archivesPlugin installs, imports and exports
xml, dom and simplexmlParse and build XMLFeeds, sitemaps, SOAP and government APIs
bcmathArbitrary-precision mathsMoney calculations, some payment SDKs
opcacheCaches compiled PHP code in memoryPerformance on every production site

Before you install an application, check its requirements page for the exact list; Laravel, WordPress and Magento each publish one.

A few extensions are for development only. Xdebug, for example, is excellent for step debugging and profiling, but it slows PHP down considerably and should never be loaded on a production site.

3. Check which extensions are loaded

On the command line:

bash
php -m                 # list every loaded extension
php -m | grep -i intl  # check for one
php --ri intl          # show one extension's settings

In a web page, which is the more reliable test because the website and the command line can use different PHP versions or settings:

php
<?php
foreach (['pdo_mysql', 'mbstring', 'intl', 'gd', 'curl', 'zip', 'sodium'] as $ext) {
    echo $ext, ': ', extension_loaded($ext) ? 'loaded' : 'MISSING', "\n";
}

Upload it as check.php, open it in your browser, then delete it. A full phpinfo() page also works on a server you manage, but never leave one online: it tells attackers exactly what your server runs.

4. Installing an extension on your own server

This applies only to a VPS or server where you have root access. The short version:

  1. Find the package.
    On Ubuntu or Debian, extensions are packaged as php-intl, php-mbstring and so on (or with the version, such as php8.3-intl). On AlmaLinux or Rocky Linux, run dnf search php- to see the exact names.
  2. Install it.
    For example sudo apt install php-intl or sudo dnf install php-intl. The package normally enables the extension for you.
  3. Restart PHP.
    Restart PHP-FPM, for example sudo systemctl restart php8.3-fpm on Ubuntu or Debian, or sudo systemctl restart php-fpm on AlmaLinux and Rocky Linux.
  4. Confirm.
    Check with php -m and with the web test page above.

When no package exists, build the extension from PECL, which needs the PHP development headers and must be rebuilt after each PHP upgrade. The detailed steps for each operating system, including PECL, are in enabling PHP extensions on a VPS.

Old guides list extensions that no longer exist

mcrypt and xmlrpc are no longer part of PHP, and the old mysql_* functions were removed in PHP 7. json no longer needs installing, because it is always on. If an application still asks for a removed extension, the application needs updating. Also ignore yum and CentOS instructions: CentOS Linux is end of life.

5. When an extension seems to be missing

  • "Call to undefined function mb_strlen()" or "Class 'IntlDateFormatter' not found" means the extension is not loaded for the PHP version that ran the code.
  • Command line and website disagree. They often use different PHP versions or php.ini files. Trust the web test page for website problems.
  • Wrong PHP version selected. Each PHP version has its own set of extensions. Switching the version can add or remove one.
  • The extension loads but fails. Check the PHP error log; a missing system library or a version mismatch is the usual cause.

6. PHP extensions on Domain India shared hosting

On shared hosting, extensions are part of the server's PHP builds, which every account shares, so you can't add one yourself, and dl(), which loads an extension at runtime, is disabled. What you can do is choose the PHP version per domain: on cPanel in MultiPHP Manager (new accounts use PHP 8.3), and on DirectAdmin in the panel's PHP settings.

cPanel MultiPHP Manager showing the system PHP version, a PHP Version dropdown with Apply, and a domain row with a checkbox and its current version
Choose the PHP version per domain in MultiPHP Manager.

When we measured PHP 8.3 on our cPanel server (command-line PHP, 23 September 2026), it included pdo_mysql, mysqli, mbstring, intl, curl, gd, imagick, zip, bcmath, soap, xml, pgsql and OPcache. It did not include sodium, redis, memcached, apcu or mongodb. The DirectAdmin builds, version by version, are listed in installing and managing PHP extensions in DirectAdmin.

Two more things to know:

  • phpinfo() is disabled on our cPanel servers, so use the extension_loaded() test page from section 3 instead.
  • Some PHP functions are disabled on shared hosting for security, even when their extension is loaded. See PHP disabled functions on shared hosting.

If your application needs an extension that isn't there, open a ticket with the extension name and your PHP version before you build around it. If you need full control, a VPS lets you install anything; our VPS plans are self-managed.

Prices on the cards are Domain India list prices on 19 September 2026, excluding 18% GST.

cPanel Starter
₹125/mo + GST
  • 25 GB NVMe SSD Storage
  • 50 GB Monthly Bandwidth
  • 1 Website
  • 10 Email Accounts
See plan details
VPS Starter
₹552.65/mo + GST
  • 1 vCPU
  • 2 GB DDR4 RAM
  • 64 GB NVMe SSD Storage
  • 2 TB Monthly Bandwidth
See plan details
What is a PHP extension?

A PHP extension is a compiled module that adds functions, classes or features to PHP, such as database drivers (pdo_mysql), text handling (mbstring) or image processing (gd). Extensions are installed on the server, unlike Composer libraries, which live in your project.

How do I check which PHP extensions are installed?

Run php -m on the command line, or upload a small page that calls extension_loaded('name') for each extension you need. The web page is the more reliable test for a website, because the command line can use a different PHP version.

Can I install PHP extensions on Domain India shared hosting?

No. Extensions are built into the server's PHP versions, which all accounts share. You can switch PHP version per domain, and you can ask support about a missing extension. On a VPS you can install any extension yourself.

How do I install a PHP extension on Ubuntu?

Run sudo apt install php-intl (replacing intl with the extension you need), restart PHP-FPM with sudo systemctl restart php8.3-fpm using your PHP version, and confirm with php -m.

Do I need to install the JSON extension?

No. Since PHP 8.0, JSON support is always built in and cannot be disabled.

Should Xdebug be enabled on a live website?

No. Xdebug is a development tool for debugging and profiling, and it slows PHP down considerably. Use it on your own computer or a staging server only.

Ready to host your PHP app? Compare cPanel hosting for the common extensions ready to go, or a VPS for full control. Questions about a specific extension? Chat with us 24/7.

Host your PHP application

Choose your PHP version per domain, with the common extensions for WordPress and Laravel already built in.

See cPanel plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app