SlideShare a Scribd company logo
1 of 41
行動APP開發管理實務
WNMP & Phalcon Micro App – Part II
2016.01.05 @ 淡江大學商管B217
Taien Wang <taien_wang@hiiir.com>
時間軸科技股份有限公司
Agenda
• Part I
– Windows
• nginx
• php
• Phalcon
• Part II
– mysql
– micro-restful api
2
Review
• Resource: http://taien.idv.tw/files/20160105-tku-web.7z
– nginx
– php
– phalcon
3
Phalcon
• Download Phalcon form https://phalconphp.com/en/download/windows
• Copy php_phalcon.dll to php extension dir
– ex: C:webphpext
• Modify the configuration from php.ini-development to php.ini
– extension=php_phalcon.dll
• Phalcon Dev Tool
– Download: https://phalconphp.com/en/download/tools
– Docs: https://docs.phalconphp.com/en/latest/reference/tools.html
– Source: https://github.com/phalcon/phalcon-devtools
4
Phalcon – Nginx configuration
5
source: https://docs.phalconphp.com/en/latest/reference/nginx.html
Target - AddressBook
API resource Method Raw Body
select a contact addressbook/{Id} GET
select multi contacts addressbook GET
create contact addressbook POST {"name":"taien","mobile":"0912111
111"}
modify contact addressbook/{Id} PUT {"name":"taien","mobile":"0912111
111"}
delete contact addressbook/{Id} DELETE
6
URL:http://tku.api.taien.idv.tw:8080/
Chrome extension - Postman
7
MySQL
• Download PHP form https://dev.mysql.com/downloads/mysql/
– mysql-installer-community-5.6.28.0.msi
8
MySQL – License agreement
9
MySQL – Choosing a setup type
10
MySQL – Select products and features
11
MySQL – Check requirements
12
MySQL – Installation excute
13
MySQL – Install complete
14
MySQL – Product configuration
15
MySQL – Type and networking
16
MySQL – Accounts and roles
17
MySQL – Window service
18
MySQL – Advanced options
19
MySQL – Apply server configuration
20
MySQL – Apply server configuration finish
21
MySQL – Product configuration
22
MySQL – Installation complete
23
MySQL – Create databases
• mysql –h localhost –u root –p
• CREATE DATABASE `tku-sample` CHARACTER SET utf8 COLLATE utf8_general_ci;
• use `tku-sample`;
• CREATE TABLE `addressbook` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(45) NOT NULL,
`mobile` varchar(45) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
24
Windows Environment Variables
• Environment Variables
– Path
• C:webphp;C:webnginx;C:webphalcon-devtools-master;C:Program
FilesMySQLMySQL Server 5.7bin
25
Phalcon Micro App Command
• Create project
– phalcon project tku --type=mirco
• Setup DB in config/config.php
• Create ORM model
– phalcon model addressbook
26
Restful API (1/3)
27
Restful API (2/3)
28
Restful API (3/3)
29
Phalcon Code - Hello TKU
$app->get('/tku', function () use ($app) {
echo "Hello, TKU!";
});
30
Phalcon Code - Select a contact
$app->get('/addressbook/{addressbookId}', function ($addressbookId) use ($app) {
$response = new Response();
$AddressBook = Addressbook::findFirst($addressbookId);
$data = array();
if ($AddressBook) {
$data["id"] = $AddressBook->id;
$data["name"] = $AddressBook->name;
$data["mobile"] = $AddressBook->mobile;
echo json_encode($data);
} else {
$response->setStatusCode(404, "Not Found");
return $response;
}});
31
Phalcon Code - Select multi contacts
$app->get('/addressbook', function () use ($app) {
$AddressBooks = Addressbook::find();
$data = array();
foreach ($AddressBooks as $AddressBook) {
$data[] = array(
'id' => $AddressBook->id,
'name' => $AddressBook->name,
'mobile' => $AddressBook->mobile);
}
echo json_encode($data);
});
32
Phalcon Code - Create contact
$app->post('/addressbook', function () use ($app) {
$response = new Response();
$bodyData = $app->request->getJsonRawBody();
$requestAry = json_decode(json_encode($bodyData), true);
$AddressBook = new Addressbook;
$AddressBook->name = $requestAry["name"];
$AddressBook->mobile = $requestAry["mobile"];
$result = $AddressBook->save();
if ($result) {
$response->setStatusCode(201, "Created");
} else {
$response->setStatusCode(500, "Internal Error");
}
return $response;
});
33
Phalcon Code - Modify contact
$app->put('/addressbook/{addressbookId}', function ($addressbookId) use ($app) {
$response = new Response();
$bodyData = $app->request->getJsonRawBody();
$requestAry = json_decode(json_encode($bodyData), true);
$AddressBook = Addressbook::findFirst($addressbookId);
if ($AddressBook) {
$AddressBook->name = $requestAry["name"];
$AddressBook->mobile = $requestAry["mobile"];
$result = $AddressBook->save();
if ($result) {
$response->setStatusCode(202, "Accepted");
} else {
$response->setStatusCode(500, "Internal Error");
}
} else {
$response->setStatusCode(500, "Internal Error");
}
return $response;
});
34
Phalcon Code - Delete contact
$app->delete('/addressbook/{addressbookId}', function ($addressbookId) use ($app) {
$response = new Response();
$AddressBook = Addressbook::findFirst($addressbookId);
if ($AddressBook) {
$result = $AddressBook->delete();
if ($result) {
$response->setStatusCode(202, "Accepted");
} else {
$response->setStatusCode(500, "Internal Error");
}
} else {
$response->setStatusCode(500, "Internal Error");
}
return $response;
});
35
Mission
• 20%: Select a contact
• 20%: Select multi contact
• 20%: Create a contact
• 20%: Modify a contact
• 20%: Delete a contact
36
Mission - Select multi contact
37
Mission - Select a contact
38
Mission - Create a contact
39
Mission – Modify a contact
40
Mission – Delete a contact
41

More Related Content

What's hot

Laravel でやってみるクリーンアーキテクチャ #phpconfuk
Laravel でやってみるクリーンアーキテクチャ #phpconfukLaravel でやってみるクリーンアーキテクチャ #phpconfuk
Laravel でやってみるクリーンアーキテクチャ #phpconfukShohei Okada
 
Awash in a sea of connections
Awash in a sea of connectionsAwash in a sea of connections
Awash in a sea of connectionsGalen Charlton
 
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For KohaPutting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For KohaGalen Charlton
 
TDC2015 Porto Alegre - Automate everything with Phing !
TDC2015 Porto Alegre - Automate everything with Phing !TDC2015 Porto Alegre - Automate everything with Phing !
TDC2015 Porto Alegre - Automate everything with Phing !Matheus Marabesi
 
Reactive computing
Reactive computingReactive computing
Reactive computingStan Lea
 

What's hot (7)

Laravel でやってみるクリーンアーキテクチャ #phpconfuk
Laravel でやってみるクリーンアーキテクチャ #phpconfukLaravel でやってみるクリーンアーキテクチャ #phpconfuk
Laravel でやってみるクリーンアーキテクチャ #phpconfuk
 
Awash in a sea of connections
Awash in a sea of connectionsAwash in a sea of connections
Awash in a sea of connections
 
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For KohaPutting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
Putting the Cat in the Catalogue: A Feline-Inspired OPAC Theme For Koha
 
Web Scraping
Web ScrapingWeb Scraping
Web Scraping
 
YAP / Open Mail Overview
YAP / Open Mail OverviewYAP / Open Mail Overview
YAP / Open Mail Overview
 
TDC2015 Porto Alegre - Automate everything with Phing !
TDC2015 Porto Alegre - Automate everything with Phing !TDC2015 Porto Alegre - Automate everything with Phing !
TDC2015 Porto Alegre - Automate everything with Phing !
 
Reactive computing
Reactive computingReactive computing
Reactive computing
 

Similar to WNMP & Phalcon Micro App

fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)
fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)
fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)modeelf
 
Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud CastlesBen Scofield
 
