laravel Encrypter.php 中未定义的函数 openssl_encrypt()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39618353/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 14:29:40  来源:igfitidea点击:

Undefined function openssl_encrypt() in Encrypter.php

phplaravellaravel-5.3php-openssl

提问by gegham-ayvazyan

I get the following error:

我收到以下错误:

Call to undefined function openssl_encrypt() in Encrypter.php line 73

调用 Encrypter.php 第 73 行中未定义的函数 openssl_encrypt()

It may seem obvious, but OpenSSL extension is enabled in my config, this error occurs only when using artisan serve, looked through config and it is enabled.

看起来似乎很明显,但是在我的配置中启用了 OpenSSL 扩展,只有在使用artisan serve、查看配置并启用时才会出现此错误。

Did some research: Copied the following code in the artisanfile

做了一些研究:在artisan文件中复制了以下代码

$loaded = extension_loaded('openssl');
var_dump($loaded);die();

And it returned true. But when I copy the same code into /public/index.phpit returns false.

它回来了true。但是当我将相同的代码复制到/public/index.php它时返回false.

So I assumed that the opensslextension is enabled in php-cli, but for some reason it gets disabled after reaching the bootstrap file.

所以我假设openssl扩展在 中启用php-cli,但由于某种原因它在到达引导文件后被禁用。

*And I am using UniServer if someone is interested.

*如果有人感兴趣,我正在使用 UniServer。

回答by Titken

Had same issue on Apache 2.4, PHP7, Fresh Laravel 5.3 on a Windows. My Apache error log showed

在 Windows 上的 Apache 2.4、PHP7、Fresh Laravel 5.3 上有同样的问题。我的 Apache 错误日志显示

"PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\wamp\php\ext\php_openssl.dll' - The operating system cannot run %1.\r\n in Unknown on line 0"

Fixed it by copying libeay32.dll and ssleay32.dll from PHP-root folder to Apache/bin folder and restarted Apache.

通过将 libeay32.dll 和 ssleay32.dll 从 PHP-root 文件夹复制到 Apache/bin 文件夹并重新启动 Apache 来修复它。