php 找不到 mcrypt => 调用未定义的函数 Laravel\mcrypt_create_iv()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12479983/
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-08-25 03:38:16  来源:igfitidea点击:

can't find mcrypt => Call to undefined function Laravel\mcrypt_create_iv()

phposx-mountain-lionmcryptlaravel

提问by coryj

Trying to set up Laravel and keep getting hit with this error. I installed mcrypt through brew and it is located in /usr/local/Cellar. Any thoughts? .. It's not showing up in terminal command php -m either, if that matters. I'm running Mountaion Lion with macs native web server.

尝试设置 Laravel 并不断遇到此错误。我通过 brew 安装了 mcrypt,它位于 /usr/local/Cellar。有什么想法吗?.. 如果这很重要,它也没有出现在终端命令 php -m 中。我正在使用 macs 本机 Web 服务器运行 Mountaion Lion。

采纳答案by Deinumite

You need to enable it in your php.inifile as well and probably restart Apache.

您还需要在您的php.ini文件中启用它,并可能重新启动 Apache。

In php.iniyou will find ;mcrypt.soand remove the ;from it.

php.ini你会发现;mcrypt.so;从中删除。

Or, if it's not in there, just add mcrypt.sosomewhere.

或者,如果它不在那里,只需添加mcrypt.so某处。

Also the salt option has been deprecated as of PHP 7.0.0. It is now preferred to simply use the salt that is generated by default.

自 PHP 7.0.0 起,salt 选项也已弃用。现在更喜欢简单地使用默认生成的盐。

回答by Sophy

Ubuntu or any Debian based Linux users can install the required package with apt-get:

Ubuntu 或任何基于 Debian 的 Linux 用户可以使用以下命令安装所需的软件包apt-get

sudo apt-get install php5-mcrypt

Remember to restart the web server afterwards:

记得之后重新启动网络服务器:

sudo service apache2 restart

If it still doesn't work, try to link the configuration file to the appropriate configuration folder for the web server. Thanks to dave1010for this hint in the comments.

如果仍然不起作用,请尝试将配置文件链接到 Web 服务器的相应配置文件夹。感谢dave1010在评论中的提示。

sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/   # for Apache
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/cli/conf.d/       # for CLI

And again, restart the web server:

再次,重新启动 Web 服务器:

sudo service apache2 restart

Perhaps, if not working yet, you need also the line showed by @RahulPrasad, with php5enmod mcrypt.

也许,如果还没有工作,您还需要@RahulPrasad 显示的行,带有php5enmod mcrypt.

回答by Rahul Prasad

Try sudo php5enmod mcrypt && sudo service apache2 restart

尝试 sudo php5enmod mcrypt && sudo service apache2 restart

回答by darronz

You've installed mcryptwhen you actually wanted the php56-mcryptphp module.

mcrypt当您真正想要php56-mcryptphp 模块时,您已经安装了。

You stated in your question that you can see mcryptinstalled in /usr/local/Cellarand that you're using OSX. So, the easiest way to install the mcrypt PHP module on OSX using Homebrewis:

您在问题中表示可以看到mcrypt已安装/usr/local/Cellar并且您正在使用OSX. 因此,使用Homebrew在 OSX 上安装 mcrypt PHP 模块的最简单方法是:

// assuming you have php56
brew install php56-mcrypt

If homebrew can't find the correct package you may need to tap the PHP repositories found on GitHub:

如果自制软件找不到正确的包,您可能需要点击在 GitHub 上找到的 PHP 存储库

brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php

Now when you issue the command brew search mcrypt, you should see something like:

现在,当您发出命令时brew search mcrypt,您应该看到如下内容:

libtomcrypt   mcrypt   php53-mcrypt   php54-mcrypt   php55-mcrypt   php56-mcrypt

Several other posters have mentioned the need to edit your php.inifile. This will be unnecessary as homebrew will take care of activating the module for you. It places the configuration file at /usr/local/etc/php/5.6/conf.d/ext-mcrypt.ini

