1

Is it possible to load a PHP module only in CLI. I am trying to enable pthreads in CLI only but it gets enabled in Apache as well and crashes the server. I am using Homebrew to install php7 and php7-pthreads. Apache Loads the modules from /usr/local/etc/php/7.0/ and everything inside /usr/local/etc/php/7.0/conf.d

I created a folder named CLI and moved the ext-pthreads.ini inside it but it didn't work.

2
  • You could completely separate the PHP install by downloading a ZIP from php.net and putting it somewhere else for use by your CLI. Commented Apr 30, 2016 at 19:02
  • @pgmann thank you but this will create further issues to keep php versions in sync. Commented May 1, 2016 at 19:04

1 Answer 1

1

You could use command line options for that:

php -d extension="[yourExtension]"

If you wrap it in a bash (or .bat) file you only have to specify it once.

Update

You could use something like (not tested):

#!/bin/sh

php -d extension="[yourExtension]" ./pathToYour/script.php


For an extended explanation, please see: Bash script to run php script

Sign up to request clarification or add additional context in comments.

3 Comments

can you please elaborate a little bit more. I know what php -d does but not fully sure how to wrap it in a bash file. Does this mean that I can put php -d extension=[yourExtension] in a file and point .bash_profile to it ?
Also: if my answer is helpful to you, feel free to upvote it.
Thank you for leading me to the right direction. I duplicated php.ini that was inside /usr/local/etc/php/7.0/ and renamed it to php-cli.ini and enabled pthreads there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.