Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket Pipelines PHP Iconv Issue

adam
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 27, 2018

I'm running PHPUnit tests inside the Pipeline and one of the tests is using the iconv ext. to convert for example a german "ä" into "ae". Inside the Pipeline (based on PHP 7.2) this test return always a empty string.

My last try:

image: php:7.2-cli
pipelines:
default:
- step:
caches:
- composer
script:
- apt-get clean
- apt-get update -y
- apt-get install -y locales unzip zlib1g-dev libicu-dev
- printf 'en_US.UTF-8 UTF-8\n' >> /etc/locale.gen
- locale-gen
- dpkg-reconfigure --frontend noninteractive locales
- docker-php-ext-install bcmath
- docker-php-ext-enable bcmath
- docker-php-ext-install intl
- docker-php-ext-enable intl
- docker-php-ext-install mbstring
- docker-php-ext-enable mbstring
- docker-php-ext-install iconv
- docker-php-ext-enable iconv
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install
- vendor/bin/phpunit

 The test script:

echo iconv('UTF-8', 'ASCII//TRANSLIT', 'ÄäÖöÜü');

Expected: 'AaOoUu'
Actual: ''

1 answer

0 votes
Gabriel Dias
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 18, 2023

My problem was with phpunit and some env config. If I executed plain php it will work. To make my tests pass what finally worked was:

apt-get install locales

localedef -i en_US -f UTF-8 en_US.UTF-8

 

For anyone needing the full script to run a symfony project:

- echo "memory_limit = 512M" > $PHP_INI_DIR/conf.d/php-memory-limits.ini
- apt-get update && apt-get install -y libc-bin libonig-dev libfreetype-dev libjpeg62-turbo-dev libpng-dev default-mysql-client unzip libicu-dev locales
- docker-php-ext-configure gd --with-freetype --with-jpeg && docker-php-ext-install -j$(nproc) gd
- docker-php-ext-install pdo_mysql
- docker-php-ext-configure intl && docker-php-ext-install intl
- pecl install mailparse && docker-php-ext-enable mailparse
- localedef -i en_US -f UTF-8 en_US.UTF-8
# app config
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- cp app/config/parameters.yml.dist app/config/parameters.yml
- export SYMFONY_ENV=test
- composer require composer/package-versions-deprecated
- cp phpunit.xml.dist phpunit.xml
- vendor/bin/phpunit
- vendor/bin/phpstan analyse src
- echo "DONE!"

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events