其他几张海报提到需要编辑您的php.ini文件。这将是不必要的,因为自制软件会为您激活模块。它将配置文件放在/usr/local/etc/php/5.6/conf.d/ext-mcrypt.ini

回答by duality_

You don't have the mcrypt PHP extension installed.

您没有安装 mcrypt PHP 扩展。

For a Mac, I followed these instructions: mcrypt on Mac 10.7 or 10.8.

对于 Mac,我遵循以下说明: mcrypt on Mac 10.7 或 10.8

They look like a lot, but it's not, it's very easy to follow in it works!

它们看起来很多,但事实并非如此,它的工作原理很容易遵循!

回答by James Paterson

Just a note for people who have recently upgraded to PHP 7 - The MCRYPT library has been deprecated. If you upgraded to PHP 7 and are now seeing this error, that is why. You should switch to an alternative library, some alternatives are mentioned in this thread.

只是给最近升级到 PHP 7 的人一个注意事项 - MCRYPT 库已被弃用。如果您升级到 PHP 7 并且现在看到此错误,这就是原因。您应该切换到替代库,此线程中提到了一些替代方案。

回答by Andrew

You may have installed mycrypt but not have the php_mcrypt module installed / enabled.

您可能已经安装了 mycrypt 但没有安装/启用 php_mcrypt 模块。

回答by Eric Norcross

This is what finally worked for me:

这最终对我有用:

brew reinstall --with-homebrew-curl --with-httpd php56
brew reinstall --build-from-source php56-mcrypt

I also had to do sudo chmod 777 /usr/local/etc/php/5.6/conf.dbecause I got errors when the second brew reinstalltried to add the ext-mcrypt.inito that directory.

我也不得不这样做,sudo chmod 777 /usr/local/etc/php/5.6/conf.d因为当第二个brew reinstall尝试将ext-mcrypt.ini.

回答by Kris

Go to the CLI folder in your php instalation, and find php.ini in there and enable mcrypt. Terminal sometimes uses another php.ini, which is usually in the CLI folder.

转到 php 安装中的 CLI 文件夹,并在其中找到 php.ini 并启用 mcrypt。终端有时会使用另一个 php.ini,它通常位于 CLI 文件夹中。

回答by gmeben

I installed php and mcrypt with Homebrew, but I still experienced this error after doing brew updatea few times. I think my setup has just gotten a bit borked over time.

我用 Homebrew 安装了 php 和 mcrypt,但我做brew update了几次后仍然遇到这个错误。我认为我的设置随着时间的推移变得有点无聊。

It turns out my php was being configured from /private/etc/php.ini, not/usr/local/etc/php/5.4/php.inias Homebrew recommends. Mcrypt is not even being included from /usr/local/etc/php/5.4/ext-mcrypt.iniwhich doesn't make a lot of sense considering php -iproduces this for me:

事实证明,我的 php 是从/private/etc/php.ini配置的,而不是Homebrew 推荐的/usr/local/etc/php/5.4/php.ini。Mcrypt 甚至没有被包含在/usr/local/etc/php/5.4/ext-mcrypt.ini 中,考虑到php -i这对我来说没有多大意义:

Configuration File (php.ini) Path => /usr/local/etc/php/5.4
Loaded Configuration File => /usr/local/etc/php/5.4/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/5.4/conf.d
Additional .ini files parsed => /usr/local/etc/php/5.4/conf.d/ext-mcrypt.ini

My solution:

我的解决方案:

  1. Edit /private/etc/php.inias a superuser
  2. Add extension="/usr/local/Cellar/php54-mcrypt/5.4.28/mcrypt.so"and save
  3. Restart Apache with sudo apachectl restart
  1. /private/etc/php.ini以超级用户身份编辑
  2. 添加extension="/usr/local/Cellar/php54-mcrypt/5.4.28/mcrypt.so"并保存
  3. 重新启动Apache sudo apachectl restart