Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Laravel fails with undefined function openssl_decrypt()

ErrorCall 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.

  • Applies to PHP 8.3, PHP 8.4, Laravel 12
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 --ini
  2. 2Match what you see, then jump to its fix

    1. 1php -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. 2php -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. 3The 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

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 openssl

2Fix

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=openssl

3Verify

Restart PHP and list the modules.

php -m | grep -i openssl

Confirmed by php.net

Did this fix it?

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-fpm

3Verify

Reload the page; the error is gone.

curl -I https://example.com

Confirmed by php.net

Did this fix it?

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-openssl

3Verify

php -m lists openssl.

php -m | grep -i openssl

Confirmed by php.net

Did this fix it?

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 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 fix

Back 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 fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.