DEV Community

Cover image for Add a php.ini setting for gitlab-ci
Julian
Julian

Posted on

3 2

Add a php.ini setting for gitlab-ci

sometimes you need to change a php.ini setting on the fly in your gitlab-ci. this is quite easy.

simple run something like:

echo 'phar.readonly="0"' >> /etc/php/7.1/cli/conf.d/ci.ini

i used my debian stretch docker file, which uses the https://deb.sury.org/ repository for php. your directory structure may differ.

you can find out where php is loading its config files from by running:

php --ini

this prints a list similar to this:

$ php --ini
Configuration File (php.ini) Path: /etc/php/7.1/cli
Loaded Configuration File:         /etc/php/7.1/cli/php.ini
Scan for additional .ini files in: /etc/php/7.1/cli/conf.d
Additional .ini files parsed:      /etc/php/7.1/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.1/cli/conf.d/10-opcache.ini,
/etc/php/7.1/cli/conf.d/10-pdo.ini,
/etc/php/7.1/cli/conf.d/15-xml.ini,
/etc/php/7.1/cli/conf.d/20-apcu.ini,
/etc/php/7.1/cli/conf.d/20-apcu_bc.ini,
/etc/php/7.1/cli/conf.d/20-bcmath.ini,
/etc/php/7.1/cli/conf.d/20-bz2.ini,
/etc/php/7.1/cli/conf.d/20-calendar.ini,
/etc/php/7.1/cli/conf.d/20-ctype.ini,
...

in debian all files in the conf.d directory are included. so we only need to put it inside this directory. you can also append the config to the main file php.ini.

relevant part from the gitlab-ci.yml:

image: c33s/php:7.1
...
build:
  stage: build
  script:
    - composer install
    - php --ini
    - echo 'phar.readonly="0"' >> /etc/php/7.1/cli/conf.d/ci.ini
    - wget https://github.com/box-project/box2/releases/download/2.7.5/box-2.7.5.phar
    - php box-2.7.5.phar build
    - php satis.phar --version
...

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs