実践まるごとrhaco

52
まるごと 実践!

Upload: keisuke-sato

Post on 05-Dec-2014

3.032 views

Category:

Technology


0 download

DESCRIPTION

rhaco勉強会で使った資料です。

TRANSCRIPT

Page 1: 実践まるごとrhaco

 まるごと

実践!

Page 2: 実践まるごとrhaco

はじめに会場を提供して頂いたウノウさん

ありがとうございます!

ここいちさんだいすきです!!

とくしまさんもいろいろとありがとうございます!(てきとうすぎる?w)

Page 3: 実践まるごとrhaco

今回は突然の募集にも関わらず参加して頂きありがとうございます!

Page 4: 実践まるごとrhaco

ただ、突然すぎて資料まともに作る時間がありませんでした。。。

おかしなところとかわからないところはガンガンつっこんでくださいね!

Page 5: 実践まるごとrhaco

僕について

•riaf

• 北海道からついさっき来ました

• rhaco は聞いたことがある程度です

Page 6: 実践まるごとrhaco
Page 7: 実践まるごとrhaco

ところで...

Page 8: 実践まるごとrhaco

ところで...

rhaco知ってますか?

Page 9: 実践まるごとrhaco

rhaco知ってます?知っている 聞いたことはあるが知らない知らない hentai

「WebProgを極めて居酒屋を開発する」調べ

Page 10: 実践まるごとrhaco

半分以上の方が知っている。

Page 11: 実践まるごとrhaco

つまり

Page 12: 実践まるごとrhaco

え|っ!?

知らないの!?

いまどき

パイソニスタだって

知ってるよね|

Page 13: 実践まるごとrhaco

本題

Page 14: 実践まるごとrhaco

rhacoとは

•PHP4/5で動作

•ライブラリ

•セットアップフレームワーク

•レンタルサーバーで動く

Page 15: 実践まるごとrhaco

あれ?フレームワークじゃないの?

Page 16: 実践まるごとrhaco

フレームワークじゃないの?

ライブラリ集ですがフレームワークとしてもつかえるんです

というのが正解に近い気がする

Page 17: 実践まるごとrhaco

ライブラリとりあえず

雰囲気だけつかめたらOKです!理解しようと頑張らないで気軽に

Page 18: 実践まるごとrhaco

データベース

•MySQL/PostgreSQL/Oracle/SQLite

• 強力な Criteria / Criterion

•親子関係を解決(fact / depend)

•カテゴリ処理などでありがちなやつ

Page 19: 実践まるごとrhaco

データベース<?phprequire_once '__init__.php';Rhaco::import(‘database.DbUtil’);Rhaco::import(‘model.Item’);

$db = new DbUtil(Item::connection());$items = $db->select(new Item(),new C(Q::eq(Item::columnCategory(), 2), Q::fact())

);

Page 20: 実践まるごとrhaco

ネットワーク

•HTTP処理

• PEARでいうHTTP_Requestなど

•ブラウザー

• PEARでいうHTTP_Clientみたいな

Page 21: 実践まるごとrhaco

ネットワーク<?phprequire_once ‘rhaco/Rhaco.php’;Rhaco::import(‘network.http.Http’);Rhaco::import(‘network.http.Browser’);

$mixiContent = Http::get(‘http://mixi.jp/’);$mixib = new Browser();$mixib->setVariable(‘mail’, ‘hogehoge’);$mixib->setVariable(‘password’, ‘hogehoge’);$login = $mixib->post(‘http://mixi.jp/login.pl’);

Page 22: 実践まるごとrhaco

XML

•XML/HTML などを生成・読込

• PHP4でも動作するHTMLパーサとしては最強じゃないかな?

•テンプレートエンジン

Page 23: 実践まるごとrhaco

XML

<?phprequire_once ‘rhaco/Rhaco.php’;Rhaco::import(‘tag.model.SimpleTag’);

$tag = new SimpleTag();$tag->set("<xxx val="value" /></xxx>", "xxxx");$tag->getParameter(‘val’); //-> “value”

Page 24: 実践まるごとrhaco

ファイル操作

•ファイルの読み込み書き出し処理

•ディレクトリ操作

• ls メソッドなど

Page 25: 実践まるごとrhaco

国際化

•gettext ライクな独自実装

•つまり、gettext拡張は不要

•セットアップで、言語定義ファイルなどの生成が可能

Page 26: 実践まるごとrhaco

汎用ビュー

•リクエスト処理から、モデル、テンプレートまで全ておまかせできる

•単純なCRUDならば1行で記述可能

Page 27: 実践まるごとrhaco

汎用ビュー<?phprequire_once '__init__.php';Rhaco::import('generic.Views');Rhaco::import('model.Item');

$views = new Views(Item::connection());$parser = $views->read(new Item());$parser->write();

Page 28: 実践まるごとrhaco

例外

•PHPではPHP5から導入された概念

• rhacoでは擬似的に例外を実装

Page 29: 実践まるごとrhaco

例外class Hoge(){function fuga(){ExceptionTrigger::raise(new GenericException("test")

);}

}Hoge::fuga(); // 例外が投げられるif(ExceptionTrigger::isException()){// エラー後の処理

}

Page 30: 実践まるごとrhaco

Object 操作

•匿名クラスを生成

•mixin

• プロパティーをコピー(Object, Array)

Page 31: 実践まるごとrhaco

各種Util• Automator (順次実行処理)

• DocTest (ソースコード内にテスト記述)

• UnitTest

• DocUtil (ソースコードからドキュメント生成)

• Logger

Page 32: 実践まるごとrhaco

まだまだたくさんありますが僕も把握しきれてないのでパス

Page 33: 実践まるごとrhaco

io.model.File io.FileUtil io.Stream io.Cache io.Snapshot tag.feed.NetscapeBookmark tag.feed.model.AtomLink tag.feed.model.RssChannel09 tag.feed.model.RssChannel10 tag.feed.model.RssChannel20 tag.feed.model.AtomEntry tag.feed.model.RssSource tag.feed.model.AtomSummary

tag.feed.model.NetscapeBookmarkItem tag.feed.model.RssTextinput tag.feed.model.RssItem tag.feed.model.AtomContent tag.feed.model.RssEnclosure tag.feed.model.RssItem10 tag.feed.model.RssItem20 tag.feed.model.NetscapeBookmarkBlock

tag.feed.model.RssChannel tag.feed.model.OpmlOutline tag.feed.model.RssImage tag.feed.model.AtomAuthor tag.feed.model.RssTextinput10 tag.feed.model.RssCloud tag.feed.model.AtomEntry03 tag.feed.model.AtomEntry10 tag.feed.model.RssImage09 tag.feed.model.RssImage10

tag.feed.Opml tag.feed.Atom03 tag.feed.Atom10 tag.feed.Rss tag.feed.FeedParser tag.feed.Atom tag.feed.Rss09 tag.feed.Rss10 tag.feed.Rss2tag.model.SimpleTagParameter tag.model.SimpleTag tag.model.TemplateFormatter tag.TagParser tag.HtmlParser tag.TemplateParser

abbr.abbr.E abbr.F abbr.L abbr.M abbr.Q abbr.V lang.UnitUtil lang.model.AssertResult lang.Variable lang.Assert lang.DateUtil lang.ObjectUtil lang.Validate lang.ArrayUtil lang.Env lang.StringUtil lang.MathUtil util.model.LogRecord util.model.DocFunction util.DocUtil util.Automator

util.UnitTest util.Logger util.DocTest database.model.Column database.model.TableObjectBase database.model.Table database.model.CriteriaPattern database.model.DbConnection database.model.Criteria database.model.Criterion database.DbUtil

database.TableObjectUtil database.TableObjectVerify database.controller.DbUtilOracle database.controller.DbUtilMySQL database.controller.DbUtilPostgreSQL database.controller.DbUtilSQLite database.DbUtilBase setup.util.model.CaseModel setup.util.AuthFileManager setup.util.SetupView setup.util.SetupUtil setup.util.ApplicationInstaller setup.util.PotGenerator

setup.database.model.TableModel setup.database.model.ExTableModel setup.database.model.MapTableModel setup.database.model.DatabaseModel setup.database.model.ColumnModel setup.database.controller.DbUtilMySQLInitializer

setup.database.controller.DbUtilOracleInitializer setup.database.controller.DbUtilSQLiteInitializer setup.database.controller.DbUtilPostgreSQLInitializer setup.database.DbUtilInitializer setup.model.ProjectInputModel setup.model.ProjectModel setup.filter.SetupViewsFilter setup.resources.intl setup.SetupGenerator exception.model.DataTypeException exception.model.MinSizeException

exception.model.GenericException exception.model.PermissionException exception.model.SqlException exception.model.ExceptionBaseexception.model.IllegalStateException exception.model.NotConnectionException exception.model.NotFoundException exception.model.RequireException exception.model.DuplicateException

exception.model.IllegalArgumentException exception.model.ClassTypeException exception.model.HttpPostFilesException exception.model.MinLengthException exception.model.MaxLengthException

exception.model.NotSupportedExceptionexception.model.MaxSizeException exception.ExceptionTrigger irhaco Rhaco generic.util.ViewsUtil generic.Views generic.model.SortOrder generic.model.Paginator generic.Urls generic.filter.RequestLoginFilter generic.filter.ViewsFilter generic.Flow

generic.InstallViews generic.Paginator generic.ViewsUtil network.http.model.RequestLoginConditionBrowser network.http.model.RequestLoginCondition network.http.model.RequestLoginConditionDb network.http.model.RequestLoginConditionFile

network.http.Request network.http.RequestLogin network.http.Browser network.http.ServiceRestAPIBase network.http.Header network.http.Http network.mail.Mail network.mail.IMAP network.mail.SMTP network.mail.POP3 network.Url network.Socket setup

resources.locale.messages.message-ja resources.Message

まだまだたくさんありますが僕も把握しきれてないのでパス

Page 34: 実践まるごとrhaco

こんなかんじでなんでもありなライブラリ集

Page 35: 実践まるごとrhaco

ちょっとまって

Page 36: 実践まるごとrhaco

それrhacoじゃなくてよくね?

Page 37: 実践まるごとrhaco
Page 38: 実践まるごとrhaco

何故rhacoを使うか

Page 39: 実践まるごとrhaco

rhacoを使う理由•セットアップフレームワーク

•ライブラリの質が高い

• PHPらしい書き方ができる

• PHPを機能強化するようなライブラリ群

•なんといっても簡単

Page 40: 実践まるごとrhaco

セットアップ•project.xml 記述で、簡易的な管理画面が使用できる

•環境差異を気にしなくて良い

• ローカルからサーバーにアップロードするときに設定ファイルを書き換えたりなんてしたくない!

Page 41: 実践まるごとrhaco
Page 42: 実践まるごとrhaco

ライブラリの質

•コミッタは tokushima さん一人

•やっぱりライブラリは独裁のほうがいいですよ。ほら、どこかのPなんとかP言語みたいになっty(ry

Page 43: 実践まるごとrhaco

ライブラリの質

•コミッタは tokushima さん一人

•やっぱりライブラリは独裁のほうがいいですよ。ほら、どこかのPなんとかP言語みたいになっty(ry

hentai++

Page 44: 実践まるごとrhaco

でも、rhacoだけじゃ物足りないときあるよね?

WebService使いたい!とか。

Page 45: 実践まるごとrhaco

arbo• rhacoに無い部分を拡張したり

•特定のサービスに依存しちゃうライブラリだったり

•本体に取り込むのはちょっとなーとか

•コミッタ複数居ます

Page 46: 実践まるごとrhaco

jaja

• rhacoで作られたアプリ集

•実際に利用することも

•サンプルとしても

ついでに

Page 47: 実践まるごとrhaco
Page 48: 実践まるごとrhaco

rhacoをフレームワークとしてつかう

Page 49: 実践まるごとrhaco

開発の流れrhacoを

ダウンロードディレクトリ

作成setup.phpコピー

setup.phpアクセス

ファイル生成 project.xml記述

あとはコードを書いて行く!

Page 50: 実践まるごとrhaco

続きは tokushima さんが実践編としてやってくれるはず!!

Page 51: 実践まるごとrhaco

おしまいありがとうございました!