无法使用 Composer 在 Windows 上安装 Mailgun 库

Can't install Mailgun library on Windows with composer

我一直在尝试使用 composer 在我的本地主机中安装 mailgun 库。我在命令提示符中写了以下命令:

php composer require mailgun/mailgun-php:~1.3

它给了我错误 Could not open input file: composer

然后我尝试删除上一个命令开头的 php

composer require mailgun/mailgun-php:~1.3

它显示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
./composer.json has been updated
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
- The requested package mailgun/mailgun-php 1.0.0 could not be found.
Problem 2
- guzzle/guzzle v3.7.4 requires ext-curl * -> the requested PHP extension cu
rl is missing from your system.
- guzzle/guzzle v3.7.3 requires ext-curl * -> the requested PHP extension cu
rl is missing from your system.
- guzzle/guzzle v3.7.2 requires ext-curl * -> the requested PHP extension cu
rl is missing from your system.
- guzzle/guzzle v3.7.1 requires ext-curl * -> the requested PHP extension cu
rl is missing from your system.
- guzzle/guzzle v3.7.0 requires ext-curl * -> the requested PHP extension cu
rl is missing from your system.
- Installation request for guzzle/guzzle 3.7.* -> satisfiable by guzzle/guzz
le[v3.7.0, v3.7.1, v3.7.2, v3.7.3, v3.7.4].

Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your min
imum-stability setting
 see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> f
or more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common
problems.

Installation failed, reverting ./composer.json to its original content.

我这几天一直在努力安装mailgun,请帮助我。

更新:

仅供参考:我正在使用 xampp

使用 Windows

composer.phar 文件详细信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
"name":"mailgun/mailgun-php",
"description":"The Mailgun SDK provides methods for all API functions.",
"require": {
   "guzzle/guzzle":"3.7.*"
},
"require-dev": {
   "phpunit/phpunit":"3.7.*"
},
"autoload": {
   "psr-0": {
       "Mailgun\\\\Tests":"tests/",
       "Mailgun":"src/"
    }
},
"license":"MIT",
"authors": [
    {
       "name":"Travis Swientek",
       "email":"[email protected]"
    }
],
"minimum-stability":"stable"
}


mailgun 使用 guzzle 需要 php>=5.3.3 和 curl 扩展

执行以下操作:

  • 更新作曲家:composer self-update
  • 检查 php 版本:php -v
  • 安装 curl 扩展:[sudo] apt-get install php5-curl

如果您使用 Windows,请尝试以下方法:

  • WAMP 卷曲安装
  • 如何在 xampp 中启用 curl?
  • 如何在 Windows 上安装 cURL?

如果您仍然收到 composer require ... 错误

  • 如果存在,请从项目的根目录中删除"composer.lock"文件。
  • 在项目的根目录中创建一个"composer.json"文件,如下所示。
  • 运行 composer install

// 作曲家.json:

1
2
3
4
5
{
   "require": {
       "mailgun/mailgun-php":"~1.5"
    }
}


composer 需要 mailgun/mailgun-php:~1.7.1

为我工作 - Windows、XAMPP。

找到你的 php.ini 并取消注释 extension=php_curl.dll.