Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
omoon.org の裏側 〜FuelPHP の task 活用例〜
Search
omoon
October 12, 2013
Technology
0
140
omoon.org の裏側 〜FuelPHP の task 活用例〜
2013/10/12 の FuelPHP&CodeIgniter ユーザの集い LT 資料です。
omoon
October 12, 2013
Tweet
Share
More Decks by omoon
See All by omoon
My First Adobe XD Plugin
omoon
0
130
LaravelでTDDを体験しよう #phpcon2018
omoon
1
3.9k
Laravel でアプリケーションを開発し Heroku で公開するまでの一部始終 #laravel_osaka
omoon
3
1.3k
Why don't you try "Query Builder"
omoon
1
2.8k
素晴らしき Carbon の世界 〜あなたも今日から日時マスター〜
omoon
4
14k
Dive into the Cloud with our buddy, lovely PHP!
omoon
0
920
FuelPHP をさわってみて #phpkansai
omoon
2
180
Other Decks in Technology
See All in Technology
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
スクラム成熟度セルフチェックツールを作って得た学びとその活用法
coincheck_recruit
1
140
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
2
580
エンジニア人生の拡張性を高める 「探索型キャリア設計」の提案
tenshoku_draft
1
120
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
290
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
150
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
240
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
170
Terraform未経験の御様に対してどの ように導⼊を進めていったか
tkikuchi
2
430
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
0
110
Evangelismo técnico: ¿qué, cómo y por qué?
trishagee
0
360
データプロダクトの定義からはじめる、データコントラクト駆動なデータ基盤
chanyou0311
2
280
Featured
See All Featured
Speed Design
sergeychernyshev
24
610
Automating Front-end Workflow
addyosmani
1366
200k
How to Ace a Technical Interview
jacobian
276
23k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Scaling GitHub
holman
458
140k
Git: the NoSQL Database
bkeepers
PRO
427
64k
The Cult of Friendly URLs
andyhume
78
6k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Transcript
PNPPOPSHͷཪଆ 'VFM1)1ͷUBTL׆༻ྫ 'VFM1)1ˍ$PEF*HOJUFSϢʔβͷू͍ʢ'VFM1)1౦ژษڧձɺ$PEF*HOJUFSUBMLʣ 0DUPCFS 4PUBSP0.63" !PNPPO
"CPVU.F
"CPVU.F w4PUBSP0.63"
"CPVU.F w4PUBSP0.63" wେࡕ͔Βདྷ·ͨ͠
"CPVU.F w4PUBSP0.63" wେࡕ͔Βདྷ·ͨ͠ w,BOTBJ1)16TFST(SPVQ4UB⒎
"CPVU.F w4PUBSP0.63" wେࡕ͔Βདྷ·ͨ͠ w,BOTBJ1)16TFST(SPVQ4UB⒎ w1)1ྺ΄Ͳʢ࠷ۙ'VFM1)1ʣ
"CPVU.F w4PUBSP0.63" wେࡕ͔Βདྷ·ͨ͠ w,BOTBJ1)16TFST(SPVQ4UB⒎ w1)1ྺ΄Ͳʢ࠷ۙ'VFM1)1ʣ wPNPPOPSH
"CPVU.F w4PUBSP0.63" wେࡕ͔Βདྷ·ͨ͠ w,BOTBJ1)16TFST(SPVQ4UB⒎ w1)1ྺ΄Ͳʢ࠷ۙ'VFM1)1ʣ wPNPPOPSH w!PNPPO
"CPVU.F w4PUBSP0.63" wେࡕ͔Βདྷ·ͨ͠ w,BOTBJ1)16TFST(SPVQ4UB⒎ w1)1ྺ΄Ͳʢ࠷ۙ'VFM1)1ʣ wPNPPOPSH w!PNPPO
ΊΜͲ͕͘͞Γ
None
None
"CPVU.F
"CPVU.F
ϑϨʔϜϫʔΫΛͬͨ αϯϓϧΞϓϦέʔγϣϯ
1 <?php 2 require __DIR__ . '/../vendor/autoload.php'; 3 4
$app = new Silex\Application(); 5 6 $app-‐>register(new Silex\Provider\TwigServiceProvider(), array( 7 'twig.path' => __DIR__.'/../views', 8 )); 9 10 // σʔλϕʔεଓใͷಡࠐ 11 $env = getenv('APP_ENV') ?: 'development'; 12 $config = require __DIR__ . "/../config/$env.php"; 13 $app-‐>register(new Silex\Provider\DoctrineServiceProvider(), array( 14 'db.options' => $config['db'], 15 )); 16 17 // τοϓը໘ 18 $app-‐>get('/', function(Silex\Application $app) { 19 $posts = $app['db']-‐>fetchAll(' 20 SELECT name, message, unix_timestamp(created) as created 21 FROM posts ORDER BY created DESC LIMIT 5 22 '); 23 return $app['twig']-‐>render('index.twig', array( 24 'posts' => $posts, 25 )); 26 }); 27 28 // ߘॲཧ 29 $app-‐>post('/speak', function(Silex\Application $app) { 30 $name = $app['request']-‐>get('name'); 31 $message = $app['request']-‐>get('message'); 32 if ($name && $message) { 33 $app['db']-‐>insert('posts', array('name' => $name, 'message' => $message)); 34 } 35 return $app-‐>redirect('/'); 36 }); 37 38 $app-‐>run();
1 <?php 2 require __DIR__ . '/../vendor/autoload.php'; 3 4
$app = new Silex\Application(); 5 6 $app-‐>register(new Silex\Provider\TwigServiceProvider(), array( 7 'twig.path' => __DIR__.'/../views', 8 )); 9 10 // σʔλϕʔεଓใͷಡࠐ 11 $env = getenv('APP_ENV') ?: 'development'; 12 $config = require __DIR__ . "/../config/$env.php"; 13 $app-‐>register(new Silex\Provider\DoctrineServiceProvider(), array( 14 'db.options' => $config['db'], 15 )); 16 17 // τοϓը໘ 18 $app-‐>get('/', function(Silex\Application $app) { 19 $posts = $app['db']-‐>fetchAll(' 20 SELECT name, message, unix_timestamp(created) as created 21 FROM posts ORDER BY created DESC LIMIT 5 22 '); 23 return $app['twig']-‐>render('index.twig', array( 24 'posts' => $posts, 25 )); 26 }); 27 28 // ߘॲཧ 29 $app-‐>post('/speak', function(Silex\Application $app) { 30 $name = $app['request']-‐>get('name'); 31 $message = $app['request']-‐>get('message'); 32 if ($name && $message) { 33 $app['db']-‐>insert('posts', array('name' => $name, 'message' => $message)); 34 } 35 return $app-‐>redirect('/'); 36 }); 37 38 $app-‐>run();
1 <?php 2 require __DIR__ . '/../vendor/autoload.php'; 3 4
$app = new Silex\Application(); 5 6 $app-‐>register(new Silex\Provider\TwigServiceProvider(), array( 7 'twig.path' => __DIR__.'/../views', 8 )); 9 10 // σʔλϕʔεଓใͷಡࠐ 11 $env = getenv('APP_ENV') ?: 'development'; 12 $config = require __DIR__ . "/../config/$env.php"; 13 $app-‐>register(new Silex\Provider\DoctrineServiceProvider(), array( 14 'db.options' => $config['db'], 15 )); 16 17 // τοϓը໘ 18 $app-‐>get('/', function(Silex\Application $app) { 19 $posts = $app['db']-‐>fetchAll(' 20 SELECT name, message, unix_timestamp(created) as created 21 FROM posts ORDER BY created DESC LIMIT 5 22 '); 23 return $app['twig']-‐>render('index.twig', array( 24 'posts' => $posts, 25 )); 26 }); 27 28 // ߘॲཧ 29 $app-‐>post('/speak', function(Silex\Application $app) { 30 $name = $app['request']-‐>get('name'); 31 $message = $app['request']-‐>get('message'); 32 if ($name && $message) { 33 $app['db']-‐>insert('posts', array('name' => $name, 'message' => $message)); 34 } 35 return $app-‐>redirect('/'); 36 }); 37 38 $app-‐>run(); ͳΜ͔͢Έ·ͤΜ
'VFM1)1ͱͷͳΕͦΊ
None
None
None
None
None
͓͖Ͱ͢Ͷ
ଞʹ
None
࠷ۙ
None
None
None
None
None
+40/ͰΓͱΓ
None
͋Γ͕ͱ͏
ͯ͞
PNPPOPSH
None
PNPPOPSH
PNPPOPSH w͝Ζελʔτ
PNPPOPSH w͝Ζελʔτ wࣸਅͱҰߦίϝϯτ͚ͩ
PNPPOPSH w͝Ζελʔτ wࣸਅͱҰߦίϝϯτ͚ͩ w࠷ॳ)5.- '51Ξοϓϩʔυ
ΊΜͲ͕͘͞Γ
None
None
None
؆қԽͷྺ࢙
؆қԽͷྺ࢙ w'MJDLS
؆қԽͷྺ࢙ w'MJDLS w1)1 .Z42-
؆қԽͷྺ࢙ w'MJDLS w1)1 .Z42- w'MJDLS &ZF'J
؆қԽͷྺ࢙ w'MJDLS w1)1 .Z42- w'MJDLS &ZF'J wಠࣗDSPOKPC
None
ΦϨΦϨͳͷͰ͠ͳ͍
None
5BTLTBSFDMBTTFTUIBUDBOCFSVOUISPVHIUIFDPNNBOEMJOFPS TFUVQBTBDSPOKPC5IFZBSFHFOFSBMMZVTFEGPSCBDLHSPVOE QSPDFTTFT UJNFEUBTLTBOENBJOUFOBODFUBTLT5BTLTDBODBMMT NPEFMTBOEPUIFSDMBTTFTKVTUMJLFDPOUSPMMFST
5BTLT
5BTLT wίϚϯυϥΠϯ͔ΒݺΔ
5BTLT wίϚϯυϥΠϯ͔ΒݺΔ wDSPOKPCͱͯ͑͠Δ
5BTLT wίϚϯυϥΠϯ͔ΒݺΔ wDSPOKPCͱͯ͑͠Δ wόοΫάϥϯυॲཧͱ͔
5BTLT wίϚϯυϥΠϯ͔ΒݺΔ wDSPOKPCͱͯ͑͠Δ wόοΫάϥϯυॲཧͱ͔ wఆظతͳॲཧͱ͔
5BTLT wίϚϯυϥΠϯ͔ΒݺΔ wDSPOKPCͱͯ͑͠Δ wόοΫάϥϯυॲཧͱ͔ wఆظతͳॲཧͱ͔ wϝϯςφϯεʹ
5BTLT wίϚϯυϥΠϯ͔ΒݺΔ wDSPOKPCͱͯ͑͠Δ wόοΫάϥϯυॲཧͱ͔ wఆظతͳॲཧͱ͔ wϝϯςφϯεʹ wϞσϧΫϥεΛίϯτϩʔϥ͔ΒݺͿ࣌Έ͍ͨʹݺΔ
͍͚Δ͔
ͬͯΈͨ
None
▾ fuel/ ▾ app/ ▸ cache/
▾ classes/ ▸ controller/ ▸ model/ ▸ twig/ ▸ view/ flickr.php ▾ config/ ▸ development/ ▸ production/ ▸ test/ config.php db.php parser.php rest.php routes.php ▸ lang/ ▸ less/ ▸ logs/ ▸ migrations/ ▸ modules/ ▾ tasks/ flickr.php robots.php ▸ tests/ ▸ tmp/ ▾ vendor/ ▸ Goutte/ ▾ phpFlickr/ auth.php example.php getToken.php phpFlickr.php README.txt ▸ Twig/ .gitkeep ֎෦ϥΠϒϥϦ
▾ fuel/ ▾ app/ ▸ cache/
▾ classes/ ▸ controller/ ▸ model/ ▸ twig/ ▸ view/ flickr.php ▾ config/ ▸ development/ ▸ production/ ▸ test/ config.php db.php parser.php rest.php routes.php ▸ lang/ ▸ less/ ▸ logs/ ▸ migrations/ ▸ modules/ ▾ tasks/ flickr.php robots.php ▸ tests/ ▸ tmp/ ▾ vendor/ ▸ Goutte/ ▾ phpFlickr/ auth.php example.php getToken.php phpFlickr.php README.txt ▸ Twig/ .gitkeep Ϋϥε
require_once APPPATH . 'vendor' . DS . 'phpFlickr' . DS
. 'phpFlickr.php'; class Flickr { protected static $_instance = null; private function __construct() { $this-‐>api = new phpFlickr( 'xxxxxxxxxxxxxxxxxxxx' //Config::get('app.flickr_api_key') ); } public static function forge() { if (empty(self::$_instance)) { static::$_instance = new static(); } return static::$_instance-‐>api; } }
▾ fuel/ ▾ app/ ▸ cache/
▾ classes/ ▸ controller/ ▸ model/ ▸ twig/ ▸ view/ flickr.php ▾ config/ ▸ development/ ▸ production/ ▸ test/ config.php db.php parser.php rest.php routes.php ▸ lang/ ▸ less/ ▸ logs/ ▸ migrations/ ▸ modules/ ▾ tasks/ flickr.php robots.php ▸ tests/ ▸ tmp/ ▾ vendor/ ▸ Goutte/ ▾ phpFlickr/ auth.php example.php getToken.php phpFlickr.php README.txt ▸ Twig/ .gitkeep λεΫ
namespace Fuel\Tasks; class Flickr { public static
function run($limit = 4) { $response = \Flickr::forge()-‐>photos_search( array( 'user_id' => '94387617@N00', 'per_page' => $limit, 'tags' => 'asgt,cover', 'tag_mode' => 'all', 'sort' => 'date-‐taken-‐desc' ) ); foreach ($response['photo'] as $photo) { $r = \Flickr::forge()-‐>photos_getInfo($photo['id']); $e = \Flickr::forge()-‐>photos_getExif($photo['id']); //print_r($e['camera']); if (null === \Model_Coverphoto::find_by('flickr_id', $r['photo']['id'])) { $r['photo']['dates']['taken']; $coverphoto = \Model_Coverphoto::forge(); $coverphoto-‐>flickr_id = $r['photo']['id']; $coverphoto-‐>title = $r['photo']['description']; $coverphoto-‐>taken_at = $r['photo']['dates']['taken']; $coverphoto-‐>camera = $e['camera']; $coverphoto-‐>data = json_encode($r['photo']); $coverphoto-‐>save(); } } } }
# crontab -‐e * * * * * cd /var/www/omoon.org;
/usr/bin/php oil refine flickr:run
None
PNPPOPSH
λά͚͚ͩͰߋ৽Մೳ
J1IPOFͷqJDLSΞϓϦͰ
ࠓޙͷల
None
None
UBTLΛੵۃతʹ͍·͠ΐ͏
͋Γ͕ͱ͏͍͟͝·ͨ͠