简体   繁体   中英

pecl install - how to specify options?

I'm trying to install event extension for PHP using pecl. 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. 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 ... doesn't work at all. Also one of the questions needs a path and not yes/no.

Non-interactive mode for pecl is not yet available. It can be supplemented with yes command. Command outputs affirmatives until terminated.

You may use yes with pipe like this: yes '' | 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 ... 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 ...

I'm using PHP workerman these days and also meet this problem when install event extension in Docker. Following workerman's documents, event should be configured as:

  • do NOT include libevent OpenSSL support
  • ENABLE PHP Namespace for all Event classes

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.

You may try THIS solution (and also put RUN in the head in Dockerfile ):

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:

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 .

You'll want to find your package's package.xml file to see what options are configurable. For the event package, you'll go here:

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

Search for the <configureoption> tags, which in this case are:

<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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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