Laravel fails with undefined function openssl_decrypt()
Call to undefined function Illuminate\Encryption\openssl_decrypt()Short answer
openssl_decrypt() belongs to the PHP openssl extension. When the PHP that runs Laravel has no openssl loaded, any encryption call fails with this error. Check php -m for that PHP, enable the extension in the php.ini it really reads, and restart the web server or PHP-FPM.
Fix it fast
1Find out which cause you have
Ask the PHP binary and the web server's PHP separately. They can load different files.
php -m | grep -i openssl php --ini2Match what you see, then jump to its fix
- 1
php -m prints nothing for openssl, and php.ini has the line commented out.The openssl extension is not enabled in the php.ini that is loadedFix - 2
php -m shows openssl, but the page in the browser still fails.You edited the file for the command line, but the web server reads another oneFix - 3
The openssl line is not in php.ini at all, or the line is on but PHP still reports no openssl on Windows.This PHP binary was compiled without OpenSSL, or Windows cannot find its DLLsFix
- 1
What does the error look like?
Call to undefined function Illuminate\Encryption\openssl_decrypt()Call to undefined function openssl_decrypt()
Cause 1 of 3
The openssl extension is not enabled in the php.ini that is loaded
1Check
Extensions are switched on in php.ini with an extension line, and a semicolon in front of it disables it. php --ini shows which file is loaded.
php --ini
php -m | grep -i openssl2Fix
Remove the semicolon from the openssl extension line in the loaded php.ini. On Windows the line is extension=openssl; extension_dir must also point at the ext folder.
; php.ini
extension=openssl3Verify
Restart PHP and list the modules.
php -m | grep -i opensslConfirmed by php.net
Cause 2 of 3
You edited the file for the command line, but the web server reads another one
1Check
PHP looks for php-SAPI.ini first and then php.ini, so the CLI, PHP-FPM and Apache can each load their own file. php --ini only tells you what the CLI loaded.
php --ini
# Debian and Ubuntu keep one tree per SAPI, for example:
ls /etc/php/8.3/2Fix
Enable the extension in the configuration of the SAPI that serves the site, then restart that service.
sudo systemctl restart php8.3-fpm3Verify
Reload the page; the error is gone.
curl -I https://example.comConfirmed by php.net
Cause 3 of 3
This PHP binary was compiled without OpenSSL, or Windows cannot find its DLLs
1Check
The manual says OpenSSL support needs PHP compiled with --with-openssl. On Windows the extension needs its library DLLs on the system PATH.
php -i | grep -i "openssl"2Fix
Use a PHP build that includes OpenSSL, or recompile with the option. On Windows make the PHP folder part of PATH.
./configure --with-openssl3Verify
php -m lists openssl.
php -m | grep -i opensslConfirmed by php.net
How do I stop it coming back?
- After a PHP upgrade, check php -m for every extension your app needs, for the CLI and for the web server.
- Keep php.ini changes in version-controlled setup notes, not only on the server.
- Use composer check-platform-reqs in deploy to catch missing extensions early.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fixBack end
Composer says the root composer.json requires a PHP version your PHP does not satisfy
Your requirements could not be resolved to an installable set of packages.
Composer compares the php constraint in your composer.json, or in a package, with the PHP that runs Composer.
3 causes, each with a fix