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.9k
素晴らしき Carbon の世界 〜あなたも今日から日時マスター〜
omoon
4
14k
Dive into the Cloud with our buddy, lovely PHP!
omoon
0
930
FuelPHP をさわってみて #phpkansai
omoon
2
180
Other Decks in Technology
See All in Technology
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
380
Microsoft Azure全冠になってみた ~アレを使い倒した者が試験を制す!?~/Obtained all Microsoft Azure certifications Those who use "that" to the full will win the exam! ?
yuj1osm
1
110
re:Invent 2024 Innovation Talks(NET201)で語られた大切なこと
shotashiratori
0
300
第3回Snowflake女子会_LT登壇資料(合成データ)_Taro_CCCMK
tarotaro0129
0
180
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
180
権威ドキュメントで振り返る2024 #年忘れセキュリティ2024
hirotomotaguchi
2
730
Snykで始めるセキュリティ担当者とSREと開発者が楽になる脆弱性対応 / Getting started with Snyk Vulnerability Response
yamaguchitk333
2
180
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
2
520
.NET 9 のパフォーマンス改善
nenonaninu
0
690
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
160
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
330
20241214_WACATE2024冬_テスト設計技法をチョット俯瞰してみよう
kzsuzuki
3
440
Featured
See All Featured
Typedesign – Prime Four
hannesfritz
40
2.4k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
We Have a Design System, Now What?
morganepeng
51
7.3k
Making Projects Easy
brettharned
116
5.9k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
4 Signs Your Business is Dying
shpigford
181
21k
Code Reviewing Like a Champion
maltzj
520
39k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
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Λੵۃతʹ͍·͠ΐ͏
͋Γ͕ͱ͏͍͟͝·ͨ͠