2016年2月3日水曜日

遅まきのHerokuデビューを無料枠でしたよ。phpinfo()を作ってデプロイ編

このエントリーをはてなブックマークに追加
チュートリアルは分かったので、今度はスクラッチで作成して公開するまでの手順を確認しておこう。

まずは適当なディレクトリを作る。そしてそのディレクトリの下に移動。

$ mkdir phpinfo
$ cd phpinfo/

index.phpとcomposer.jsonを作る。composer.jsonは空に近い状態でいい。

phpinfo();
{
    "require": {
    }
}
このままcomposer updateを実行する。

$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
そうするとvenderディレクトリが作成されているので、ここでgit initする。

$ git init
Initialized empty Git repository in /Users/hogahoga/Documents/HerokuProject/phpinfo/.git/
全てのファイルをaddし、ローカルリポジトリにコミットする。
$ git add *
$ git commit -m "Initial Commit"
[master (root-commit) 3852af9] Initial Commit
 Committer: Taro Yamada 
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 10 files changed, 520 insertions(+)
 create mode 100644 composer.json
 create mode 100644 index.php
 create mode 100644 vendor/autoload.php
 create mode 100644 vendor/composer/ClassLoader.php
 create mode 100644 vendor/composer/LICENSE
 create mode 100644 vendor/composer/autoload_classmap.php
 create mode 100644 vendor/composer/autoload_namespaces.php
 create mode 100644 vendor/composer/autoload_psr4.php
 create mode 100644 vendor/composer/autoload_real.php
 create mode 100644 vendor/composer/installed.json
ここでHerokuにログインする。
$ heroku login
Enter your Heroku credentials.
Email: Taro.Yamada@hogehoge.com
Password (typing will be hidden):
Logged in as Taro.Yamada@hogehoge.com
Heroku上にアプリを作成し、ローカルリポジトリにコミットしたファイルをHerokuにプッシュする。
$ heroku create
Creating app... done, stack is cedar-14
https://mysterious-depths-86346.herokuapp.com/ | https://git.heroku.com/mysterious-depths-86346.git
$ git push heroku master
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (14/14), 4.72 KiB | 0 bytes/s, done.
Total 14 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> PHP app detected
remote: -----> Bootstrapping...
remote: -----> Installing system packages...
remote:        NOTICE: No runtime required in composer.lock; using PHP ^5.5.17
remote:        - php (5.6.17)
remote:        - Apache (2.4.16)
remote:        - Nginx (1.8.0)
remote: -----> Enabling PHP extensions...
remote:        - ext-zend-opcache (automatic)
remote: -----> Installing dependencies...
remote:        Composer version 1.0.0-alpha11 2015-11-14 16:21:07
remote:
remote:  !     WARNING: Your Composer vendor dir is part of your Git repository.
remote:        This directory should not be under version control; only your
remote:        'composer.json' and 'composer.lock' files should be added, which
remote:        will let Composer handle installation of dependencies on deploy.
remote:        To suppress this notice, first remove the folder from your index
remote:        by running 'git rm --cached vendor/'.
remote:        Next, edit your project's '.gitignore' file and add the folder
remote:        '/vendor/' to the list.
remote:        For more info, refer to the Composer FAQ: http://bit.ly/1rlCSZU
remote:
remote:        Loading composer repositories with package information
remote:        Installing dependencies
remote:        Nothing to install or update
remote:        Generating optimized autoload files
remote: -----> Preparing runtime environment...
remote:        NOTICE: No Procfile, using 'web: vendor/bin/heroku-php-apache2'.
remote: -----> Checking for additional extensions to install...
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 73.9M
remote: -----> Launching...
remote:        Released v3
remote:        https://mysterious-depths-86346.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy.... done.
To https://git.heroku.com/mysterious-depths-86346.git
 * [new branch]      master -> master
ブラウザで確認する。
$ heroku open
Opening mysterious-depths-86346... done

よしよし、コツが分かったぞ。

0 件のコメント:

コメントを投稿