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
How to be a better PHP Developer
Search
大澤木小鐵
January 12, 2013
Programming
39k
62
Share
How to be a better PHP Developer
WebConf Taiwan 2013 議程簡報
大澤木小鐵
January 12, 2013
More Decks by 大澤木小鐵
See All by 大澤木小鐵
Effective Unit Testing
jaceju
3
650
JSConf Asia 2014 Sessions
jaceju
4
450
What happens in Laravel 4 bootstraping
jaceju
9
600
Deal with Laravel assets by Bower & Gulp
jaceju
30
2.1k
Leaning MVC By Example
jaceju
0
430
ng-conf_2014
jaceju
2
1.1k
The Power of JavaScript in JSConf.Asia 2013
jaceju
5
440
jQuery vs AngularJS, dochi?
jaceju
20
3k
Begining Composer
jaceju
24
5.5k
Other Decks in Programming
See All in Programming
誰も頼んでない機能を出荷した話
zekutax
0
150
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
440
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
1.2k
OSもどきOS
arkw
0
370
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
4
1.2k
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
140
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
690
Modding RubyKaigi for Myself
yui_knk
0
840
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
560
LLM Plugin for Node-REDの利用方法と開発について
404background
0
150
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
290
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
220
Featured
See All Featured
Google's AI Overviews - The New Search
badams
0
1k
The agentic SEO stack - context over prompts
schlessera
0
790
Believing is Seeing
oripsolob
1
140
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
The SEO identity crisis: Don't let AI make you average
varn
0
480
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
120
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.8k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
380
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
160
Testing 201, or: Great Expectations
jmmastey
46
8.2k
How to train your dragon (web standard)
notwaldorf
97
6.6k
Evolving SEO for Evolving Search Engines
ryanjones
0
210
Transcript
jaceju@webconf 2013 如何成為更好的 PHP 開發者 磚業也要專業
Jace Ju 大澤木小鐵 http://plurk.com/jaceju http://twitter.com/jaceju http://weibo.com/jaceju http://www.jaceju.net
[email protected]
新浪微博軟體工程師 PHP
開發者
匠
牆
塌
老闆的想法
微薪 技佳
PHP 的困境 不需要高門檻 大量舊資訊充斥 社群過於多元化
捫心自問 我們真的瞭解 PHP 嗎 要不要繼續學 PHP
第一式 瞭解 PHP
門
瞭解新版本 4.x → 5.x http://php.net/manual/en/migration5.php 5.2 → 5.3 http://php.net/manual/en/migration53.php
瞭解運作環境 Error Reporting Session Save Path Web Server OS
瞭解執行模式 Web 執行模式 命令列執行模式
瞭解語法 // 交換變數內容 list($a, $b) = array($b, $a); // 直接取得指定位置的值
list( , $el) = getElements(); // PHP 5.4 :⽤用⽅方括號來直接取⽤用元素 $el = getElements()[1];
瞭解原生函式 // Bad $diff_ids = array(); foreach ($ids as $id)
{ if (!in_array($id, $actual_ids)) { $diff_ids[] = $id; } } // Good $diff_ids = array_diff($ids, $actual_ids);
瞭解技術原理������� HTTP 協定 資料庫存取 檔案存取 ...
學會 SPL 及內建介面 Standard PHP Library http://www.php.net/manual/en/book.spl.php Predefined Interfaces http://www.php.net/manual/en/reserved.interfaces.php
第二式 開發工具
編輯器 語法高亮度 自動完成 API 查詢 函式或類別方法的查找 其他工具的整合
NetBeans for PHP http://netbeans.org/
Eclipse PDT http://www.eclipse.org/projects/project.php?id=tools.pdt
除錯工具 中斷點設置 完整執行堆棧資訊 變數內容追蹤 .........
Xdebug http://xdebug.org/
FirePHP http://www.firephp.org/
版本控制 歷史紀錄 還原版本 解決衝突 支線版本
GitHub http://github.com/
Git 教育訓練課程投影片 http://ihower.tw/blog/archives/6696/
程式碼等級 一,,,要能對得起自己的良心 二,,,不能考驗測試人員的耐心 三,,,要能得到上頭的歡心 四,,,要能獲得客戶的信心 五,,,要能受到其他開發者的關心
第三式 成為團隊一份子
群
良好的程式架構 使用 Framework 減少溝通成本 減少開發成本
遵守編碼標準 統一團隊編碼風格 PHP-FIG https://github.com/php-fig/fig-standards
套件管理������� 避免套件散落各地 統一套件載入方式 Composer http://getcomposer.org/ https://packagist.org/
第四式 學會把程式寫活
Any fool can write code that a computer can understand.
Good programmers write code that humans can understand. Martin Fowler
以抽象角度看事物 // 找出特定作者的所有⽂文章 $sql = 'SELECT * FROM articles WHERE
'; $sql .= 'author = :author'; $sth = $dbh->prepare($sql); $sth->execute(array( ':author' => 'jaceju' )); $articles = $sth->fetchAll();
以抽象角度看事物 // 找出特定作者的所有⽂文章 $blog = new Blog(); $articles = $blog->fetchArticlesByAuthor('jaceju');
讓程式容易佈署 <?php include '/home/web/my/config.php';
讓程式容易佈署 <?php include __DIR__ . '/config.php'; // 假設 __DIR__ 在執⾏行時期的值為
// "/home/web/my"
一開始做對系統純屬神話 要將系統寫活來應付變化
組 合
讓系統可以被擴充 統一抽象介面 定義插入點 Template Method / Observer 模組化設計 管理�������介面
協
第五式 自我要求
注意安全 SQL Injection Cross Site Script (XSS) Cross Site Request
Forgery (CSRF)
Filter Input, Escape Output 不要信任瀏覽器所回傳的資訊 也不要直接輸出敏感的資訊
開發時嚴格 上線時寬鬆 解決掉所有警告與錯誤 隱藏但紀錄線上環境的 錯誤訊息
天下網站 無堅不摧 唯快不破
第六式 效能
原則 不做重複的事 放到背景執行 空間換取時間 執行路徑越短越好 保持輕量化 必要時才初始化 有異動才更新 資料少時全抓 資料多時分段抓
事先計算 善用快取
不做重複的事 function fib($n) { if ($n < 2) return $n;
$f[$n] = fib($n - 2) + fib($n - 1); return $f[$n]; } echo fib(30), "\n"; // 結果: 832040 ,共執⾏行 5.59556889534 秒
不做重複的事 function fib($n) { static $f = array(); if (isset($f[$n]))
return $f[$n]; if ($n < 2) return $n; $f[$n] = fib($n - 2) + fib($n - 1); return $f[$n]; } echo fib(30), "\n"; // 結果: 832040 ,共執⾏行 0.002144813537 秒
奧巴馬籌款網站的製作過程 http://www.ruanyifeng.com/blog/2012/12/ obama_fundraising_website.html
第七式 強健的程式碼
測試 確保系統舊有功能的完整 建立問題發生的情境
自動化測試框架 PHPUnit http://www.phpunit.de/ PHPSpec http://www.phpspec.net/ Behat http://behat.org/
重構 不是打掉重練 防止程式碼腐敗 搭配測試實行 Refactoring - Martin Fowler
第八式 不要只學寫程式碼
系統管理������� 系統安裝 Shell Script Service 管理������� 排程設定
學習使用雲端服務 AWS Linode Heroku ...
學習使用雲端服務 Hosting Plan http://blog.gslin.org/archives/2012/04/19/2865/ hosting-plan/ Startup : 如何挑選適合的 Hosting Plan?
http://blog.xdite.net/posts/2012/04/18/startup- hosting-plan/
學習其它語言 JavaScript (Browser) Perl / Python / Ruby / Node.js
C English
眼 神 死
關注國外資訊 PHP Master http://phpmaster.com/ nettuts+ http://net.tutsplus.com/category/tutorials/php/ PHP Mailing Lists http://php.net/mailing-lists.php
第九式 學會用輪子 也要學會造輪子
https://github.com/c9s c9s
PHPConf Taiwan 2013 http://phpconf.tw/
不要只問 自己勤練 真正的功夫
謝謝大家 版權所有.翻印必舊 - 定價 50 元 -