GithubHelp home page GithubHelp logo

Auto detect .ini dir about php-psr HOT 7 CLOSED

jbboehr avatar jbboehr commented on June 12, 2024
Auto detect .ini dir

from php-psr.

Comments (7)

sergeyklay avatar sergeyklay commented on June 12, 2024 2

To use with php-config and configure directive --with-config-file-scan-dir is set:

$ php-config --configure-options | \
    tr -s ' ' '\n' | \
    grep -e '--with-config-file-scan-dir' | \
    cut -f2 -d=

from php-psr.

sergeyklay avatar sergeyklay commented on June 12, 2024 1

I have an ugly approach:

PHP_CONFD=$(php --ini | \
    grep Additional | \
    awk -F'parsed:' '{print $2}' | \
    sed -r 's/,//g' | \
    tr -d '[:space:]')

from php-psr.

sergeyklay avatar sergeyklay commented on June 12, 2024 1

I think this may be closed

from php-psr.

jbboehr avatar jbboehr commented on June 12, 2024

@dragoonis That's a pretty distribution-dependent question, no?

You could try getting the value of Scan this dir for additional .ini files out of php -i.

$ php -i | grep ini
Configuration File (php.ini) Path => /nix/store/1ip3r4rr646w3a658snrk638yd4vk159-php-7.1.11/lib
Scan this dir for additional .ini files => /etc/php.d

from php-psr.

sergeyklay avatar sergeyklay commented on June 12, 2024

Or according to php_ini_scanned_files:

php -r "echo dirname(explode(',', php_ini_scanned_files())[0]);"

but there is a potential issue:

Returns a comma-separated string of .ini files on success. Each comma is followed by a newline. If the configure directive --with-config-file-scan-dir wasn't set and the PHP_INI_SCAN_DIR environment variable isn't set, FALSE is returned.

I can't realize why it returns a comma-separated string instead of array 🤦, but we can use this approach

from php-psr.

dragoonis avatar dragoonis commented on June 12, 2024

That doesn't work inside a bash script, so I've modified it to look like this:

VAL=$(
  echo `php-config --configure-options` | \
  tr -s ' ' '\n' | \
  grep -e '--with-config-file-scan-dir' \
  | cut -f2 -d=
)

echo "${VAL}"

from php-psr.

jbboehr avatar jbboehr commented on June 12, 2024

@sergeyklay Sounds good, thanks!

from php-psr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.