Giter Club home page Giter Club logo

laravel-bitnami-emp's Introduction

Laravel Bitnami EMP

A bare-bones laravel install using the Bitnami EMP docker config.

Quickstart

In the project root, start everything with docker-compose up -d. This will start the containers in 'daemon' mode so it doesn't clutter up your terminal with log output.

Run the following commands to install dependencies, set up your .env file properly, set app key etc, and create the database tables and seed data

bin/composer install
cp -n .env.example .env
bin/artisan key:generate
bin/artisan migrate --seed

The running application will be available at http://localhost:3080/ (you can change this port in docker-compose.yml)

docker-compose.yml

Uses a simple three-container approach for serving the laravel app:

  • MariaDB (a MySQL compatible DB) with a local volume for data persistence
  • Nginx with a customizable vhost config file, which reverse-proxies php requests to PHP-FPM container
  • PHP-FPM running PHP 7.1

Also includes utilities useful for development and debugging (more info below for each)

  • redis-commander, a web UI for Redis
  • mailcatcher a mock email server that you can send as many emails as you like, with a web interface to read them

To view logs, you can use docker-compose logs, read more about logging here: https://docs.docker.com/compose/reference/logs/

docker/ folder

  • Contains a data directory that the MariaDB container will use for persisting its data.
  • Has a customizable nginx-vhost/laravel.nginx file, which listens on all interfaces at port 8080 and serves the laravel app.
    • the location / section will first try loading a file directly, which will work for any static files (css, js, etc)
    • if it doesn't match, then it passes along the request to index.php
    • the next location ~ \.php$ section handles an incoming php request (such as when the previous section doesn't find a matching file)
    • this passes along the request to the php-fpm container, which has a pool listening on port 9000

bin/ folder

Working within the containers can be tedious, always having to type docker-compose exec... commands sucks.

To make this easier, there are helper scripts in the bin/ folder that pass through whatever args you give, and execute the commands within the docker containers.

  • composer: runs php composer commands (eg. bin/composer install, bin/composer update etc)
  • artisan: runs the laravel artisan command (eg. bin/artisan migrate)
  • phpunit: runs PHPUnit tests (eg. bin/phpunit will run the default test suite)

Laravel

.env.example

The example .env file has been configured to connect to mariadb based on the values in docker-compose.yml

Redis

To support redis for cache/sessions etc, the composer predis/predis package has been installed.

Index length fixes

In order to support older versions of MariaDB, this is added to the AppServiceProvider::boot() method:

// fix issues with utf8mb4 and older versions of mariadb
Schema::defaultStringLength(191);

More info here in the Laravel documentation, under the "Index Lengths & MySQL / MariaDB" section: https://laravel.com/docs/5.5/migrations#creating-indexes

Sending Emails

An example of how to create a Mailable class, view and Unit test is included:

  • app/Mail/HelloWorld.php demonstrates a Mailable class
  • resources/views/email/hello-world.blade.php shows how to write an email template consuming data from the Mailable class
  • tests/Unit/MailTest.php shows a PHPUnit test that sends a test email and asserts no errors.

Redis and Redis-Commander

Redis is a really fast in-memory key/value store that is perfect for caching and storing user sessions. Laravel supports it really well out of the box.

Looking at the data can be useful but is hard without a GUI client, so a simple web GUI, redis-commander is included.

Mailcatcher

Debugging email can be a pain, so mailcatcher is included as well. This provides a simple SMTP server that will intercept emails sent to any address from Laravel, and store them for display in a nice web UI.

  • Access the mailcatcher web UI at http://localhost:1081 to view the emails
  • You can also test emailing from your host, by setting up an "SMTP server" using host: localhost, port: 1025

laravel-bitnami-emp's People

Contributors

chrispappas avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.