[Resolved]Create database

Hi,

I use GitlabCI with my Symfony app. The database is not create. So my composer install command doesn’t work because the database is required.

This is my configuration :

phpunit:
  image: php:7.1
  services:
    - mysql:latest
  variables:
    WITH_XDEBUG: "1"
    MYSQL_ROOT_PASSWORD: password
    MYSQL_DATABASE: gitlab_test_db
    MYSQL_USER: runner
    MYSQL_PASSWORD: password
  before_script:
    - apt-get update -yqq
    - apt-get install -yqq git zip unzip
    - docker-php-ext-install pdo_mysql
    # Installation de Composer
    - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    - php composer-setup.php
    - php -r "unlink('composer-setup.php');"
    # Mise en place de la configuration
    - cp app/config/parameters.yml.dist app/config/parameters.yml
    # Installation des dépendances
    - php composer.phar install --prefer-source --no-interaction --ignore-platform-reqs # > Problem here because not db
    # Installation de la db de test
    - php bin/console doctrine:database:create -e test
    - php bin/console doctrine:schema:update -f -e test
    - php bin/console doctrine:fixtures:load --no-interaction -e test
  script:
    # Lancement des tests PHP
    - bin/phpunit -d memory_limit=-1 

How to create database ?

Regards,

Are you sure you are connecting to:

  • host: mysql
  • database: gitlab_test_db
  • user: runner
  • password: password

Where do you use this in your composer-setup.php? Or do they use the ENV variables?

What is the output of the job?

PS: Why run php -r "unlink('composer-setup.php');"" instead of rm composer-setup.php?

Ok, my problem is resolved ! My host was discorrect and I added in my config :

- php composer.phar dump-autoload

Thank you for your help !
Regards,