Laravel for Web Artisans
Laravel for Web ArtisansLaravel for Web Artisans
Laravel for Web ArtisansRaf Kewl
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php PresentationAlan Pinstein
 
Collaboration hack with slackbot - PyCon HK 2018 - 2018.11.24
Collaboration hack with slackbot - PyCon HK 2018 - 2018.11.24Collaboration hack with slackbot - PyCon HK 2018 - 2018.11.24
Collaboration hack with slackbot - PyCon HK 2018 - 2018.11.24Kei IWASAKI
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5Darren Craig
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Hugo Hamon
 
Symfony console: build awesome command line scripts with ease
Symfony console: build awesome command line scripts with easeSymfony console: build awesome command line scripts with ease
Symfony console: build awesome command line scripts with easeOscar Merida
 
Ecto and Phoenix: Doing web with Elixir - Yurii Bodarev
Ecto and Phoenix: Doing web with Elixir - Yurii BodarevEcto and Phoenix: Doing web with Elixir - Yurii Bodarev
Ecto and Phoenix: Doing web with Elixir - Yurii BodarevElixir Club
 
Ecto and Phoenix: Doing Web With Elixir
Ecto and Phoenix: Doing Web With ElixirEcto and Phoenix: Doing Web With Elixir
Ecto and Phoenix: Doing Web With ElixirYurii Bodarev
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in detailsMax Klymyshyn
 
HotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePushHotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePushEvan Schultz
 
Jakob Holderbaum - Managing Shared secrets using basic Unix tools
Jakob Holderbaum - Managing Shared secrets using basic Unix toolsJakob Holderbaum - Managing Shared secrets using basic Unix tools
Jakob Holderbaum - Managing Shared secrets using basic Unix toolsDevSecCon
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswanivvaswani
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Edureka!
 

Similar to WNMP & Phalcon Micro App (20)

fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)
fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)
fb-researchの舞台裏No.2~技術編~(HatchUp主催 渋谷Facebookアプリ勉強会)
 
Kyiv.py #17 Flask talk
Kyiv.py #17 Flask talkKyiv.py #17 Flask talk
Kyiv.py #17 Flask talk
 
Building Cloud Castles
Building Cloud CastlesBuilding Cloud Castles
Building Cloud Castles
 
Laravel for Web Artisans
Laravel for Web ArtisansLaravel for Web Artisans
Laravel for Web Artisans
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Collaboration hack with slackbot - PyCon HK 2018 - 2018.11.24
Collaboration hack with slackbot - PyCon HK 2018 - 2018.11.24Collaboration hack with slackbot - PyCon HK 2018 - 2018.11.24
Collaboration hack with slackbot - PyCon HK 2018 - 2018.11.24
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
Symfony console: build awesome command line scripts with ease
Symfony console: build awesome command line scripts with easeSymfony console: build awesome command line scripts with ease
Symfony console: build awesome command line scripts with ease
 
Ecto and Phoenix: Doing web with Elixir - Yurii Bodarev
Ecto and Phoenix: Doing web with Elixir - Yurii BodarevEcto and Phoenix: Doing web with Elixir - Yurii Bodarev
Ecto and Phoenix: Doing web with Elixir - Yurii Bodarev
 
Ecto and Phoenix: Doing Web With Elixir
Ecto and Phoenix: Doing Web With ElixirEcto and Phoenix: Doing Web With Elixir
Ecto and Phoenix: Doing Web With Elixir
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in details
 
HotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePushHotPush with Ionic 2 and CodePush
HotPush with Ionic 2 and CodePush
 
