简体   繁体   English

pecl install - 如何指定选项?

[英]pecl install - how to specify options?

I'm trying to install event extension for PHP using pecl.我正在尝试使用 pecl 为 PHP 安装event扩展。 During the installation I get several prompts:在安装过程中,我收到几个提示:

Enable internal debugging in Event [no] : 
Enable sockets support in Event [yes] : 
libevent installation prefix [/usr] : 
Include libevent's pthreads library and enable thread safety support in Event [no] : 
Include libevent protocol-specific functionality support including HTTP, DNS, and RPC [yes] : 
Include libevent OpenSSL support [yes] : 
PHP Namespace for all Event classes [no] : 
openssl installation prefix [no] : 

But ofc that only happens in the interactive mode.但是只有在交互模式下才会发生这种情况。 I need to do this without interaction, for instance in Dockerfile.我需要在没有交互的情况下执行此操作,例如在 Dockerfile 中。 The default values don't work for me so I need to change them with command line options.默认值对我不起作用,因此我需要使用命令行选项更改它们。 How?如何?

Keep in mind that I need to answer differently for each question so yes '' | pecl install ...请记住,我需要对每个问题做出不同的回答,所以yes '' | pecl install ... yes '' | pecl install ... doesn't work at all. yes '' | pecl install ...根本不起作用。 Also one of the questions needs a path and not yes/no.还有一个问题需要一条路径,而不是是/否。

Non-interactive mode for pecl is not yet available. pecl 的非交互模式尚不可用。 It can be supplemented with yes command.可以用yes命令补充。 Command outputs affirmatives until terminated.命令输出肯定的直到终止。

You may use yes with pipe like this: yes '' | pecl install ...您可以像这样对管道使用yesyes '' | pecl install ... yes '' | pecl install ...

Edit: If you are not in need output yes every iteration, just echo your answers like echo 'yes\n no\n ...' | pecl install ...编辑:如果您不需要每次迭代都输出 yes,只需回显您的答案,例如echo 'yes\n no\n ...' | pecl install ... echo 'yes\n no\n ...' | pecl install ...

More edit: If you are using this solution in docker, in Dockerfile you may use command docker-php-ext-install event and then docker-php-ext-configure ...更多编辑:如果您在 docker 中使用此解决方案,则在 Dockerfile 中您可以使用命令 docker docker-php-ext-install event ,然后使用 docker docker-php-ext-configure ...

I'm using PHP workerman these days and also meet this problem when install event extension in Docker.这些天我正在使用 PHP workerman ,并且在 Docker 中安装event扩展时也遇到了这个问题。 Following workerman's documents, event should be configured as:按照工人的文件, event应配置为:

  • do NOT include libevent OpenSSL support不包括 libevent OpenSSL 支持
  • ENABLE PHP Namespace for all Event classes为所有事件类启用 PHP 命名空间

which means one should type no for interactive question Include libevent OpenSSL support [yes] : and yes for Include libevent OpenSSL support [yes] : , while just leave enter for other questions.这意味着对于交互式问题应该输入no包括 libevent OpenSSL support [ yes Include libevent OpenSSL support [yes] :并且对于Include libevent OpenSSL support [yes] :输入 yes ,而对于其他问题只需要enter

You may try THIS solution (and also put RUN in the head in Dockerfile ):您可以尝试这个解决方案(也可以在Dockerfile RUN放在首位):

printf "\n\n\n\n\nno\nyes\n\n" | pecl install event

echo '\n\n\n\n\nno\nyes\n\n' do NOT work since it seems not be used as interactive answers, which sends whole string as the configuration parameter value, and you may see this: echo '\n\n\n\n\nno\nyes\n\n'不起作用,因为它似乎没有用作交互式答案,它将整个字符串作为配置参数值发送,您可能会看到:

running: /tmp/pear/temp/event/configure --with-php-config=/usr/bin/php-config --enable-event-debug=\n\n\n\n\nno\nyes\n\n ...

It's now possible to pass configuration options to pecl install via --configureoptions .现在可以通过--configureoptions将配置选项传递给pecl install

You'll want to find your package's package.xml file to see what options are configurable.您需要找到您的包的 package.xml 文件以查看哪些选项是可配置的。 For the event package, you'll go here:对于event套餐,您将前往此处:

https://bitbucket.org/osmanov/pecl-event/src/master/package.xml https://bitbucket.org/osmanov/pecl-event/src/master/package.xml

Search for the <configureoption> tags, which in this case are:搜索<configureoption>标记,在本例中为:

<configureoption default="no" name="enable-event-debug" prompt="Enable internal debugging in Event"/>
<configureoption default="yes" name="enable-event-sockets" prompt="Enable sockets support in Event"/>
<configureoption default="/usr" name="with-event-libevent-dir" prompt="libevent installation prefix"/>
<configureoption default="no" name="with-event-pthreads" prompt="Include libevent's pthreads library and enable thread safety support in Event"/>
<configureoption default="yes" name="with-event-extra" prompt="Include libevent protocol-specific functionality support including HTTP, DNS, and RPC"/>
<configureoption default="yes" name="with-event-openssl" prompt="Include libevent OpenSSL support"/>
<configureoption default="no" name="with-event-ns" prompt="PHP Namespace for all Event classes"/>
<configureoption default="yes" name="with-openssl-dir" prompt="openssl installation prefix"/>

You can then pass these options along to the install command like so:然后,您可以将这些选项传递给安装命令,如下所示:

pecl install --configureoptions 'enable-event-debug="no" with-event-libevent-dir="/my/dir" with-event-ns="yes"' event

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM