- バックアップ一覧
- ソース を表示
- 勉強会/Maple組み方講座その1 は削除されています。
- 1 (2006-05-18 (木) 20:20:04)
- 2 (2006-05-18 (木) 20:31:35)
- 3 (2006-06-24 (土) 17:14:54)
- 4 (2006-10-03 (火) 20:34:51)
- 5 (2006-10-05 (木) 10:19:51)
- 6 (2007-02-01 (木) 03:26:44)
- 7 (2007-02-02 (金) 06:46:08)
- 8 (2007-02-02 (金) 09:05:16)
- 9 (2007-02-03 (土) 08:10:42)
- 10 (2007-02-24 (土) 21:03:11)
- 11 (2007-02-28 (水) 04:27:19)
- 12 (2007-02-28 (水) 21:43:48)
- 13 (2007-03-02 (金) 07:01:52)
- 14 (2007-03-02 (金) 13:56:15)
- 15 (2007-03-03 (土) 10:46:37)
- 16 (2007-03-05 (月) 02:49:20)
- 17 (2007-03-06 (火) 06:00:10)
- 18 (2007-03-11 (日) 14:36:52)
- 19 (2007-03-16 (金) 07:41:48)
- 20 (2007-03-19 (月) 14:01:29)
- 21 (2007-03-20 (火) 00:14:46)
- 22 (2007-03-21 (水) 06:34:52)
- 23 (2007-03-21 (水) 18:19:34)
- 24 (2007-03-22 (木) 13:30:44)
- 25 (2007-03-22 (木) 16:19:10)
- 26 (2007-03-22 (木) 23:35:27)
- 27 (2007-03-25 (日) 03:49:40)
- 28 (2007-03-26 (月) 07:31:03)
- 29 (2007-03-27 (火) 04:56:33)
- 30 (2007-03-27 (火) 17:48:56)
- 31 (2007-03-28 (水) 17:25:18)
- 32 (2007-03-29 (木) 14:51:08)
- 33 (2007-03-29 (木) 17:55:03)
- 34 (2007-03-30 (金) 00:04:48)
- 35 (2007-03-31 (土) 14:00:41)
- 36 (2007-04-08 (日) 14:56:54)
- 37 (2007-04-13 (金) 12:11:10)
- 38 (2007-04-16 (月) 20:21:19)
- 39 (2007-04-16 (月) 20:21:19)
- 40 (2007-04-22 (日) 15:53:39)
- 41 (2007-05-13 (日) 03:50:37)
- 42 (2007-05-19 (土) 04:43:39)
- 43 (2007-05-22 (火) 11:59:14)
- 44 (2007-09-21 (金) 03:42:08)
- 45 (2007-09-21 (金) 03:42:10)
- 46 (2007-09-21 (金) 11:52:40)
- 47 (2007-09-30 (日) 17:22:39)
勉強会/Maple組み方講座その1?
目次 †
Mapleの組み方講座 †
やりたいこと †
Maple(Ver.3.1.0)でログイン認証のシステムを組み込むにあたって、下記を理解できるようにしようと思う
- 第1回
- mapleでのコード作成方法を理解する
- コンポーネントの作り方と DI について理解する
- 第2回
- PEARのDBをコンポーネントとして追加してみる
- DAOによるアクセスをしてみる
mapleのインストール †
- 公式サイトから落としてきて解凍して置いたら終わり
- Maple公式: http://kunit.jp/maple/
- ちなみに、今回説明するMapleのバージョンは 3.1.0
- ただし、Smartyを使う前提なので、maple/smarty/ に最新のSmartyを入れておくこと!
ログインフォームを表示させる †
- htdocsとmodulesとtemplatesの下に、↓このようにファイルを配置する
maple_sample + htdocs | + login.php + webapp + modules | + everybody | + login | + default | + Default.class.php | + maple.ini + templates + everybody + login + default.html
※everybody以下は開発者が自由に作成できる
ファイル構成 †
- maple_sample/htdocs/login.php
- ユーザからアクセスされるphpファイル
- maple_sample/webapp/modules/everybody/login/default/Default.class.php
- Injectionされるメンバ変数の定義と、フレームワークから呼び出されるメソッドの定義
- maple_sample/webapp/modules/everybody/login/default/maple.ini
- Convert, DIContainer, Action, Viewの定義
- View以外はここではあまり意味ない。。
- Convert, DIContainer, Action, Viewの定義
- maple_sample/webapp/templates/everybody/login/default.html
- ログインフォームのテンプレ
- ポイントは↓このhiddenのvalueが「次のmodulesの実行クラスになる」ということ
<input type="hidden" name="action" value="everybody_login_login">
- messageとか$action.oContainerLogin.xxxxは次で説明する
- ポイントは↓このhiddenのvalueが「次のmodulesの実行クラスになる」ということ
- ログインフォームのテンプレ
※以下の説明では、maple_sample/webapp/までを省略して書くことにする
フロー †
- ユーザは、htdocs/login.php を実行する
- htdocs/login.php の↓によりmodulesの実行クラスが決定される
define('DEFAULT_ACTION', 'everybody_login_default');
- mapleフレームワークが実行を開始する
- mapleフレームワークが modules/everybody/login/default/maple.ini によってDIコンテナの作成等行うが、とりあえず今回ははしょる
- modules/everybody/login/default/Default.class.php の execute メソッドが実行される
- modules/.../default/maple.ini の[View]より、templates/everybody/login/default.html の出力をSmartyにより実行される
- 以上。
入力チェック †
- 上のフローから表示されたフォームに「メアド」と「パスワード」を入れて[登録]する
- ↓このhiddenにより次のアクションが決定される
<input type="hidden" name="action" value="everybody_login_login">
- このアクションで modules/everybody/login/login/Login.class.php が実行される
- Everybody_Login_Loginクラスは、executeメソッドでログイン判定をしているわけだが、
その前に modules/everybody/login/login/maple.ini に記してある内容を実行する
- maple.iniには下記のように記してある
[Convert] mail,passwd,persistence.trim = [Validate] mail.required = "1,ID(メールアドレス)を入力してください" mail.maxlength = "1,メールアドレスは60文字以内で入力してください,60" mail.mail = "0,メールアドレスを正しく入力してください" passwd.required = "1,パスワードを入力してください" passwd.maxlength = "0,パスワードは16文字以内で入力してください,16" persistence.range = "1,フラグが不正です,0,1" [DIContainer] filename = dicon.ini [InjectRequest] oContainerLogin = [Action] oContainerLogin = "ref:oContainerLogin" oLogicLogin = "ref:oLogicLogin" [View] success = "everybody/login/login.html" input = "everybody/login/default.html"
- Convert : 入力文字列の変換をかけられる
- Trim : 前後の空白を取り除く
- Tohira: 全半角カナを全角かなに変換する
- Tohalf: 全角英数字を半角英数字に変換する
- 詳しくはこちら参照→http://kunit.jp/maple/wiki/index.php?%A5%EA%A5%D5%A5%A1%A5%EC%A5%F3%A5%B9#c920be1a
- Validate: 入力チェックができる
- 第1引数 : その入力チェックでそれ以降のチェックを止めるかどうか (Boolean)
- 第2引数 : エラー文言 (String)
- 第3引数以降 : チェック オプション (入力チェック用メソッドの引数)
- 詳しくはこちら参照→http://kunit.jp/maple/wiki/index.php?%A5%EA%A5%D5%A5%A1%A5%EC%A5%F3%A5%B9#q14a3a8a
- DIContainer: 下でやります
- InjectRequest: 下でやります
- Action: DIContainerと関係あるので、またあとで。
- View: MVCのView (Actionクラスのexecuteでこの文字列を返す)
- success : 成功時のView
- input : Validateで失敗したときにのView
- 各フィルタクラスが呼ばれて実行される
- Convertの場合は、maple_sample/maple/core/ConverterManager.php
- Validateの場合は、maple_sample/maple/core/ValidateorManager.php
- Validateに失敗した場合は、inputというViewが実行される
- このときActionクラスは実行されない
リクエストデータのインジェクション †
- フォームの場合は、リクエストデータをもとに処理が発生する
このリクエストデータを格納するクラスを作成する- maple_sample/webapp/conponents/container/Login.class.php
- コンストラクタでNULLに初期化する <-必須
- getterを記述する
- maple_sample/webapp/conponents/container/Login.class.php
- そして、このクラスにインジェクトするのが maple.ini に記述した InjectRequest になる
[InjectRequest] oContainerLogin =
- ただ、これだけ書いてもダメで、dicon.ini にそのインスタンスに対するクラスを定義する必要がある
[oContainerLogin:sample.container.login]
- 上記例の場合、sample.container.loginクラスからoContainerLoginというインスタンスを作っている
- インジェクションするクラスは maple_sample/webapp/components/ 以下に設置する
- sample.container.loginクラスの場合は maple_sample/webapp/components/sample/container/Login.class.php と記述する必要がある
- インジェクションするクラスは maple_sample/webapp/components/ 以下に設置する
- これで、インスタンスは作ったが、Viewにリクエストデータを渡すにはActionに渡してやる必要がある
そこで、maple.ini で下記のように記述している[Action] oContainerLogin = "ref:oContainerLogin"
- これでActionのメンバ変数に↓このように記述しておくことで、ActionクラスとViewクラスに渡される
var $oContainerLogin;
- View (テンプレート)におけるアサインされた変数の利用方法
- {$action.oContainerLogin.mail} : Actionクラスに割り当てられているoContainerLoginインスタンスのmailメソッドを実行した返値を出力する
- {action->getFormatDate type="1"} : ActionクラスのgetFormatDateメソッドをパラメータ「array('type'=>1)」で実行した返値を出力する
- ↑こちらはexample1のpage2を参照
- {errorList->getMessages assign=messages} : maple_sample/maple/core/ErrorListクラスのgetMessagesメソッド。これでValidateのエラーリストが取れる
コンポーネントへのインジェクション †
- Actionクラスからコンポーネントのクラスを利用するには、dicon.iniとmaple.iniを使うことを
『リクエストデータのインジェクション』で理解した
- リクエストデータ以外のコンポーネント クラスを利用する場合も同様にdicon.iniとmaple.iniを使う
- dicon.iniより
[oDaoUser:sample.database.dao.user] [oLogicLogin:sample.logic.login] oDaoUser = "ref:oDaoUser"
- dicon.iniより
- sample.database.dao.userクラスのインスタンスがoDaoUser
- sample.logic.loginクラスのインスタンスがoLogicLogin
- oDaoUserのインスタンスをoLogicLoginのメンバ変数として利用するようにしている
- maple.iniより
[Action] oContainerLogin = "ref:oContainerLogin" oLogicLogin = "ref:oLogicLogin"
- oContainerLoginはリクエストデータをインジェクションしたインスタンス
- oLogicLoginはLoginロジックを含むクラスのインスタンス
- これでActionクラスのoLogicLoginメンバ変数からoLogicLoginのメソッドを実行できる
$bResult = $this->oLogicLogin->login($this->oContainerLogin);
- sample.logic.loginは、components/sample/logic/Login.class.php に記述されている
- ログイン判定を行う
- ユーザDAOのsetterメソッド
- ログイン判定をするときに、このsetterを使うため
- dicon.ini上で記述されている↓を実行するのに使用される(?:Actionはいらないのに?)
[oLogicLogin:sample.logic.login] oDaoUser = "ref:oDaoUser"
〆める †
- たぶんこれくらいで時間がなくなると思うので、一旦〆める
- 次回は、DAOによるデータの取得と設定についてやります
- 組み方の特徴としては。。
- Actionクラスは1画面につき1ディレクトリ
- maple.iniに Convert や Validate が書ける
- ActionクラスとComponentsを分けて管理できる
- Smartyを利用できる
- mapleを使う開発では、Actionクラスと各Componentsとの依存性は大分薄れている
あとは、各Component間で依存させないように工夫して実装していく必要があるように思う。- この辺りについては、またのちほど公開する
- mapleによるDIの種類は、デフォルトではセッター・インジェクションのみ
- DIContainer2フィルタを使えば、コンストラクタ・インジェクションとfactoryメソッドによる初期化にも対応している
勉強会あとがき †
- 竹村:
- 以前のMapleを私は知らないが、、以前に比べるとなにやら物凄い洗練されたものになっているらしい
- ValidateやConvertで日本語について取り扱っているところなど、日本人っぽい細かさを感じるところがあるようだ
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/culos-gratis.html >discounts order online culos gratis</a> <a href= http://www.dreipage.de/userdaten/79068443/html/el-telefono.html >el telefono no prescription online</a> <a href= http://www.dreipage.de/userdaten/79068443/html/horoscopo-chino-gratis.html >cheap buy horoscopo chino gratis</a> -- Best regards? 2007-02-01 (木) 03:26:31
- Check this:[url=http://www.dreipage.de/userdaten/79068443/html/culos-gratis.html]order culos gratis lowest price[/url] [url=http://www.dreipage.de/userdaten/79068443/html/el-telefono.html]order online culos gratis no prescription[/url] [url=http://www.dreipage.de/userdaten/79068443/html/horoscopo-chino-gratis.html]online horoscopo chino gratis discounts[/url] -- Best regards? 2007-02-01 (木) 03:26:44
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/culos-gratis.html >culos gratis lowest price order online</a> <a href= http://www.dreipage.de/userdaten/79068443/html/el-telefono.html >order culos gratis no prescription</a> <a href= http://www.dreipage.de/userdaten/79068443/html/horoscopo-chino-gratis.html >culos gratis online lowest price</a> -- Best regards? 2007-02-02 (金) 04:27:36
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/culos-gratis.html >culos gratis lowest price order online</a> <a href= http://www.dreipage.de/userdaten/79068443/html/el-telefono.html >order culos gratis no prescription</a> <a href= http://www.dreipage.de/userdaten/79068443/html/horoscopo-chino-gratis.html >culos gratis online lowest price</a> -- Best regards? 2007-02-02 (金) 04:27:46
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/culos-gratis.html >culos gratis lowest price order online</a> <a href= http://www.dreipage.de/userdaten/79068443/html/el-telefono.html >order culos gratis no prescription</a> <a href= http://www.dreipage.de/userdaten/79068443/html/horoscopo-chino-gratis.html >culos gratis online lowest price</a> -- Best regards? 2007-02-02 (金) 04:28:03
- Check this:[url=http://www.dreipage.de/userdaten/79068443/html/culos-gratis.html]culos gratis buy online no prescription[/url] [url=http://www.dreipage.de/userdaten/79068443/html/el-telefono.html]order el telefono cheap[/url] [url=http://www.dreipage.de/userdaten/79068443/html/horoscopo-chino-gratis.html]buy online culos gratis cheap[/url] -- Best regards? 2007-02-02 (金) 04:28:21
- Check this:[url=http://www.dreipage.de/userdaten/79068443/html/culos-gratis.html]culos gratis buy online no prescription[/url] [url=http://www.dreipage.de/userdaten/79068443/html/el-telefono.html]order el telefono cheap[/url] [url=http://www.dreipage.de/userdaten/79068443/html/horoscopo-chino-gratis.html]buy online culos gratis cheap[/url] -- Best regards? 2007-02-02 (金) 04:28:30
- Check this:[url=http://www.dreipage.de/userdaten/79068443/html/culos-gratis.html]culos gratis buy online no prescription[/url] [url=http://www.dreipage.de/userdaten/79068443/html/el-telefono.html]order el telefono cheap[/url] [url=http://www.dreipage.de/userdaten/79068443/html/horoscopo-chino-gratis.html]buy online culos gratis cheap[/url] -- Best regards? 2007-02-02 (金) 04:28:41
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/mujeres-desnudas-gratis.html >lowest price el telefono online</a> <a href= http://www.dreipage.de/userdaten/79068443/html/musica-gratis-stratovarius.html >culos gratis lowest price buy online</a> -- Best regards? 2007-02-02 (金) 06:45:04
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/mujeres-desnudas-gratis.html >lowest price el telefono online</a> <a href= http://www.dreipage.de/userdaten/79068443/html/musica-gratis-stratovarius.html >culos gratis lowest price buy online</a> -- Best regards? 2007-02-02 (金) 06:45:10
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/mujeres-desnudas-gratis.html >lowest price el telefono online</a> <a href= http://www.dreipage.de/userdaten/79068443/html/musica-gratis-stratovarius.html >culos gratis lowest price buy online</a> -- Best regards? 2007-02-02 (金) 06:45:34
- Check this:[url=http://www.dreipage.de/userdaten/79068443/html/mujeres-desnudas-gratis.html]no prescription buy online mujeres desnudas gratis[/url] [url=http://www.dreipage.de/userdaten/79068443/html/musica-gratis-stratovarius.html]online cheap culos gratis[/url] -- Best regards? 2007-02-02 (金) 06:45:43
- Check this:[url=http://www.dreipage.de/userdaten/79068443/html/mujeres-desnudas-gratis.html]no prescription buy online mujeres desnudas gratis[/url] [url=http://www.dreipage.de/userdaten/79068443/html/musica-gratis-stratovarius.html]online cheap culos gratis[/url] -- Best regards? 2007-02-02 (金) 06:46:07
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/mujeres-desnudas-gratis.html >culos gratis no prescription buy online</a> <a href= http://www.dreipage.de/userdaten/79068443/html/musica-gratis-stratovarius.html >musica gratis stratovarius discounts online</a> -- Best regards? 2007-02-02 (金) 09:04:38
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/mujeres-desnudas-gratis.html >culos gratis no prescription buy online</a> <a href= http://www.dreipage.de/userdaten/79068443/html/musica-gratis-stratovarius.html >musica gratis stratovarius discounts online</a> -- Best regards? 2007-02-02 (金) 09:05:03
- Check this:[url=http://www.dreipage.de/userdaten/79068443/html/mujeres-desnudas-gratis.html]culos gratis order discounts[/url] [url=http://www.dreipage.de/userdaten/79068443/html/musica-gratis-stratovarius.html]lowest price order online musica gratis stratovarius[/url] -- Best regards? 2007-02-02 (金) 09:05:15
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/office-xp-manuales-free-gratis.html >lowest price order gratis</a> <a href= http://www.dreipage.de/userdaten/79068443/html/sexo-gratis.html >mujeres desnudas gratis no prescription buy</a> -- Best regards? 2007-02-03 (土) 05:21:33
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/office-xp-manuales-free-gratis.html >lowest price order gratis</a> <a href= http://www.dreipage.de/userdaten/79068443/html/sexo-gratis.html >mujeres desnudas gratis no prescription buy</a> -- Best regards? 2007-02-03 (土) 05:21:43
- Check this:[url=http://www.dreipage.de/userdaten/79068443/html/office-xp-manuales-free-gratis.html]online mujeres desnudas gratis lowest price[/url] [url=http://www.dreipage.de/userdaten/79068443/html/sexo-gratis.html]discounts mujeres desnudas gratis buy online[/url] -- Best regards? 2007-02-03 (土) 05:21:52
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/office-xp-manuales-free-gratis.html >horoscopo chino gratis discounts buy online</a> <a href= http://www.dreipage.de/userdaten/79068443/html/sexo-gratis.html >online discounts el telefono</a> -- Best regards? 2007-02-03 (土) 08:09:41
- Check this:<a href= http://www.dreipage.de/userdaten/79068443/html/office-xp-manuales-free-gratis.html >horoscopo chino gratis discounts buy online</a> <a href= http://www.dreipage.de/userdaten/79068443/html/sexo-gratis.html >online discounts el telefono</a> -- Best regards? 2007-02-03 (土) 08:09:52
- Check this:[url=http://www.dreipage.de/userdaten/79068443/html/office-xp-manuales-free-gratis.html]online horoscopo chino gratis no prescription[/url] [url=http://www.dreipage.de/userdaten/79068443/html/sexo-gratis.html]discounts order online horoscopo chino gratis[/url] -- Best regards? 2007-02-03 (土) 08:10:41