SlideShare une entreprise Scribd logo
1  sur  12
フレームワーク Ethna Ethnaの紹介 株式会社 CyberX エンジニア 石川泰式
目次 Ethnaとは Ethnaの動作イメージ Ethnaのディレクトリ構成 Ethnaの簡単なプログラム Actionの記述例 ActionFormの記述例 ActionClassの記述例 AppManagerとAppObjectの記述例 テンプレートの記述例 まとめ Ethnaの参考資料
Ethnaとは EthnaとはPHPフレームワークの一つ 読み方は「えすな」 Ethnaは、PHPを利用したウェブアプリケーションフレームワークで似たようなコードを書かなくてよいことを目標に作成しています。(本文まま) 最新の安定版は 2.5.0 (PHP 5.3非対応) 開発版は 2.6.0 beta2 (PHP 5.3対応) 利用例 GREE ポケラボ KLab など
Ethnaの動作イメージ Ethna本家参照 URL : http://ethna.jp/ethna-document-tutorial-overview.html
Ethnaのディレクトリ構成 app (アプリケーションのスクリプト) action (アクションスクリプト) action_cli(CLI用アクションスクリプト) action_xmlrpc(XMLRPC用アクションスクリプト) plugin(フィルタスクリプト) test (テストスクリプト) view (ビュースクリプト) bin (コマンドラインスクリプト) etc (設定ファイル等) lib (アプリケーションのライブラリ) locale ja_jp log (ログファイル) schema (DBスキーマ等) skel(アプリケーション用スケルトンファイル) template ja_jp(テンプレートファイル) tmp(一時ファイル) www (ウェブ公開用ファイル) css(CSSファイル) js(JavaScriptファイル)
Actionの記述例 class Sample_Form_Login extends Ethna_ActionForm { // フォームの定義 var $form = array(     ); } class Sample_Action_Login extends Ethna_ActionClass {     // 前処理     public function prepare() {     }     // メイン処理     public function perform() {     } }
ActionFormの記述例 var $form = array(     'id' => array(         'type' => VAR_TYPE_STRING,         'form_type' => FORM_TYPE_TEXT,         'name' => 'ID',         'required' => true,     ),     'passwd' => array(         'type' => VAR_TYPE_STRING,         'form_type' => FORM_TYPE_PASSWORD,         'name' => 'ログインパスワード',         'required' => true,     ), );
ActionClassの記述例 public function perform() { $result = false;     if ($this->af->validate() == 0) {         $id = $this->af->get('id');         $passwd = $this->af->get('passwd');         $userMng =& $this->backend->getManager("User");         $result = $userMng->auth($id, $passwd);     }     if ($result === false) {         $this->ae->add("loginerror", "ログインエラー");         return "login";     } else {         return "mypage";     } }
AppManagerとAppObjectの記述例 <?php class Sample_UserInf extends Ethna_AppObject { } class Sample_UserManager extends Ethna_AppManager {     public function auth($id, $passwd) {         $userInf = $this->backend->getObject('UserInf', "id", $id);         $pass = $userInf->get("passwd");         if ($passwd == $pass && $pass != "") {             return true;         }         return false;     } } ?>
テンプレートの記述例 {foreach from=$errors item=error} <span style="color: #FF0000;">{$error}</span><br /> {/foreach} {form ethna_action="login" action="/login.php"} ID {form_input name="id" size="20"}     パスワード {form_input name="passwd" size="8"}     {form_submit value="ログイン"} {/form}
まとめ メリット 国産(GREE)である. ActionFormを扱える. 自動でエスケープしてくれる. デフォルトでSmartyが使える. PEARと連携している. デメリット リリースペースが遅い. デフォルトでSmarty利用. ドキュメントが少ない.
Ethnaの参考資料 本家 http://ethna.jp/ ダウンロード http://ethna.jp/ethna-download.html チュートリアル http://ethna.jp/ethna-document-tutorial.html APIドキュメント http://ethna.jp/doc/

Contenu connexe

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

フレームワーク Ethna

  • 1. フレームワーク Ethna Ethnaの紹介 株式会社 CyberX エンジニア 石川泰式
  • 2. 目次 Ethnaとは Ethnaの動作イメージ Ethnaのディレクトリ構成 Ethnaの簡単なプログラム Actionの記述例 ActionFormの記述例 ActionClassの記述例 AppManagerとAppObjectの記述例 テンプレートの記述例 まとめ Ethnaの参考資料
  • 3. Ethnaとは EthnaとはPHPフレームワークの一つ 読み方は「えすな」 Ethnaは、PHPを利用したウェブアプリケーションフレームワークで似たようなコードを書かなくてよいことを目標に作成しています。(本文まま) 最新の安定版は 2.5.0 (PHP 5.3非対応) 開発版は 2.6.0 beta2 (PHP 5.3対応) 利用例 GREE ポケラボ KLab など
  • 4. Ethnaの動作イメージ Ethna本家参照 URL : http://ethna.jp/ethna-document-tutorial-overview.html
  • 5. Ethnaのディレクトリ構成 app (アプリケーションのスクリプト) action (アクションスクリプト) action_cli(CLI用アクションスクリプト) action_xmlrpc(XMLRPC用アクションスクリプト) plugin(フィルタスクリプト) test (テストスクリプト) view (ビュースクリプト) bin (コマンドラインスクリプト) etc (設定ファイル等) lib (アプリケーションのライブラリ) locale ja_jp log (ログファイル) schema (DBスキーマ等) skel(アプリケーション用スケルトンファイル) template ja_jp(テンプレートファイル) tmp(一時ファイル) www (ウェブ公開用ファイル) css(CSSファイル) js(JavaScriptファイル)
  • 6. Actionの記述例 class Sample_Form_Login extends Ethna_ActionForm { // フォームの定義 var $form = array( ); } class Sample_Action_Login extends Ethna_ActionClass { // 前処理 public function prepare() { } // メイン処理 public function perform() { } }
  • 7. ActionFormの記述例 var $form = array( 'id' => array( 'type' => VAR_TYPE_STRING, 'form_type' => FORM_TYPE_TEXT, 'name' => 'ID', 'required' => true, ), 'passwd' => array( 'type' => VAR_TYPE_STRING, 'form_type' => FORM_TYPE_PASSWORD, 'name' => 'ログインパスワード', 'required' => true, ), );
  • 8. ActionClassの記述例 public function perform() { $result = false; if ($this->af->validate() == 0) { $id = $this->af->get('id'); $passwd = $this->af->get('passwd'); $userMng =& $this->backend->getManager("User"); $result = $userMng->auth($id, $passwd); } if ($result === false) { $this->ae->add("loginerror", "ログインエラー"); return "login"; } else { return "mypage"; } }
  • 9. AppManagerとAppObjectの記述例 <?php class Sample_UserInf extends Ethna_AppObject { } class Sample_UserManager extends Ethna_AppManager { public function auth($id, $passwd) { $userInf = $this->backend->getObject('UserInf', "id", $id); $pass = $userInf->get("passwd"); if ($passwd == $pass && $pass != "") { return true; } return false; } } ?>
  • 10. テンプレートの記述例 {foreach from=$errors item=error} <span style="color: #FF0000;">{$error}</span><br /> {/foreach} {form ethna_action="login" action="/login.php"} ID {form_input name="id" size="20"} パスワード {form_input name="passwd" size="8"} {form_submit value="ログイン"} {/form}
  • 11. まとめ メリット 国産(GREE)である. ActionFormを扱える. 自動でエスケープしてくれる. デフォルトでSmartyが使える. PEARと連携している. デメリット リリースペースが遅い. デフォルトでSmarty利用. ドキュメントが少ない.
  • 12. Ethnaの参考資料 本家 http://ethna.jp/ ダウンロード http://ethna.jp/ethna-download.html チュートリアル http://ethna.jp/ethna-document-tutorial.html APIドキュメント http://ethna.jp/doc/