Skip to content

Instantly share code, notes, and snippets.

@BonfaceKilz
Last active June 21, 2018 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BonfaceKilz/5e391f1d5bcdd0ca26f255f85ab0b51f to your computer and use it in GitHub Desktop.
Save BonfaceKilz/5e391f1d5bcdd0ca26f255f85ab0b51f to your computer and use it in GitHub Desktop.
Working with laravel 4.1 (which is no longer supported)

Introduction

I've setup a docker image to work with the laravel 4.1 project and all its dependencies. Working with depracated code can be a nuisance, especially if you run a rolling release distro. You might break stuff in you local machine when downgrading things. Needless to say, it's frustrating. This is a short guide on how to set up and run a docker instance that has everything you need to work on any laravel 4.1 project.

I'll try as much as possible to dockerize things since upgrading the project in a safe way is one of the future goals of this project.

My goal for this was to have a working stable environment that can be replicated anywhere on any machine that has docker installed.

For the initial setup, I've cloned laradock to the repository and set up the initial .env.

git clone https://github.com/Laradock/laradock.git
cd laradock
cp .env.example .env

Set your php version to 56 in the .env file. Also set the mariadb/ mysql version.

Building

Build the necessary images by running:

docker-compose up nginx mariadb phpmyadmin

Get into your docker workspace and install composer dependencies:

docker-composer exec workspace bash
composer install

There's also a simple bash script that get's your container's IP address and sets it in the app/config/database.php file. To run, cd into your laradock folder and run: bash init.sh. You can use the IP address that has been echoed to login into the phpmyadmin dashboard.

MYSQL setup

For now, I haven't found a clean way of automatically importing the db dump to the docker instance. For now, you have to enter your docker container and import the db manually(which will take some time. Here's how I've done it:

docker-compose exec mariadb bash
mysql -uroot -p

Once you are in the mysql prompt, simply do:

CREATE DATABASE familyPlanning;
USE familyPlanning;
SOURCE /docker-entrypoint-initdb.d/familyPlanning.sql

If I find a cleaner way of importing the DB, on start up I will update this file.

PHP Artisan commands

If you want to run PHP artisan commands, you can get into your workspace commands like this:

docker-compose exec workspace bash

Pitfalls to avoid

#2002 - php_network_getaddresses: getaddrinfo failed: Try again — The server is not responding (or the local server's socket is not correctly configured).

This was solved by setting:

PHP_FPM_INSTALL_MYSQLI=false

to

PHP_FPM_INSTALL_MYSQLI=true

and the running the following in your terminal: docker-compose build php-fpm


Symfony \ Component \ Debug \ Exception \ FatalErrorException

Call to undefined function gregoriantojd()

You can add line RUN docker-php-ext-install calendar in file php-fpm/Dockerfile-70 or php-fpm/Dockerfile and rebuild php-fpm

To switch php versions, change the PHP_VERSION parameter in the .env file then run docker-compose build php-fpm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment