PHP extensions and PHP libraries both add features to PHP, but they live in different places and are installed by different people. An extension is part of the PHP program on the server; a library is PHP code inside your project. Knowing which is which tells you what you can add yourself on shared hosting, what you need to ask for, and when you need your own server.
An extension is a compiled module (usually C) loaded by PHP itself, such as mysqli, intl, gd or imagick; it is installed server-wide by whoever runs the server. A library is plain PHP code, such as Guzzle, PHPMailer or Dompdf, that you add to your project, usually with Composer. On Domain India shared hosting you choose from the extensions each PHP version already has, and you add libraries yourself by running Composer on your own computer and uploading the vendor folder. Composer itself cannot run on our shared servers.
1. Extensions and libraries side by side
| Question | PHP extension | PHP library |
|---|---|---|
| What is it? | A compiled module loaded by the PHP binary | PHP source code in your project |
| Examples | mysqli, pdo_mysql, mbstring, intl, gd, imagick, sodium, opcache | Guzzle, PHPMailer, Dompdf, Carbon, Monolog |
| Installed with | The OS package manager (apt, dnf) or PECL | Composer, or by copying the files |
| Who can install it | The server administrator (root) | Anyone who can upload files to the project |
| Scope | Every site that uses that PHP version | Only the project that includes it |
| Speed | Native code: fast | Interpreted PHP: fast enough for most work, especially with OPcache |
| Shared hosting | Choose a PHP version that has it; you can't add one | Fully usable; you add them yourself |
The two often work together. Many libraries require an extension: Dompdf needs mbstring and dom, Intervention Image needs gd or imagick, and a library that encrypts data may need sodium or openssl. A library's composer.json lists these as ext-... requirements.
2. What a PHP extension is
An extension is loaded when PHP starts and adds functions, classes or engine features. Some are always built in (json, pcre, hash), some ship with PHP and are switched on when PHP is packaged (mbstring, intl, gd, curl, zip), and some come from outside PHP (imagick, redis, mongodb, xdebug).
Check what is loaded:
php -m # list loaded extensions (command line)
php --ri intl # details for one extensionFor a website, a small test page is more reliable, because the command line can use a different PHP version:
<?php
foreach (['mysqli', 'mbstring', 'intl', 'gd', 'imagick', 'sodium'] as $ext) {
echo $ext, ': ', extension_loaded($ext) ? 'loaded' : 'missing', "\n";
}Delete the page after use. For which extensions common applications need, see PHP extensions and their role in web development.
3. What a PHP library is
A library is ordinary PHP code that solves one problem well: sending mail, making HTTP requests, generating PDFs, handling dates. Composer is the standard way to add libraries: it downloads them into a vendor folder, resolves their own dependencies and writes an autoloader, so your code needs one line:
<?php
require __DIR__ . '/vendor/autoload.php';
$client = new \GuzzleHttp\Client(['timeout' => 10]);
$response = $client->get('https://api.example.com/status');
echo $response->getStatusCode();Libraries are portable: the same vendor folder works on any server with a compatible PHP version and the extensions the libraries require. Get them from Packagist, keep them updated, and run composer audit to check for known security issues.
4. Which one do you need?
mysqli, pdo_mysql, pgsql). Pick a PHP version that has it.curl extension, or plain curl_* functionsgd or imagick), often through a library such as Intervention Imagembstring and domopcache), switched on by the serverIf a library needs an extension that is missing, the library cannot fix that: Composer stops with a message such as "requires ext-intl", or the code fails with "Call to undefined function". The fix is a PHP version or server that has the extension.
5. Adding an extension on your own VPS
On a server where you have root, install extensions with the operating system's packages and restart PHP-FPM:
# Ubuntu or Debian (package names may include the version, e.g. php8.3-intl)
sudo apt install php-intl
sudo systemctl restart php8.3-fpm
# AlmaLinux or Rocky Linux
sudo dnf install php-intl
sudo systemctl restart php-fpmUse PECL only when no package exists; a PECL build has to be rebuilt after every PHP upgrade. Avoid old guides that use yum on CentOS, which is end of life, or that install mcrypt, which is no longer part of PHP. The detailed steps are in installing PHP extensions across operating systems. This section applies only to a VPS or server you manage, not to shared hosting.
6. Extensions and libraries on Domain India shared hosting
On shared hosting the PHP builds are shared by every account on the server, so you cannot install an extension, and dl() is disabled. You choose the PHP version per domain, in MultiPHP Manager on cPanel and in the PHP settings on DirectAdmin, and each version has its own set of extensions. What we measured in September 2026 (command-line PHP):
| Extension | cPanel hosting | DirectAdmin hosting |
|---|---|---|
mysqli, pdo_mysql, mbstring, intl, curl, gd, zip | Yes | Yes |
imagick | PHP 8.2 and 8.3 only | PHP 8.1 and 8.2 |
sodium | Not on PHP 8.2 and later | PHP 8.1 to 8.3 |
| ionCube Loader | Not on PHP 8.2 and later | PHP 8.1 to 8.3 |
pgsql and ldap | Yes | Not built |
| OPcache | On | On, except PHP 8.3 |
| Xdebug, APCu, Redis, Memcached, MongoDB, Swoole | No | No |
cPanel offers PHP up to 8.5 (new accounts start on 8.3); DirectAdmin offers up to 8.3. If your application needs an extension that isn't listed for your version, open a ticket with the extension name and your PHP version before you build around it.
Libraries work normally, with two cautions:
- Run Composer on your computer, not on the server. Composer needs
proc_open, which is disabled on our shared servers. Setconfig.platform.phpincomposer.jsonto your hosting PHP version, runcomposer install --no-dev --optimize-autoloaderlocally or in CI, and upload the project with itsvendorfolder. See installing PHP libraries with Composer on cPanel hosting. - Some library features call disabled functions. A library that starts other programs (for example Symfony Process) or opens raw network sockets will fail, even though the library itself installs fine. On cPanel that includes SMTP sending from PHP; PHPMailer works when it hands the message to the server's mail function. The full list is in PHP disabled functions on shared hosting.
If you need an extension we don't provide, such as Redis or MongoDB, a VPS lets you install anything; our VPS plans are self-managed.
Frequently asked questions
What is the difference between a PHP extension and a PHP library?
An extension is a compiled module that the PHP program loads on the server, such as mysqli or gd. A library is PHP code in your project, such as Guzzle or PHPMailer, usually added with Composer. Extensions are installed by the server administrator; libraries by the developer.
Can I install PHP extensions on Domain India shared hosting?
No. Extensions are part of the server's shared PHP builds. You can switch PHP version per domain to get a different set of extensions, and you can ask support about a missing one. On a VPS you can install any extension yourself.
Can I use Composer on Domain India shared hosting?
Not on the server, because Composer needs proc_open, which is disabled on our shared servers. Run Composer on your own computer or in CI, then upload your project including the vendor folder. The libraries themselves run normally.
Are PHP extensions faster than libraries?
Yes, extensions run as native code. For most website work the difference is small, especially with OPcache, so choose a library when it does the job and an extension when you need low-level features such as image processing or database drivers.
Why does Composer say a package requires ext-something?
The library needs a PHP extension that your PHP version does not load. Choose a PHP version that has it, ask support whether it is available, or use a VPS where you can install it.
Is Redis or MongoDB available on shared hosting?
No. Neither the Redis nor the MongoDB extension is available on our shared servers. Use a VPS, or choose MySQL or PostgreSQL on shared hosting.
Ready to build? Compare cPanel hosting for common PHP extensions ready to use, or a VPS if you need extensions of your own.
Choose your PHP version per domain, with the common extensions for WordPress and Laravel already built in.
See cPanel plans