PhpStormとGrunt.jsで作るCakePHP快適開発環境

33
PhpStormとGrunt.jsで作る CakePHP快適開発環境 第7回関西PHP勉強会 2013.7.17 13718日木曜日

description

第7回関西PHP勉強会

Transcript of PhpStormとGrunt.jsで作るCakePHP快適開発環境

Page 1: PhpStormとGrunt.jsで作るCakePHP快適開発環境

PhpStormとGrunt.jsで作るCakePHP快適開発環境

第7回関西PHP勉強会           2013.7.17               

13年7月18日木曜日

Page 2: PhpStormとGrunt.jsで作るCakePHP快適開発環境

自己紹介

• かみやん (Twitter@kamiyam)

• エンジニア

• Webサービスつくってます

http://nantokaworks.com

13年7月18日木曜日

Page 3: PhpStormとGrunt.jsで作るCakePHP快適開発環境

普段はNode.js の人です13年7月18日木曜日

Page 4: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Grunt.js?

13年7月18日木曜日

Page 5: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Grunt.js

JavaScript(Node.js)製タスクランナー

13年7月18日木曜日

Page 6: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Grunt.js

JavaScript(Node.js)製タスクランナー

13年7月18日木曜日

Page 7: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Grunt.js

JavaScript(Node.js)製タスクランナー

え?Node???

13年7月18日木曜日

Page 8: PhpStormとGrunt.jsで作るCakePHP快適開発環境

インストール

$ npm install -g grunt-cli

※ gruntコマンドが利用可能となる。

13年7月18日木曜日

Page 9: PhpStormとGrunt.jsで作るCakePHP快適開発環境

環境構築

$ vim Gruntfile.js (Grunt.coffee)

13年7月18日木曜日

Page 10: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Gruntfile.js 設定例module.exports = function(grunt) {

grunt.initConfig({ xxxxxx: { //......... } }); grunt.loadNpmTasks('grunt-contrib-xxxxxx'); grunt.registerTask('default', ['xxxxxx']);};

13年7月18日木曜日

Page 11: PhpStormとGrunt.jsで作るCakePHP快適開発環境

積み上がるタスク• CoffeeScriptのコンパイル

• Sassのコンパイル

• CSSファイルのコードミニファイ化・結合

• 画像ファイルの圧縮

• 画面の表示確認

13年7月18日木曜日

Page 12: PhpStormとGrunt.jsで作るCakePHP快適開発環境

gruntのメリット

grunt内でタスクとしてファイルを監視してリロードかけたり、コマンドの実行を割り当てられ

13年7月18日木曜日

Page 13: PhpStormとGrunt.jsで作るCakePHP快適開発環境

gruntのメリット

grunt内でタスクとしてファイルを監視してリロードかけたり、コマンドの実行を割り当てられ

え?フロントエンドの話?

13年7月18日木曜日

Page 14: PhpStormとGrunt.jsで作るCakePHP快適開発環境

gruntでできること(例)

• スタンドアロンでサーバ起動 (Node:V8)

• テストを実行する

• FTPでファイルアップロード

• rsync などのコマンドを実行

13年7月18日木曜日

Page 15: PhpStormとGrunt.jsで作るCakePHP快適開発環境

gruntでできること(例)• grunt server

• grunt test

• grunt ftp

• grunt rsync

• etc...

13年7月18日木曜日

Page 16: PhpStormとGrunt.jsで作るCakePHP快適開発環境

gruntでできること(例)• grunt server

• grunt test

• grunt ftp

• grunt rsync

• etc...

実行するタスクを自由に定義出来る

13年7月18日木曜日

Page 17: PhpStormとGrunt.jsで作るCakePHP快適開発環境

GruntでCakePHP

• css/js/html(ctp)/phpの監視/リロード

• php -S ... (php5.4<)

• テスト(PHPUnit)実行

13年7月18日木曜日

Page 18: PhpStormとGrunt.jsで作るCakePHP快適開発環境

PHP でサーバ起動

$ php -S localhost:3000 -c /usr/local/etc/php/5.4/php.ini-t app/webroot

13年7月18日木曜日

Page 19: PhpStormとGrunt.jsで作るCakePHP快適開発環境

PHP でサーバ起動• -S

<addr>:<port> Run with built-in web server.

• -c<path>|<file> Look for php.ini file in this directory

• -t<docroot> Specify document root <docroot> for built-in web server.

13年7月18日木曜日

Page 20: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Grunt 実行

$ grunt [server]

※ Gruntfile.js(Gruntfile.coffee)と同階層ディレクトリで実行

13年7月18日木曜日

Page 21: PhpStormとGrunt.jsで作るCakePHP快適開発環境

リバースプロキシ

PHPのスタンドアロンサーバだけではなくApache・nginxでも可能

13年7月18日木曜日

Page 22: PhpStormとGrunt.jsで作るCakePHP快適開発環境

リバースプロキシ

13年7月18日木曜日

Page 23: PhpStormとGrunt.jsで作るCakePHP快適開発環境

PhpStormでGrunt

• Run Command...

• grunt/node などのPATHを通す

• External Tool 設定

13年7月18日木曜日

Page 24: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Php Storm $PATH設定

$ vim /Applications/Phpstorm.app/Contents/Info.plist

$ vim /Applications/Webstorm.app/Contents/Info.plist

PhpStorm

WebStorm

13年7月18日木曜日

Page 25: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Php Storm $PATH設定

<key>LSEnvironment</key><dict> <key>PATH</key> <string>[Your Path Value]</string></dict>

13年7月18日木曜日

Page 26: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Php Storm $PATH設定

$ /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/PhpStorm.app

Via. http://ify.io/getting-webstorm-external-tools-to-work-on-webstorm-on-osx/

13年7月18日木曜日

Page 27: PhpStormとGrunt.jsで作るCakePHP快適開発環境

External Tool

13年7月18日木曜日

Page 28: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Alias C

13年7月18日木曜日

Page 29: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Arias C

• Composer

• Command Line Tool Support

13年7月18日木曜日

Page 30: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Arias C

PhpStorm から Composerを実行するのに「Arias c」を使う!

13年7月18日木曜日

Page 31: PhpStormとGrunt.jsで作るCakePHP快適開発環境

Command Line Tool Support

13年7月18日木曜日

Page 32: PhpStormとGrunt.jsで作るCakePHP快適開発環境

まとめ

• Grunt.jsはタスクツール

• Gruntからコマンドが実行可能

• サーバ起動・テスト・デプロイを手軽に

13年7月18日木曜日

Page 33: PhpStormとGrunt.jsで作るCakePHP快適開発環境

ご静聴ありがとうございました

13年7月18日木曜日