Compose Laravel
- Project website:
- laravel.com
- Github:
- https://github.com/dockerwest/compose-laravel
Getting started
Make sure you first followed the global getting started steps.
1. Clone the git repository next to your project folder.
$ git clone git@github.com:dockerwest/compose-laravel.git
2. Copy .env-sample to .env and update accordingly
Set the relative path to the folder where your project is located:
APPLICATION=../application
3. Start the project-specific environment
$ ./environment
4. Start the docker environment
$ run up
The helper command run
is an alias to docker-compose
, specific
for the current environment.
5. Access your project in the browser
This can be done in one of the following ways:
- Use Docker Developer DNS
This way you can access the environment by browsingapplication.docker
in your browser. - Use Nginx Proxy
This way you can access the environment by browsingapplication.docker
in your browser. - Add
ports
section to the nginx config in the docker-composer.yml file:nginx: ports: - "80:80"
This way you can access the environment by browsinglocalhost:80
in your browser.
What's in the box?
The following technologies are out-of-the-box available in this environment.
Click on one of the names for more information.
php-laravel image named
application
,
which mounts the APPLICATION
path to the image and links to mysql, redis and
mailcatcher.
You can access the php-cli using the php
helper. (see below)
The following packages are installed: php-gd php-mysql php-mcrypt php-sqlite3 php-bz2 php-xml php-mbstring php-zip php-redis php-imagick php-json php-bcmath php-intl
nginx-laravel image named
nginx
,
which mounts the APPLICATION
path to the image and links to application.
Please note that there is a different vhost between laravel 2 and laravel 3.
This nginx container is available at application.docker
and
www.application.docker
through
- VIRTUAL_HOST=${BASEHOST:-application.docker},www.${BASEHOST:-application.docker}
Redis image named redis
.
This redis container is available at redis.application.docker
through
- DOMAIN_NAME=redis.${BASEHOST:-application.docker}
Connection settings:
host: redis
Mysql image named mysql
.
The mysql root password is provided through the environment variable in the .env
file
through:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-toor}
This mysql container is available at mysql.application.docker
through
- DOMAIN_NAME=mysql.${BASEHOST:-application.docker}
You should first create a new database through the create_db
helper command (see below).
Connection settings:
host: mysql port: 3306 user: root password: toor (unless changed in .env file)
Mailcatcher container named
mailcatcher
.
This mailcatcher container is available at mailcatcher.application.docker:1080
through
- DOMAIN_NAME=mailcatcher.${BASEHOST:-application.docker}
SMTP settings for your application are:
host: mailcatcher port: 1025
Available helper commands
Click on one of the commands for more info and an example.
$ run up
Execute the php command inside the running php container, or inside a php-laravel container if none is running.
The working directory will be the current directory you are executing this command from.
eg.$ php -v
Run the composer command inside the php docker container. The working directory will be the current directory you are executing this command from.
Your $HOME/.ssh and $HOME/.composer folders wil be mounted inside this container to enable you to make use of your ssh keys and composer cache.
eg.$ composer require package_name
Create a new database inside the running mysql container with the given name (eg. 'laravel') and 'DEFAULT CHARSET utf8'.
eg.$ create_db laravel
Execute a mysql command inside the running mysql container as the root user.
eg.$ mysql "SELECT * FROM table_name;"
Execute the mysqldump command inside the running mysql container as the root user.
eg.$ mysqldump db_name > export_file_name.sql
Import a given mysql file into a given database, inside the running mysql container as the root user.
eg.$ mysqlimport db_name import_file_name.sql
Execute the nodejs command inside a nodejs container. The working directory will be the current directory you are executing this command from.
eg.$ node js_file.js
Execute the npm command inside a nodejs container.
The working directory will be the current directory you are executing this command from. Your $HOME/.ssh and $HOME/.npm folders wil be mounted inside this container to enable you to make use of your ssh keys and npm cache.
eg.$ npm install package_name
Execute the yarn command inside a nodejs container.
The working directory will be the current directory you are executing this command from. Your $HOME/.ssh and $HOME/.npm folders wil be mounted inside this container to enable you to make use of your ssh keys and npm cache.
eg.$ yarn add package_name