devilbox/docs/PHP_Projects.md
2017-05-24 08:05:10 +02:00

2.6 KiB

Devilbox Documentation

Home | Overview | Configuration | Usage | Updating | Info | PHP Projects | Emails | Logs | Intranet | FAQ


PHP Projects

TL;DR

  1. Create folder ${HOST_PATH_HTTPD_DATADIR}/my-project/htdocs
  2. Set ${TLD_SUFFIX} in the .env file (example: loc)
  3. Expand docker host /etc/hosts with 127.0.0.1 my-project.loc or attach included DNS server to your host and stop worrying about DNS
  4. Browse http://my-project.loc

Adding projects

As an example, we are going to add two projects.

Prerequisites (dir)

For this case let's assume your www root folder points to ~/www. This means your projects will reside on your host computer in your home directory under www.

In order to achive this set HOST_PATH_HTTPD_DATADIR=~/www in the .env file (If this file does not yet exist, copy env-example to .env).

.env:

...
HOST_PATH_HTTPD_DATADIR=~/www
...

Prerequisites (domain suffix)

Let's also assume that you have chosen *.loc as you projects TLD_SUFFIX Domain

In order to achive this set TLD_SUFFIX=loc in the .env file (If this file does not yet exist, copy env-example to .env).

.env:

...
TLD_SUFFIX=loc
...

Desired Projects

Project name Document Root URL
devilbox ~/www/devilbox/htdocs http://devilbox.loc
foo.bar ~/www/foo.bar/htdocs http://foo.bar.loc

htdocs can either be a folder or a symlink to a folder.

Project: devilbox

Setup projects folder and an index.php (on your host computer)

$ mkdir -p ~/www/devilbox/htdocs
$ vim ~/devilbox/htdocs/index.php
<?php
echo 'hello world';
?>

Adjust your local (host computer) /etc/hosts and point devilbox.loc to your localhost address 127.0.0.1

$ sudo vim /etc/hosts
127.0.0.1 devilbox.loc

Project: foo.bar

Setup projects folder and use existing github project to serve.

$ mkdir -p ~/www/foo.bar
$ cd ~/www/foo.bar

# Use an existing github project as your document root
$ git clone https://github.com/<user>/<some-project>

# Symlink the project to htdocs
$ ln -s <some-project> htdocs

$ ls -l
drwxr-xr-x 4 cytopia 1286676289  136 Oct 30 14:24 <some-project>/
lrwxr-xr-x 1 cytopia 1286676289  549 Nov  6 15:13 htdocs -> <some-project>/

Adjust your local (host computer) /etc/hosts and point foo.bar.loc to your localhost address 127.0.0.1

$ sudo vim /etc/hosts
127.0.0.1 foo.bar.loc