The Mcrypt Library is Dead: Why You're Seeing That Warning on PHP 7.2
If you are running composer update on Ubuntu and seeing a warning about mcrypt.so, your application is likely failing because the underlying cryptographic library has been removed from modern PHP distributions. This isn't a configuration error you can fix by reinstalling an old package; it is a fundamental shift in how PHP handles encryption.
The specific error message indicates that PHP attempted to load /usr/lib/php/20170718/mcrypt.so but failed. The directory name 20170718 confirms you are running PHP 7.2, where the extension was already deprecated in favor of newer standards. In previous versions like PHP 5.x, this library was widely used for stream ciphers and block encryption, often loaded automatically via php.ini. However, starting with PHP 7.0, the development team marked it as deprecated due to security vulnerabilities and performance issues. By the time you reach PHP 7.2, most Linux distributions have completely removed the package from standard repositories to reduce attack surface and encourage migration.
Attempting to manually load this library or forcing a reinstall is futile. The mcrypt extension relies on internal algorithms that were intentionally broken in later versions. If your Laravel application depends on mcrypt, you are facing a hard dependency break. You cannot simply "enable" it again because the code itself is incompatible with the current PHP engine.
To resolve this, you must audit your composer.json file to identify which package is requesting the mcrypt extension. Typically, this stems from older versions of packages like phpseclib/phpseclib, certain legacy payment gateways, or specific encryption helpers that haven't updated their requirements for years. You need to check the require-dev or main require sections for these dependencies and look for alternative implementations.
The standard replacement involves migrating from mcrypt to either OpenSSL (via the native openssl extension) or the Sodium extension. Laravel provides a robust built-in encryption system that handles this transition seamlessly if you configure it correctly. You can update your config/app.php configuration to use the application key and ensure no custom cipher modes relying on deprecated functions are hardcoded.
If a third-party package strictly requires mcrypt, you may need to replace that package entirely or wait for an upstream update. There is no viable workaround to keep using mcrypt with PHP 7.2, and attempting to downgrade PHP versions introduces significant security risks and compatibility issues with modern web servers. The path forward is code refactoring to utilize the OpenSSL extension, which offers superior performance and security guarantees.
For projects hosted on LaravelCompany.com or similar platforms, ensuring your dependencies are up to date with modern cryptographic standards is part of maintaining a secure environment. When updating Composer, always check for breaking changes in major dependency updates that might drop support for obsolete extensions. Ignoring the warning until it becomes a fatal error can lead to unexpected downtime when the PHP runtime simply refuses to start without the requested library.