coroin/homeport

Laradock multi-project helpers

Installs: 2 569

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Language:Shell

1.2.1 2019-07-24 19:14 UTC

This package is auto-updated.

Last update: 2025-03-25 08:45:52 UTC


README

Homeport is a script (homeport) installed your project-root with shortcuts to streamline your workflow while interacting with laradock in a multi-project environment.

Prerequesites

Homeport requires Docker and Laradock.

Install laradock in the same root folder as your other projects.

It is recommended to use the ~/code folder

/home/USER/code/            /home/USER/code/
├── a-project               ├── a-project
├── b-project               ├── b-project
├──                         ├── laradock
├── z-project               ├── z-project

Run this to create the ~/code folder (if it doesn't already exist) and install laradock:

mkdir -p ~/code && cd ~/code
git clone https://github.com/Laradock/laradock.git
cd laradock

Copy the env-example to .env and enable packages:

cp env-example .env
perl -i -pe's/PHP_FPM_INSTALL_IMAP=false/PHP_FPM_INSTALL_IMAP=true/' .env
perl -i -pe's/WORKSPACE_INSTALL_IMAP=false/WORKSPACE_INSTALL_IMAP=true/' .env
perl -i -pe's/WORKSPACE_INSTALL_PYTHON=false/WORKSPACE_INSTALL_PYTHON=true/' .env

Installation (only required for a new project)

Install Homeport in your project:

composer require coroin/homeport
php artisan vendor:publish --provider="Homeport\HomeportServiceProvider"
chmod +x homeport

Review the homeport script and customize for your project, if needed:

## Homeport Configuration

# 1. set path to laradock files
LARADOCK="${HOME}/code/laradock"        # note: must use ${HOME} instead of ~

# 2. set project name
PROJECT="${PWD##*/}"                        # defaults to current folder

# 3. specify database config
DATABASE_NAME="${PROJECT}"                  # defaults to project-name
DATABASE_PASS=root                          # DO NOT CHANGE (laradock default)
DATABASE_TYPE=mariadb                       # [mysql, mariadb]

# 4. select containers to run
CONTAINERS="nginx ${DATABASE_TYPE} redis"   # default uses nginx, database and redis

Initial Setup (required one time per project)

Add entry to your hosts file:

It is recommended to use the .test top-level-domain for your localdev

127.0.0.1   yourproject.test

On Mac/*NIX this file is located at /etc/hosts. On Windows, it is C:\Windows\system32\drivers\etc\hosts

Create the database and nginx config file:

./homeport setup

Note: If this is the first time you have run this command, it may take some time to download and build the docker images.

Usage

Any command not defined in the homeport script will default to being passed to the docker-compose command.

If no command is used, it will run docker-compose ps to list the running containers used by laradock.

Starting and Stopping Laradock

# start laradock
./homeport up

# stop laradock
./homeport down

# restart laradock
./homeport restart  # same as running ./homeport down && ./homeport up

Artisan, Composer, and NPM

# run artisan commands
./homeport artisan <command>
./homeport art <command> # "art" is a shortcut to "artisan"

# run composer commands
./homeport composer <command>
./homeport comp <command> # "comp" is a shortcut to "composer"

# run npm commands
./homeport npm <command>

MySql and Redis

# access the database
./homeport sql

# access the redis cli
./homeport redis

PHPUnit and Debugging

# run phpunit tests
./homeport test <arguments>
./homeport t <arguments> # "t" is a shortcut to "test"

# tail the laravel log
./homeport tail
./homeport log <command> # "log" is an alias to "tail"
./homeport log -f # follow
./homeport log -n 10 # show 10 lines of the log

Rebuilding or Repairing Laradock

After an update to Laradock or making changes to the .env file, rebuild the docker images:

# start laradock
./homeport rebuild
./homeport repair # "repair" is an alias of rebuild

Upgrading Homeport

Run the following command each time composer update gives you a new version of homeport

# upgrade homeport
./homeport update
./homeport upgrade # "upgrade" is an alias of update

Learning Docker

If you're unfamiliar with Docker, check out Chris Fidao's awesome Docker in Development and Shipping Docker courses at serversforhackers.com.

Contributing

  1. Fork this repo
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request