sample-php-laravel icon indicating copy to clipboard operation
sample-php-laravel copied to clipboard

Extend this example to include a mysql container

Open tripper54 opened this issue 6 years ago • 4 comments

Hi there,

Thanks for putting this example together, it has been a great help!

It would be really cool if you could extend it to include a mysql container for the DB layer. I think an example that included a second mysql container would cover typical use cases a lot better.

Thanks!

tripper54 avatar Jun 06 '18 04:06 tripper54

Trying to figure out how to use a circleci MySQL container with this example. Can someone please push me in the right direction.

this is how my config.yml looks like:

version: 2
jobs:
  build:
    docker:
      - image: circleci/php:7.1-node-browsers
        environment:
          MYSQL_HOST: 127.0.0.1
          MYSQL_DB: testing
          MYSQL_USER: testing
          MYSQL_ALLOW_EMPTY_PASSWORD: true
          MYSQL_PASSWORD: testing

      - image: mysql:5.7
        environment:
            MYSQL_USER: testing
            MYSQL_ALLOW_EMPTY_PASSWORD: true

    working_directory: ~/laravel

    steps:
      - checkout
      - run: sudo apt install -y libsqlite3-dev zlib1g-dev
      - run: sudo docker-php-ext-install zip
      - run: composer install -n --prefer-dist
      # - run: composer install --dev --ignore-platform-reqs

      # prepare the database
      - run:
          name: Create Mysql Database
          command: mysql  -h 127.0.0.1 -u root -e "create database testing;"

the build breaks at last step

#!/bin/bash -eo pipefail
mysql  -h 127.0.0.1 -u root -e "create database testing;"
/bin/bash: mysql: command not found
Exited with code 127

ec-wagner avatar Sep 20 '18 12:09 ec-wagner

from here I found out that I have to add an mysql client to the primary container

- run: checkout
- run: sudo apt install -y mysql-client

But now I am running into another error

$ php artisan migrate

In Connection.php line 647:
  could not find driver (SQL: select * from information_schema.tables where table_schema = circle_test and table_name = migrations)  
                                                                                                                                     
In Connector.php line 68:
  could not find driver

Yes, please add and MyQSL example.

ec-wagner avatar Sep 20 '18 16:09 ec-wagner

@ec-wagner this should fix it

- run: sudo docker-php-ext-install zip pdo pdo_mysql

ridaamirini avatar Jan 06 '19 11:01 ridaamirini

@ec-wagner this should fix it

- run: sudo docker-php-ext-install zip pdo pdo_mysql

@ridaamirini Your comment helped me fix the same issue. Thank you

omitobi avatar May 02 '20 08:05 omitobi