Git Product home page Git Product logo

laravel-apache.dev's Introduction

laravel-apache.dev

Laravel + Apache + MySQL development environment with Docker and Docker Compose. Based on a dev.to Article and Laravel + Apache + Docker by veevidify.

Status

GitHub license

Contents:

Requirements

Usage

Up and Running

Clone the repo and create the folder structure for the laravel source code:

git clone https://github.com/rolodoom/laravel-apache.dev.git
cd laravel-apache.dev
mkdir -p src run/var

Copy .env.example to .env

cp .env.example .env

Build the images and start the services:

docker-compose build --no-cache
docker-compose up -d

Setup Laravel Project

Create Laravel Project:

./composer create-project laravel/laravel .

Modify Laravel src/.env file to match your container credentials:

APP_URL=http://localhost:<APP_PORT>

DB_HOST=mysql-db
DB_PORT=<MYSQL_PORT>
DB_DATABASE=laravel
DB_USERNAME=dbuser
DB_PASSWORD=secret

Initialize Laravel:

./composer install
./php-artisan key:generate
./php-artisan migrate
./php-artisan config:cache

NOTE: To regenrate DB use ./php-artisan migrate:fresh --seed

phpMyAdmin

You can also visit http://localhost:8088 to access phpMyAdmin after starting the containers.

The default username is root, and the password is the same as supplied in the .env file.

Helper Scripts

container

#!/bin/bash

docker exec -it laravel-app bash -c "sudo -u devuser /bin/bash"

Running ./container takes you inside the laravel-app container under user uid(1000) (same with host user)

db

#!/bin/bash

docker exec -it mysql-db bash -c "mysql -u dbuser -psecret laravel"

Running ./db will connect to your database container's daemon using mysql client.

composer

#!/bin/bash

args="$@"
command="composer $args"
echo "$command"
docker exec -it laravel-app bash -c "sudo -u devuser /bin/bash -c \"$command\""

Run any composer command, example:

$ ./composer dump-autoload

php-artisan

#!/bin/bash

args="$@"
command="php artisan $args"
echo "$command"
docker exec -it laravel-app bash -c "sudo -u devuser /bin/bash -c \"$command\""

Run any php artisan command, example:

$ ./php-artisan make:controller BlogPostController --resource

phpunit

#!/bin/bash

args="$@"
command="vendor/bin/phpunit $args"
echo "$command"
docker exec -it laravel-app bash -c "sudo -u devuser /bin/bash -c \"$command\""

Run ./vendor/bin/phpunit to execute tests, example:

$ ./phpunit --group=failing

Bugs and Issues

Have a bug or an issue with this template? Open a new issue here on GitHub.

License

This code in this repository is released under the MIT license, which means you can use it for any purpose, even for commercial projects. In other words, do what you want with it. The only requirement with the MIT License is that the license and copyright notice must be provided with the software.

laravel-apache.dev's People

Contributors

rolodoom avatar

Watchers

 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.