所以在工作中,我的任务是学习并开始使用一些Laravel,所以我一直在Youtube上学习文档和一些教程,但我似乎无法让它发挥作用。我正在使用composer和MAMP来安装Laravel。当我在htdocs中使用命令(在终端中)"composer create project laravel/laravel TestLaravel"时。它很快就出现了这个错误:
➜ htdocs composer create-project laravel/laravel TestLaravel
Installing laravel/laravel (v5.0.1)
- Installing laravel/laravel (v5.0.1)
Loading from cache
Created project in TestLaravel
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- 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.3 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.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.
- Installation request for laravel/framework 5.0.* -> satisfiable by laravel/framework[v5.0.0, v5.0.1, v5.0.2, v5.0.3, v5.0.4, v5.0.5].
我想知道是否有人能为我解决这个问题
谢谢。
Joshua Johnson
Mac OS X Yosemite
您的系统中缺少请求的PHP扩展mcrypt
我通过在我的终端中运行以下命令修复了这个错误:
brew update
brew upgrade
brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew install php54-mcrypt
大多数情况下,当您的MAMP PHP版本与命令版本PHP不匹配时,就会出现此问题。请在终端中键入php-v,然后它将显示类似php5.5的版本。*
问题是你必须在~/.bash_profile
中设置你的MAMP PHP路径,如下所示:
sudo nano ~/.bash_profile
PATH="/Applications/MAMP/bin/php/php5.6.7/bin:$PATH"
仅此而已,如果您想使用默认的系统php,请安装mcrypt-lib。
我解决这个问题的方法是安装Homestead,并确保在运行任何命令之前登录到Homestead虚拟机。MCrypt没有安装在您的本地机器上,但它在Homestead中。
有一个名为mcrypt
的PHP扩展,它通常不会与现有的PHP包一起分发。mcrypt
扩展是用于加密和哈希功能的实际标准PHP扩展。Laravel使用mcrypt。
OS X上的内置PHP没有安装mcrypt
。这意味着你要么需要
- 为PHP中内置的OS X自行构建并安装
mcrypt
扩展 - 使用自制软件构建和安装带有mycrypt的PHP
- 使用"针对OS X预编译"的PHP包
- 使用流浪虚拟机来运行您的开发堆栈
我通常选择第三个选项,并使用lipp.ch包。这是一个长期运行的项目,它源于Marc Liyage从更远的地方管理的旧entropy.ch包。