PhpUnit returns "could not find driver" exception

mysql
circle.yml
php7.1

#1

Hello guys, I’m trying to make CircleCI 2.0 build with Lumen/Laravel application on PHP 7.1 with MySQL as a testing database. I tried combination of these images for PHP and Mysql:

notnoopci/php:7.1.5-apache
notnoopci/mysql:5.7.18
circleci/php:7.1-apache-node
circleci/mysql:5.7.18

but I’m still getting an error while run vendor/bin/phpunit:

Illuminate\Database\QueryException: could not find driver.

I tried to run: sudo apt install -y php7.0-mysql and it returns: Unable to locate package php7.0-mysql. I also tried php-mysql, php7.1-mysql.

Anybody who can help PHP 7.1 + MySQL docker image with composer and php7.1-mysql driver included?

Thanks a lot!
Vojta


#2

I’m having the same issue. Mysqlnd is there but no pdo driver.

I’m going to try reverting to 1.0 to get this working. @vojtasvoboda let me know if you found a way to accomplish this in 2.0.


#3

There is my working solution:

version: 2

jobs:
  build:
    working_directory: ~/laravel
    docker:
      - image: notnoopci/php:7.1-apache-node
      - image: circleci/mysql:5.7
        environment:
          - MYSQL_USER=root
          - MYSQL_PASSWORD=
          - MYSQL_ALLOW_EMPTY_PASSWORD=true
          - MYSQL_DATABASE=circle_test
    steps:
      - run:
          name: Install PHP extensions
          command: sudo docker-php-ext-install pdo_mysql
      - run:
          name: Install Composer
          command: 'curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer'
      - run:
          name: Display versions
          command: |
            php -v
            composer --version
      - checkout
      - restore_cache:
          keys:
            - composer-v1-{{ checksum "composer.json" }}
            - composer-v1-
      - run:
          name: Install project dependencies
          command: composer install -n --prefer-dist
      - save_cache:
          key: composer-v1-{{ checksum "composer.json" }}
          paths:
            - vendor
      - run:
          name: Run PhpUnit
          command: ./vendor/bin/phpunit


#4

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.