Jakob Holderbaum - Managing Shared secrets using basic Unix tools
Jakob Holderbaum - Managing Shared secrets using basic Unix toolsJakob Holderbaum - Managing Shared secrets using basic Unix tools
Jakob Holderbaum - Managing Shared secrets using basic Unix tools
 
TYPO3 Scheduler
TYPO3 SchedulerTYPO3 Scheduler
TYPO3 Scheduler
 
Pluggin creation
Pluggin creationPluggin creation
Pluggin creation
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
Python Flask Tutorial For Beginners | Flask Web Development Tutorial | Python...
 
Migrating data to drupal 8
Migrating data to drupal 8Migrating data to drupal 8
Migrating data to drupal 8
 

More from Taien Wang

[MOPCON2019]從零建立商業技術團隊
[MOPCON2019]從零建立商業技術團隊[MOPCON2019]從零建立商業技術團隊
[MOPCON2019]從零建立商業技術團隊Taien Wang
 
[ModernWeb2019] Taien - 高併發的道與術
[ModernWeb2019] Taien - 高併發的道與術[ModernWeb2019] Taien - 高併發的道與術
[ModernWeb2019] Taien - 高併發的道與術Taien Wang
 
[ModernWeb2018] Web3.0 區塊鏈 DApp + 智能合約開發:你必要挑戰的坑坑洞洞
[ModernWeb2018] Web3.0 區塊鏈 DApp + 智能合約開發:你必要挑戰的坑坑洞洞[ModernWeb2018] Web3.0 區塊鏈 DApp + 智能合約開發:你必要挑戰的坑坑洞洞
[ModernWeb2018] Web3.0 區塊鏈 DApp + 智能合約開發:你必要挑戰的坑坑洞洞Taien Wang
 
百人團隊敏捷轉型暨持續性整合與交付實踐
百人團隊敏捷轉型暨持續性整合與交付實踐百人團隊敏捷轉型暨持續性整合與交付實踐
百人團隊敏捷轉型暨持續性整合與交付實踐Taien Wang
 
淡江Git與GitHub操作介紹
淡江Git與GitHub操作介紹淡江Git與GitHub操作介紹
淡江Git與GitHub操作介紹Taien Wang
 
成長駭客 Growth Hacker
成長駭客 Growth Hacker成長駭客 Growth Hacker
成長駭客 Growth HackerTaien Wang
 
20151229 wnmp & phalcon micro app - part I
20151229 wnmp & phalcon micro app - part I20151229 wnmp & phalcon micro app - part I
20151229 wnmp & phalcon micro app - part ITaien Wang
 
我編程.我快樂
我編程.我快樂我編程.我快樂
我編程.我快樂Taien Wang
 
Scrum深入淺出
Scrum深入淺出Scrum深入淺出
Scrum深入淺出Taien Wang
 
淡江大學 - 產品測試+安全性測試+壓力測試
淡江大學 - 產品測試+安全性測試+壓力測試淡江大學 - 產品測試+安全性測試+壓力測試
淡江大學 - 產品測試+安全性測試+壓力測試Taien Wang
 
淡江大學 - ios+android+html5(javascript)
淡江大學 - ios+android+html5(javascript)淡江大學 - ios+android+html5(javascript)
淡江大學 - ios+android+html5(javascript)Taien Wang
 
淡江大學 - 網站開發應用技術及雲端應用技術
淡江大學 - 網站開發應用技術及雲端應用技術淡江大學 - 網站開發應用技術及雲端應用技術
淡江大學 - 網站開發應用技術及雲端應用技術Taien Wang
 
Android Taipei 2013 August - Android Apps Security
Android Taipei 2013 August - Android Apps SecurityAndroid Taipei 2013 August - Android Apps Security
Android Taipei 2013 August - Android Apps SecurityTaien Wang
 
伺服器端攻擊與防禦III
伺服器端攻擊與防禦III伺服器端攻擊與防禦III
伺服器端攻擊與防禦IIITaien Wang
 
