5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Windows環境下でのComposerの導入

Last updated at Posted at 2014-04-03

1,phpの導入

◇XAMPPの導入

http://www.appachefriends.org/douwnload.html
->win環境下では、C:\XAMPP\php\php.exeとしてインストールされるので¥、コマンドプロンプト上でアクセスする場合は、Userディレクトリ以下でアクセスする。
ちなみに、XAMPPをインストールした際に、XAMPPのコントロールパネル「XAMPP Control Panel」を使い、ダッシュボード上のShellを起動すると、\Xamppディレクトリにすでにある状態でコマンドプロンプトを動かすことができる。

◇php.iniの編集
ファイルを検索でphp.iniを検索→エディタでphp.iniを開く。

date.timezone = Asia/Tokyo
mbstring.internal_encoding = UTF-8

を記入する。
(どこでもいいが、わかりやすく自分は一番下に記述しました)

◇環境変数PATHの追加
参考:http://github.com/uzulla/how_to_setting_path_on_windows

setxコマンドを使ってコマンドラインプロントから検出。

※仮想マシン以下での設定に関してはまた書く。

2,Composerの導入

Composerとは?
PHPのライブラリをインストールするためのツール。みたいな理解。

参考:http://getcomposer.org/

作業する、プロダクト作成に使うディレクトリのトップディレクトリで
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"

でcomposer.pharをインストールする。
これはcomposer経由でライブラリをインストールする際に必要なファイル。

◇定義ファイルcomposer.jsonを作成する。
ここにいろんなphpのライブラリ、フレームワークのversionの情報を書き込む。

ちなみに、Slim、Twig、illuminate/Eloquentを導入する際は

{
"require":{
"slim/slim":"2.",
"slim/views":"0.1.
",
"slim/extras":"2.0.",
"twig/twig":"1.
",
"illuminate/database":"4.0.",
"Respect/Validation":"0.5.
"
},
"autoload":{
"psr-0":{"":"lib/"}
}
}

と書きました。

この後
php composer.phar update
と入力すると、入力したフレームワーク、テンプレートエンジンがプロダクトのディレクトリに入ります。
vendorというディレクトリができます。

これでComposerを導入し、phpのライブラリを入れる仕組みは一通り完成。
のはず。。。(笑)

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?