Heroku PHPのドキュメントルートを環境変数から指定する

HerokuにてPHP環境を作成する際には、Procfileにて稼働するWebサーバの設定とドキュメントルートの設定を行う。
例：apacheを使ってドキュメントルートをhtdocsにする場合

```
web: vendor/bin/heroku-php-apache2 htdocs
```

このドキュメントルートの指定を環境変数から指定することが出来た。

# 環境変数から取得
Procfileの中で、`$`を使うと環境変数から取得することが可能。
例えば、`DOC_ROOT`という環境変数を指定した場合は、以下のようにすれば設定出来た。

```
web: vendor/bin/heroku-php-apache2 $DOC_ROOT
```

Heroku側の環境変数に設定しやる。

```
$ heroku config:set DOC_ROOT=htdocs
```

これでappごとに環境変数を変更してやるだけで環境変数の切り替えが出来た。

## ヘルプ
ちなみに、`vendor/bin/heroku-php-apache2 --help`のコマンドでヘルプが確認出来た。
コマンドから実行するにはherokuコマンドで実行してやる。

```
$ heroku run 'vendor/bin/heroku-php-apache2 --help'

Boots PHP-FPM together with Apache2 on Heroku and for local development.

Usage:
  heroku-php-apache2 [options] [<DOCUMENT_ROOT>]

Options:
   -C <httpd.inc.conf>     The path to the configuration file to include inside
                           the Apache2 VHost config (see option -c below). Will
                           be included inside the '<VirtualHost>' section just
                           after the '<Directory>' & 'ProxyPassMatch' directives.
                           Recommended approach when customizing Apache2's config
                           in most cases, unless you need to set fundamental
                           server level options.
                           [default: $COMPOSER_VENDOR_DIR/heroku/heroku-buildpack-php/conf/apache2/default_include.conf]
   -c <httpd.conf>         The path to the full VHost configuration file that is
                           included after Heroku's (or your local) Apache2 config
                           is loaded. Must contain a 'Listen ${PORT}' directive
                           and should have a '<VirtualHost>' and likely also a
                           '<Directory>' section (see option -C above).
                           [default: $COMPOSER_VENDOR_DIR/heroku/heroku-buildpack-php/conf/apache2/heroku.conf]
   -F <php-fpm.inc.conf>   The path to the configuration file to include at the
                           end of php-fpm.conf (see option -f below), in the
                           '[www]' pool section. Recommended approach when
                           customizing PHP-FPM's configuration in most cases,
                           unless you need to set global options.
   -f <php-fpm.conf>       The path to the full PHP-FPM configuration file.
                           [default: $COMPOSER_VENDOR_DIR/heroku/heroku-buildpack-php/conf/php/php-fpm.conf]
   -h, --help              Display this help screen and exit.
   -i <php.ini>            The path to the php.ini file to use.
                           [default: $COMPOSER_VENDOR_DIR/heroku/heroku-buildpack-php/conf/php/php.ini]
                           exist, it will be created. Wildcards are allowed, but
   -l <tailme.log>         Path to additional log file to tail to STDERR so its
                           contents appear in 'heroku logs'. If the file does not
                           Note: this option can be repeated multiple times.
                           must be quoted and must match already existing files.
   -p <PORT>               Port to listen on for HTTP traffic. If this argument
                           is not given, then the port number to use is read from
                           the $PORT environment variable, or a random port is
                           chosen if that variable does not exist.
   -v, --verbose           Be more verbose during startup.

 All file paths must be relative to '/app'.

 Any file name that ends in '.php' will be run through the PHP interpreter first.
 You may use this for templating although this is less useful than e.g. for Nginx
 where unlike in Apache2, you cannot reference environment variables in config
 files using a '${VARNAME}' syntax.

 If you would like to use the -C and -c or -F and -f options together, make sure
 you retain the appropriate include mechanisms (see default configs for details).
```

# 参考
* [Process Types and the Procfile | Heroku Dev Center](https://devcenter.heroku.com/articles/procfile)
* [Deploying PHP Apps on Heroku | Heroku Dev Center](https://devcenter.heroku.com/articles/deploying-php)
* [HTTP Routing | Heroku Dev Center](https://devcenter.heroku.com/articles/http-routing)
* [foreman で アプリケーションを動かす。 - Qiita](https://qiita.com/7kaji/items/6a59977d2ad85604e7fd)