Laravel需要Mcrypt PHP扩展 [英] Laravel requires the Mcrypt PHP extension

查看:141
本文介绍了Laravel需要Mcrypt PHP扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在OSXLaravel 4中使用migrate函数.但是,出现以下错误:

I am trying to use the migrate function in Laravel 4 on OSX. However, I am getting the following error:

Laravel requires the Mcrypt PHP extension.

据我了解,该功能已启用(请参见下图).

As far as I understand, it's already enabled (see the image below).

出什么问题了,我该如何解决?

What is wrong, and how can I fix it?

推荐答案

启用网络的扩展名和启用命令行的扩展名可以不同.在终端中运行php -m,并检查是否列出了mcrypt.如果不是,请通过从终端运行php --ini来检查命令行从何处加载php.ini文件.

The web enabled extensions and command line enabled extensions can differ. Run php -m in your terminal and check to see if mcrypt is listed. If it's not then check where the command line is loading your php.ini file from by running php --ini from your terminal.

在此php.ini文件中,您可以启用扩展名.

In this php.ini file you can enable the extension.

我听说OSX上的人遇到问题,原因是终端指向OSX随附的本机PHP.相反,您应该更新bash配置文件以包括PHP的实际路径.这样的事情(我实际上没有使用OSX,所以可能不是100%):

I have heard of people on OSX running in to problems due to the terminal pointing to the native PHP shipped with OSX. You should instead update your bash profile to include the actual path to your PHP. Something like this (I don't actually use OSX so this might not be 100%):

export PATH=/usr/local/php5/bin:$PATH

Ubuntu

在早期版本的Ubuntu(14.04之前的版本)上,当您运行sudo apt-get install php5-mcrypt时,实际上并没有将扩展安装到mods-available中.您需要对其进行符号链接.

Ubuntu

On earlier versions of Ubuntu (prior to 14.04) when you run sudo apt-get install php5-mcrypt it doesn't actually install the extension into the mods-available. You'll need to symlink it.

sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/mcrypt.ini

在所有Ubuntu版本上,您需要在安装Mod后启用它.您可以使用php5enmod来做到这一点.

On all Ubuntu versions you'll need to enable the mod once it's installed. You can do that with php5enmod.

sudo php5enmod mcrypt
sudo service apache2 restart

注意

  • PHP 7.1 deprecated mcrypt and 7.2 has removed the mcrypt extension entirely
  • Laravel 5.1 and later removed the need for mcrypt

这篇关于Laravel需要Mcrypt PHP扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