伺服器端攻擊與防禦II
伺服器端攻擊與防禦II伺服器端攻擊與防禦II
伺服器端攻擊與防禦IITaien Wang
 
伺服器端攻擊與防禦I
伺服器端攻擊與防禦I伺服器端攻擊與防禦I
伺服器端攻擊與防禦ITaien Wang
 
用戶端攻擊與防禦
用戶端攻擊與防禦用戶端攻擊與防禦
用戶端攻擊與防禦Taien Wang
 
使安全成為軟體開發必要部分
使安全成為軟體開發必要部分使安全成為軟體開發必要部分
使安全成為軟體開發必要部分Taien Wang
 
基礎網頁程式攻擊檢驗
基礎網頁程式攻擊檢驗基礎網頁程式攻擊檢驗
基礎網頁程式攻擊檢驗Taien Wang
 
PHP更有效率的除錯 - XDebug
PHP更有效率的除錯 - XDebugPHP更有效率的除錯 - XDebug
PHP更有效率的除錯 - XDebugTaien Wang
 

More from Taien Wang (20)

[MOPCON2019]從零建立商業技術團隊
[MOPCON2019]從零建立商業技術團隊[MOPCON2019]從零建立商業技術團隊
[MOPCON2019]從零建立商業技術團隊
 
[ModernWeb2019] Taien - 高併發的道與術
[ModernWeb2019] Taien - 高併發的道與術[ModernWeb2019] Taien - 高併發的道與術
[ModernWeb2019] Taien - 高併發的道與術
 
[ModernWeb2018] Web3.0 區塊鏈 DApp + 智能合約開發:你必要挑戰的坑坑洞洞
[ModernWeb2018] Web3.0 區塊鏈 DApp + 智能合約開發:你必要挑戰的坑坑洞洞[ModernWeb2018] Web3.0 區塊鏈 DApp + 智能合約開發:你必要挑戰的坑坑洞洞
[ModernWeb2018] Web3.0 區塊鏈 DApp + 智能合約開發:你必要挑戰的坑坑洞洞
 
百人團隊敏捷轉型暨持續性整合與交付實踐
百人團隊敏捷轉型暨持續性整合與交付實踐百人團隊敏捷轉型暨持續性整合與交付實踐
百人團隊敏捷轉型暨持續性整合與交付實踐
 
淡江Git與GitHub操作介紹
淡江Git與GitHub操作介紹淡江Git與GitHub操作介紹
淡江Git與GitHub操作介紹
 
成長駭客 Growth Hacker
成長駭客 Growth Hacker成長駭客 Growth Hacker
成長駭客 Growth Hacker
 
20151229 wnmp & phalcon micro app - part I
20151229 wnmp & phalcon micro app - part I20151229 wnmp & phalcon micro app - part I
20151229 wnmp & phalcon micro app - part I
 
我編程.我快樂
我編程.我快樂我編程.我快樂
我編程.我快樂
 
Scrum深入淺出
Scrum深入淺出Scrum深入淺出
Scrum深入淺出
 
淡江大學 - 產品測試+安全性測試+壓力測試
淡江大學 - 產品測試+安全性測試+壓力測試淡江大學 - 產品測試+安全性測試+壓力測試
淡江大學 - 產品測試+安全性測試+壓力測試
 
淡江大學 - ios+android+html5(javascript)
淡江大學 - ios+android+html5(javascript)淡江大學 - ios+android+html5(javascript)
淡江大學 - ios+android+html5(javascript)
 
淡江大學 - 網站開發應用技術及雲端應用技術
淡江大學 - 網站開發應用技術及雲端應用技術淡江大學 - 網站開發應用技術及雲端應用技術
淡江大學 - 網站開發應用技術及雲端應用技術
 
Android Taipei 2013 August - Android Apps Security
Android Taipei 2013 August - Android Apps SecurityAndroid Taipei 2013 August - Android Apps Security
Android Taipei 2013 August - Android Apps Security
 
