首页 > 解决方案 > 如何将 MCRYPT 路径设置回 MAMP Pro

问题描述

我已经使用 PHP 7.2 在 MAMP Pro 上安装了 MCRPYT,并且能够运行我的旧项目 Laravel 4.2。

这是我的 MAMP PHP.ini 中的列表

extension=mcrypt.so

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
extension_dir = "/Applications/MAMP/bin/php/php7.2.1/lib/php/extensions/no-debug-non-zts-20170718/"

但是当我运行which mcrypt它时/usr/local/bin/mcrypt,我认为它应该在 MAMP Pro 下。

我之所以问这个是因为,我想将我的项目 Laravel 4.2 升级到 5.0。这是我尝试安装新的 Laravel 5.0 时的问题

composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/framework v5.0.9 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.8 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.7 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.6 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.5 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.4 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.35 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.34 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.33 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.32 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.31 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.3 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.29 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.28 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.27 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.26 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.25 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.24 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.23 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.22 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.21 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.20 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.2 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.19 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.18 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.17 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.16 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.15 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.14 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.13 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.12 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.11 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.10 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.1 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework v5.0.0 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - laravel/framework 5.0.30 requires ext-mcrypt * -> the requested PHP extension mcrypt is missing from your system.
    - Installation request for laravel/framework 5.0.* -> satisfiable by laravel/framework[5.0.30, v5.0.0, v5.0.1, v5.0.10, v5.0.11, v5.0.12, v5.0.13, v5.0.14, v5.0.15, v5.0.16, v5.0.17, v5.0.18, v5.0.19, v5.0.2, v5.0.20, v5.0.21, v5.0.22, v5.0.23, v5.0.24, v5.0.25, v5.0.26, v5.0.27, v5.0.28, v5.0.29, v5.0.3, v5.0.31, v5.0.32, v5.0.33, v5.0.34, v5.0.35, v5.0.4, v5.0.5, v5.0.6, v5.0.7, v5.0.8, v5.0.9].

  To enable extensions, verify that they are enabled in your .ini files:
    - /Applications/MAMP/bin/php/php7.2.1/conf/php.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

笔记

如果你想知道我是如何使用 PHP 7.2 和 MCrypt 来运行 Laravel 4.2 的。检查此链接。

https://medium.com/@tomgrohl/making-laravel-4-2-work-with-php-7-2-e9149a9428c3

标签: phplaravel

解决方案


如果php版本低于7.1:

安装并启用 mcrypt:

sudo apt-get install mcrypt php-mcrypt
sudo phpenmod mcrypt

尝试找到您的 php.ini 并打开它。

vim php.ini

在此文件中放入一行

extension=mcrypt.so

重启php和apache。

别的

尝试将您的 laravel 版本升级到 5.5 以上。喜欢:

     "laravel/framework": "5.5.*"

因为您安装的框架是 5.0,所以它需要PHP >= 5.4, PHP < 7. 请参阅:https ://laravel.com/docs/5.0#server-requirements


推荐阅读