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
150
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
140
LaravelでTDDを体験しよう #phpcon2018
omoon
1
4k
Laravel でアプリケーションを開発し Heroku で公開するまでの一部始終 #laravel_osaka
omoon
3
1.4k
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
940
FuelPHP をさわってみて #phpkansai
omoon
2
190
Other Decks in Technology
See All in Technology
Unsafe.BitCast のすゝめ。
nenonaninu
0
200
2024年活動報告会(人材育成推進WG・ビジネスサブWG) / 20250114-OIDF-J-EduWG-BizSWG
oidfj
0
210
シフトライトなテスト活動を適切に行うことで、無理な開発をせず、過剰にテストせず、顧客をビックリさせないプロダクトを作り上げているお話 #RSGT2025 / Shift Right
nihonbuson
3
2.1k
Formal Development of Operating Systems in Rust
riru
1
420
「隙間家具OSS」に至る道/Fujiwara Tech Conference 2025
fujiwara3
7
6.4k
Goで実践するBFP
hiroyaterui
1
120
機械学習を「社会実装」するということ 2025年版 / Social Implementation of Machine Learning 2025 Version
moepy_stats
5
970
いま現場PMのあなたが、 経営と向き合うPMになるために 必要なこと、腹をくくること
hiro93n
9
7.5k
20250116_自部署内でAmazon Nova体験会をやってみた話
riz3f7
1
100
My small contributions - Fujiwara Tech Conference 2025
ijin
0
1.4k
When Windows Meets Kubernetes…
pichuang
0
300
コロプラのオンボーディングを採用から語りたい
colopl
5
970
Featured
See All Featured
Designing on Purpose - Digital PM Summit 2013
jponch
116
7.1k
Raft: Consensus for Rubyists
vanstee
137
6.7k
The Invisible Side of Design
smashingmag
299
50k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.5k
Code Review Best Practice
trishagee
65
17k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
GraphQLとの向き合い方2022年版
quramy
44
13k
YesSQL, Process and Tooling at Scale
rocio
170
14k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
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Λੵۃతʹ͍·͠ΐ͏
͋Γ͕ͱ͏͍͟͝·ͨ͠