伺服器端攻擊與防禦III
伺服器端攻擊與防禦III伺服器端攻擊與防禦III
伺服器端攻擊與防禦III
 
伺服器端攻擊與防禦II
伺服器端攻擊與防禦II伺服器端攻擊與防禦II
伺服器端攻擊與防禦II
 
伺服器端攻擊與防禦I
伺服器端攻擊與防禦I伺服器端攻擊與防禦I
伺服器端攻擊與防禦I
 
用戶端攻擊與防禦
用戶端攻擊與防禦用戶端攻擊與防禦
用戶端攻擊與防禦
 
使安全成為軟體開發必要部分
使安全成為軟體開發必要部分使安全成為軟體開發必要部分
使安全成為軟體開發必要部分
 
基礎網頁程式攻擊檢驗
基礎網頁程式攻擊檢驗基礎網頁程式攻擊檢驗
基礎網頁程式攻擊檢驗
 
PHP更有效率的除錯 - XDebug
PHP更有效率的除錯 - XDebugPHP更有效率的除錯 - XDebug
PHP更有效率的除錯 - XDebug
 

Recently uploaded

Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Fact vs. Fiction: Autodetecting Hallucinations in LLMs
Fact vs. Fiction: Autodetecting Hallucinations in LLMsFact vs. Fiction: Autodetecting Hallucinations in LLMs
Fact vs. Fiction: Autodetecting Hallucinations in LLMsZilliz
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your QueriesExploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your QueriesSanjay Willie
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 

Recently uploaded (20)

Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Fact vs. Fiction: Autodetecting Hallucinations in LLMs
Fact vs. Fiction: Autodetecting Hallucinations in LLMsFact vs. Fiction: Autodetecting Hallucinations in LLMs
Fact vs. Fiction: Autodetecting Hallucinations in LLMs
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your QueriesExploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 

WNMP & Phalcon Micro App

  • 1. 行動APP開發管理實務 WNMP & Phalcon Micro App – Part II 2016.01.05 @ 淡江大學商管B217 Taien Wang <taien_wang@hiiir.com> 時間軸科技股份有限公司
  • 2. Agenda • Part I – Windows • nginx • php • Phalcon • Part II – mysql – micro-restful api 2
  • 4. Phalcon • Download Phalcon form https://phalconphp.com/en/download/windows • Copy php_phalcon.dll to php extension dir – ex: C:webphpext • Modify the configuration from php.ini-development to php.ini – extension=php_phalcon.dll • Phalcon Dev Tool – Download: https://phalconphp.com/en/download/tools – Docs: https://docs.phalconphp.com/en/latest/reference/tools.html – Source: https://github.com/phalcon/phalcon-devtools 4
  • 5. Phalcon – Nginx configuration 5 source: https://docs.phalconphp.com/en/latest/reference/nginx.html
  • 6. Target - AddressBook API resource Method Raw Body select a contact addressbook/{Id} GET select multi contacts addressbook GET create contact addressbook POST {"name":"taien","mobile":"0912111 111"} modify contact addressbook/{Id} PUT {"name":"taien","mobile":"0912111 111"} delete contact addressbook/{Id} DELETE 6 URL:http://tku.api.taien.idv.tw:8080/
  • 7. Chrome extension - Postman 7
  • 8. MySQL • Download PHP form https://dev.mysql.com/downloads/mysql/ – mysql-installer-community-5.6.28.0.msi 8
  • 9. MySQL – License agreement 9
  • 10. MySQL – Choosing a setup type 10
  • 11. MySQL – Select products and features 11
  • 12. MySQL – Check requirements 12
  • 14. MySQL – Install complete 14
  • 15. MySQL – Product configuration 15
  • 16. MySQL – Type and networking 16
  • 17. MySQL – Accounts and roles 17
  • 18. MySQL – Window service 18
  • 19. MySQL – Advanced options 19
  • 20. MySQL – Apply server configuration 20
  • 21. MySQL – Apply server configuration finish 21
  • 22. MySQL – Product configuration 22
  • 23. MySQL – Installation complete 23
  • 24. MySQL – Create databases • mysql –h localhost –u root –p • CREATE DATABASE `tku-sample` CHARACTER SET utf8 COLLATE utf8_general_ci; • use `tku-sample`; • CREATE TABLE `addressbook` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) NOT NULL, `mobile` varchar(45) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; 24
  • 25. Windows Environment Variables • Environment Variables – Path • C:webphp;C:webnginx;C:webphalcon-devtools-master;C:Program FilesMySQLMySQL Server 5.7bin 25
  • 26. Phalcon Micro App Command • Create project – phalcon project tku --type=mirco • Setup DB in config/config.php • Create ORM model – phalcon model addressbook 26
  • 30. Phalcon Code - Hello TKU $app->get('/tku', function () use ($app) { echo "Hello, TKU!"; }); 30
  • 31. Phalcon Code - Select a contact $app->get('/addressbook/{addressbookId}', function ($addressbookId) use ($app) { $response = new Response(); $AddressBook = Addressbook::findFirst($addressbookId); $data = array(); if ($AddressBook) { $data["id"] = $AddressBook->id; $data["name"] = $AddressBook->name; $data["mobile"] = $AddressBook->mobile; echo json_encode($data); } else { $response->setStatusCode(404, "Not Found"); return $response; }}); 31
  • 32. Phalcon Code - Select multi contacts $app->get('/addressbook', function () use ($app) { $AddressBooks = Addressbook::find(); $data = array(); foreach ($AddressBooks as $AddressBook) { $data[] = array( 'id' => $AddressBook->id, 'name' => $AddressBook->name, 'mobile' => $AddressBook->mobile); } echo json_encode($data); }); 32
  • 33. Phalcon Code - Create contact $app->post('/addressbook', function () use ($app) { $response = new Response(); $bodyData = $app->request->getJsonRawBody(); $requestAry = json_decode(json_encode($bodyData), true); $AddressBook = new Addressbook; $AddressBook->name = $requestAry["name"]; $AddressBook->mobile = $requestAry["mobile"]; $result = $AddressBook->save(); if ($result) { $response->setStatusCode(201, "Created"); } else { $response->setStatusCode(500, "Internal Error"); } return $response; }); 33
  • 34. Phalcon Code - Modify contact $app->put('/addressbook/{addressbookId}', function ($addressbookId) use ($app) { $response = new Response(); $bodyData = $app->request->getJsonRawBody(); $requestAry = json_decode(json_encode($bodyData), true); $AddressBook = Addressbook::findFirst($addressbookId); if ($AddressBook) { $AddressBook->name = $requestAry["name"]; $AddressBook->mobile = $requestAry["mobile"]; $result = $AddressBook->save(); if ($result) { $response->setStatusCode(202, "Accepted"); } else { $response->setStatusCode(500, "Internal Error"); } } else { $response->setStatusCode(500, "Internal Error"); } return $response; }); 34
  • 35. Phalcon Code - Delete contact $app->delete('/addressbook/{addressbookId}', function ($addressbookId) use ($app) { $response = new Response(); $AddressBook = Addressbook::findFirst($addressbookId); if ($AddressBook) { $result = $AddressBook->delete(); if ($result) { $response->setStatusCode(202, "Accepted"); } else { $response->setStatusCode(500, "Internal Error"); } } else { $response->setStatusCode(500, "Internal Error"); } return $response; }); 35
  • 36. Mission • 20%: Select a contact • 20%: Select multi contact • 20%: Create a contact • 20%: Modify a contact • 20%: Delete a contact 36
  • 37. Mission - Select multi contact 37
  • 38. Mission - Select a contact 38
  • 39. Mission - Create a contact 39
  • 40. Mission – Modify a contact 40
  • 41. Mission – Delete a contact 41