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
...
👋 While you are here

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay