PHPから何年も離れていてcomposer
とか初めて使うぐらいです。
Laravel5.1体験ハンズオンセミナー!!に参加しつつ詰まったところメモなど。
composerコマンドの確認
composerはNode.jsでいうところのnpm的な存在って認識です。
$ which composer
/usr/local/bin/composer
ちゃんといるみたい。
$ composer
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 1.0-dev (15face5432d7b7334db6ac69fac0190971cafa6e) 2015-09-23 17:46:25
Usage:
command [options] [arguments]
Options:
--help (-h) Display this help message
--quiet (-q) Do not output any message
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
--no-interaction (-n) Do not ask any interactive question
--profile Display timing and memory usage information
--working-dir (-d) If specified, use the given directory as working directory.
Available commands:
about Short information about Composer
archive Create an archive of this composer package
browse Opens the package's repository URL or homepage in your browser.
clear-cache Clears composer's internal package cache.
clearcache Clears composer's internal package cache.
config Set config options
create-project Create new project from a package into given directory.
depends Shows which packages depend on the given package
diagnose Diagnoses the system to identify common errors.
dump-autoload Dumps the autoloader
dumpautoload Dumps the autoloader
global Allows running commands in the global composer dir ($COMPOSER_HOME).
help Displays help for a command
home Opens the package's repository URL or homepage in your browser.
info Show information about packages
init Creates a basic composer.json file in current directory.
install Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.
licenses Show information about licenses of dependencies
list Lists commands
remove Removes a package from the require or require-dev
require Adds required packages to your composer.json and installs them
run-script Run the scripts defined in composer.json.
search Search for packages
self-update Updates composer.phar to the latest version.
selfupdate Updates composer.phar to the latest version.
show Show information about packages
status Show a list of locally modified packages
suggests Show package suggestions
update Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file.
validate Validates a composer.json and composer.lock
まずはOKみたいです。
composerコマンドでプロジェクトを使う
$ composer create-project laravel-plus/laravel5-handson
これで依存関係解決しつつ利用するプロジェクトを落としてくるみたいです。
・
・
・
Token (hidden):
途中でtokenを聞かれます。
調べるとgithubのAPIトークンを取得する - Qiitaという記事がありました。
curl -u 'ユーザー名' -d '{"scopes":["repo"],"note":"Help example"}' https://api.github.com/authorizations
って感じでトークン取得できるみたいです。
別タブで作業を進めましょう。
私のgithubのユーザー名はn0bisuke
なので以下のようなコマンドを実行します。
$ curl -u 'n0bisuke' -d '{"scopes":["repo"],"note":"Help example"}' https://api.github.com/authorizations
途中でgithubのパスワード入力を求められますので入力しましょう。
Enter host password for user 'n0bisuke': 自分のパスワード入力
{
"id": 23072119,
"url": "https://api.github.com/authorizations/23072119",
"app": {
"name": "Help example",
"url": "https://developer.github.com/v3/oauth_authorizations/",
"client_id": "00000000000000000000"
},
"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"hashed_token": "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",
"token_last_eight": "zzzzzzzz",
"note": "Help example",
"note_url": null,
"created_at": "2015-10-10T04:45:32Z",
"updated_at": "2015-10-10T04:45:32Z",
"scopes": [
"repo"
],
"fingerprint": null
}
こんな感じでtokenのxxxxxxxxxxxxxxxxxxxxx
の部分をコピーして、先ほどのcomposer
コマンドでトークンを聞かれた部分で貼り付けましょう。すると続きでダウンロードが始まります。
・
・
・
(省略)
・
・
> php artisan vendor:publish
Publishing complete for tag []!
> php artisan database:upgrade
Up [framework/1.0] Run class App\Database\Migrations\Framework_1_0
laravel5-handson
というフォルダが出来ていると思います。
$ ls
laravel5-handson
$ cd laravel5-handson
$ ls
addons composer.json package.json readme.md test
app composer.lock phpspec.yml resources tests
artisan config phpunit.xml server.php vendor
bootstrap gulpfile.js public storage
こんな感じでDL出来ていればOKです。