自制软件:安装新公式php72-imagick [英] Homebrew: install new formula php72-imagick

查看:64
本文介绍了自制软件:安装新公式php72-imagick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在php 7.2上安装imagick模块

I need install imagick module on my php 7.2

我知道

brew search php72
==> Searching local taps...
==> Searching taps on GitHub...
==> Searching blacklisted, migrated and deleted formulae...
No formula found for "php72".
Closed pull requests:
...
php72-imagick 3.4.3 (new formula) (https://github.com/Homebrew/homebrew-php/pull/4267)

我该怎么办?

我还需要氩气支持

推荐答案

我认为一切都在2018年4月发生了变化. Homebrew 不再充当PHP的软件包管理器,因此所有php-imagickphp-redisphp-other-extension内容都已消失,现在您应该像所有人一样使用pecl管理PHP软件包.否则.

It all changed back in April 2018 I think. Homebrew no longer acts as the package manager for PHP, so all the php-imagick and php-redis and php-other-extension stuff has gone and you are now supposed to manage PHP packages using pecl like everyone else does.

那么,如何在PHP下获得Imagick?请注意, Imagick ImageMagick 是两个不同的东西:

So, how to get Imagick under PHP? Note that Imagick and ImageMagick are two different things:

  • ImageMagick是整个ImageMagick套件
  • Imagick是 just PHP绑定
  • ImageMagick is the entire ImageMagick suite
  • Imagick is just the PHP binding

以下是步骤-如果有人知道更好或任何改进,请通过评论让我知道,我会进行更新.

Here are the steps - if anyone knows better or any improvements, let me know via comment and I will update.

第1步-删除任何可能发生冲突的内容

开始之前,最好清理所有损坏或不需要的东西.尽可能多地执行以下操作:

Before starting, it is best to clean up all the stuff that is broken or unneeded. Do as many of these as you are comfortable with:

brew rm php php@5.6 php@7.0 php@7.1
brew rm imagemagick


第2步-更新Xcode命令行工具并获取构建包

请确保您已使用以下命令安装了Xcode命令行工具:

Make sure you have installed Xcode command-line tools with:

xcode-select --install

转到AppStore并单击更新并更新所有与Xcode相关的软件包-特别是如果您最近升级了macOS.

Go to AppStore and click on Updates and update any Xcode related packages - especially if you have recently upgraded macOS.

安装自制程序构建工具:

Install homebrew building tools:

brew install pkg-config


第3步-安装ImageMagick

检查所需的ImageMagick选项:

Check what ImageMagick options you want with:

brew options imagemagick

我喜欢使用:

brew install imagemagick --with-x11 --with-librsvg --with-openexr --with-pango
hash -r

但是您可能会喜欢香草安装:

but you may like vanilla install:

brew install imagemagick
hash -r


第4步-安装自制的PHP

下一步,使用以下命令安装PHP的自制软件版本:

Next, install the homebrew version of PHP with:

brew install php
hash -r                    # Update bash's internal paths

现在,严格确保您运行的是正确的自制软件 PHP:

Now, critically ensure you are running the correct homebrew PHP:

type php

如果这告诉您:

/usr/local/...anything.../php

您正在运行自制软件 PHP,可以继续执行下一步.

you are running homebrew PHP and you can go to the next step.

如果它告诉您:

/usr/bin/php

您正在运行Apple提供的PHP.如果那是您要运行的,请忽略我的完整答案,该答案是基于您要使用 homebrew PHP的.如果您得到此答案,但是想要运行 homebrew PHP,则您的PATH设置不正确.您需要将/usr/local/bin 放在 /usr/bin之前,以便在Apple程序(即

you are running the Apple-supplied PHP. If that is what you want to run, ignore my entire answer which is predicated on you wanting to use homebrew PHP. If you get this answer but want to run homebrew PHP, your PATH is set incorrectly. You need to put /usr/local/bin before /usr/bin to pick up all homebrew packages ahead of Apple programs, i.e.

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

此步骤还为您提供了pecl-PHP软件包管理器-因为它是自制软件 PHP的一部分.

This step gives you pecl - the PHP Package Manager - as well, since it is part of homebrew PHP.

第5步-安装Imagick

现在您可以使用pecl安装Imagick:

Now you can install Imagick with pecl:

pecl install imagick


如果有任何问题,这里有一些相关的问题和答案...


If anything goes wrong, here are some related questions and answers...

Q1.如何找到我的php.ini文件在哪里?

Q1. How can I find where my php.ini file is?

尝试以下任何命令:

pecl config-get php_ini                  # I get "/usr/local/etc/php/7.2/php.ini"
brew info php
php -i | grep "Loaded Configuration"     # I get "Loaded Configuration File => /usr/local/etc/php/7.2/php.ini"

Q2.如何找到pecl在何处安装模块?

Q2. How can I find where pecl installs modules?

pecl config-get ext_dir                 # I get "/usr/local/lib/php/pecl/20170718"

Q3.我怎么知道加载了哪些PHP模块?

php -m

Q4. PHP为什么找不到我的模块?

首先使用Q2找到您的模块目录.我喜欢将其放在剪贴板中:

First locate your modules directory using Q2. I like to put that in the clipboard with:

pecl config-get ext_dir | pbcopy

然后从Q1编辑php.ini文件.我使用vi,所以我会这样做:

Then edit the php.ini file from Q1. I use vi, so I would do:

vi "$(pecl config-get php_ini)"

然后在该文件中找到如下所示的行:

Then find the line in that file that looks like this:

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir

,然后(使用粘贴缓冲区的内容)使下面的行看起来像这样(开始时没有分号):

and, then (using the contents of your paste buffer) make the following line look like this (no semi-colon at the start):

extension_dir = "/usr/local/lib/php/pecl/XXXXXX"

我的机器上的

XXXXXX20170718.如果正确执行此操作,则通过pecl安装的所有模块对您的自制软件 PHP都是可见的.

on my machine XXXXXX is 20170718. If you get this right, any and all modules you install via pecl will be visible to your homebrew PHP.

Q5.如何查看我所有的PHP设置?

使用以下方法检查PHP配置,版本和设置:

Check PHP configuration, versions and settings with:

php -i

希望有帮助!

这篇关于自制软件:安装新公式php72-imagick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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