SlideShare a Scribd company logo
1 of 66
Download to read offline
5 Ways to Awesome-ize
Your (PHP) Code

Jeremy Kendall

Thursday, November 7, 13
Thursday, November 7, 13
I love to code

Thursday, November 7, 13
I love to code
I’m terribly forgetful

Thursday, November 7, 13
I love to code
I’m terribly forgetful
I take pictures

Thursday, November 7, 13
I love to code
I’m terribly forgetful
I take pictures
I work at OpenSky

Thursday, November 7, 13
What Are These 5 Ways of
Which You Speak?

Thursday, November 7, 13
Use Version Control

Thursday, November 7, 13
Use Version Control
‣

Thursday, November 7, 13

If you aren’t using version control, use git
Use Version Control
‣

If you aren’t using version control, use git
Install git

Thursday, November 7, 13
Use Version Control
‣

If you aren’t using version control, use git
Install git
cd /path/to/project

Thursday, November 7, 13
Use Version Control
‣

If you aren’t using version control, use git
Install git
cd /path/to/project
git init

Thursday, November 7, 13
Use Version Control
‣

If you aren’t using version control, use git
Install git
cd /path/to/project
git init
git add .

Thursday, November 7, 13
Use Version Control
‣

If you aren’t using version control, use git
Install git
cd /path/to/project
git init
git add .
git commit -m “Just saved the company”

Thursday, November 7, 13
Use Version Control
‣

If you aren’t using version control, use git
Install git
cd /path/to/project
git init
git add .
git commit -m “Just saved the company”

‣
Thursday, November 7, 13

Interactive tutorial at http://try.github.io
or Else . . .

Thursday, November 7, 13
Error Reporting: Turn it Up!

Thursday, November 7, 13
Error Reporting: Turn it Up!
‣

Thursday, November 7, 13

Turn error reporting all the way up in dev
Error Reporting: Turn it Up!
‣
Helps find existing problems
‣

Turn error reporting all the way up in dev

Thursday, November 7, 13
Error Reporting: Turn it Up!
‣
Helps find existing problems
‣
Helps head off future pain
‣

Turn error reporting all the way up in dev

Thursday, November 7, 13
Error Reporting: Turn it Up!
‣
Helps find existing problems
‣
Helps head off future pain
‣
Don’t say it’s just an E_NOTICE . . .
‣

Turn error reporting all the way up in dev

Thursday, November 7, 13
Error Reporting: Turn it Up!
‣
Helps find existing problems
‣
Helps head off future pain
‣
Don’t say it’s just an E_NOTICE . . .
‣

Turn error reporting all the way up in dev

Thursday, November 7, 13
Error Reporting: Dev
display_errors = On
display_startup_errors = On
error_reporting = -1
log_errors = On

Thursday, November 7, 13
Error Reporting: Prod
display_errors = Off
display_startup_errors = Off
error_reporting = E_ALL
log_errors = On

Thursday, November 7, 13
Ditch NIH

Thursday, November 7, 13
Ditch NIH
‣

Thursday, November 7, 13

If you write it all yourself . . .
Ditch NIH
‣
. . . you maintain it all yourself
‣
If you write it all yourself . . .

Thursday, November 7, 13
Ditch NIH
‣
. . . you maintain it all yourself
‣
Eventually you have very little time for either . . .
‣
If you write it all yourself . . .

Thursday, November 7, 13
Real, Actual Work

Thursday, November 7, 13
Real, Actual Work

Thursday, November 7, 13
A Life

Thursday, November 7, 13
Ditch NIH

Thursday, November 7, 13
Ditch NIH
‣

Thursday, November 7, 13

Offload work to the open source community
Ditch NIH
‣
Install Composer (http://getcomposer.org)
‣

Offload work to the open source community

Thursday, November 7, 13
Ditch NIH
‣
Install Composer (http://getcomposer.org)
‣
Search Packagist (http://packagist.org)
‣

Offload work to the open source community

Thursday, November 7, 13
Ditch NIH
‣
Install Composer (http://getcomposer.org)
‣
Search Packagist (http://packagist.org)
‣
Add dependency to composer.json
‣

Offload work to the open source community

Thursday, November 7, 13
Ditch NIH
‣
Install Composer (http://getcomposer.org)
‣
Search Packagist (http://packagist.org)
‣
Add dependency to composer.json
‣
Run composer install or composer update
‣
Offload work to the open source community

Thursday, November 7, 13
Ditch NIH
‣
Install Composer (http://getcomposer.org)
‣
Search Packagist (http://packagist.org)
‣
Add dependency to composer.json
‣
Run composer install or composer update
‣
Everyone needs logging. Go install monolog.
‣
Offload work to the open source community

Thursday, November 7, 13
DRY Up Your DB

Thursday, November 7, 13
DRY Up Your DB
‣

Thursday, November 7, 13

If you’re not using PDO, switch now.
DRY Up Your DB
‣
If you’re not using prepared statements, switch now.
‣
If you’re not using PDO, switch now.

Thursday, November 7, 13
DRY Up Your DB
‣
If you’re not using prepared statements, switch now.
‣
Replace connections and queries one at a time
‣
If you’re not using PDO, switch now.

Thursday, November 7, 13
DRY Up Your DB
‣
If you’re not using prepared statements, switch now.
‣
Replace connections and queries one at a time
‣
(or one group at a time)
‣
If you’re not using PDO, switch now.

Thursday, November 7, 13
DRY Up Your DB
‣
If you’re not using prepared statements, switch now.
‣
Replace connections and queries one at a time
‣
(or one group at a time)
‣
Combine with simple data access objects
‣
If you’re not using PDO, switch now.

Thursday, November 7, 13
DRY Up Your DB
class UserDao
{
protected $db;
public function __construct(PDO $db)
{
$this->db = $db;
}
public function find($id)
{
$sql = 'SELECT * FROM users WHERE id = :id';
$stmt = $this->db->prepare($sql);
$stmt->bindValue(':id', $id);
$stmt->execute();
return $stmt->fetch();
}
}

Thursday, November 7, 13
DRY Up Your DB
class UserDao
{
protected $db;
public function __construct(PDO $db)
{
$this->db = $db;
}
public function find($id)
{
$sql = 'SELECT * FROM users WHERE id = :id';
$stmt = $this->db->prepare($sql);
$stmt->bindValue(':id', $id);
$stmt->execute();
return $stmt->fetch();
}
}

Thursday, November 7, 13
DRY Up Your DB
class UserDao
{
protected $db;
public function __construct(PDO $db)
{
$this->db = $db;
}
public function find($id)
{
$sql = 'SELECT * FROM users WHERE id = :id';
$stmt = $this->db->prepare($sql);
$stmt->bindValue(':id', $id);
$stmt->execute();
return $stmt->fetch();
}
}

Thursday, November 7, 13
DRY Up Your DB
class UserDao
{
protected $db;
public function __construct(PDO $db)
{
$this->db = $db;
}
public function find($id)
{
$sql = 'SELECT * FROM users WHERE id = :id';
$stmt = $this->db->prepare($sql);
$stmt->bindValue(':id', $id);
$stmt->execute();
return $stmt->fetch();
}
}

Thursday, November 7, 13
DRY Up Your DB
class UserDao
{
protected $db;
public function __construct(PDO $db)
{
$this->db = $db;
}
public function find($id)
{
$sql = 'SELECT * FROM users WHERE id = :id';
$stmt = $this->db->prepare($sql);
$stmt->bindValue(':id', $id);
$stmt->execute();
return $stmt->fetch();
}
}

Thursday, November 7, 13
Or Just Pick Something
from Packagist

Thursday, November 7, 13
Start Writing Beautiful Code

Thursday, November 7, 13
Start Writing Beautiful Code
‣

Thursday, November 7, 13

It’s time for a coding standard!
Start Writing Beautiful Code
‣
Makes life so much easier
‣

It’s time for a coding standard!

Thursday, November 7, 13
Start Writing Beautiful Code
‣
Makes life so much easier
‣
Pick someone else’s
‣

It’s time for a coding standard!

Thursday, November 7, 13
Start Writing Beautiful Code
‣
Makes life so much easier
‣
Pick someone else’s
‣
Use automated tools to enforce
‣
It’s time for a coding standard!

Thursday, November 7, 13
Start Writing Beautiful Code
‣
Makes life so much easier
‣
Pick someone else’s
‣
Use automated tools to enforce
‣
php-cs-fixer
‣
It’s time for a coding standard!

Thursday, November 7, 13
Start Writing Beautiful Code
‣
Makes life so much easier
‣
Pick someone else’s
‣
Use automated tools to enforce
‣
php-cs-fixer
‣
PHP_CodeSniffer
‣
It’s time for a coding standard!

Thursday, November 7, 13
Start Writing Beautiful Code
‣
Makes life so much easier
‣
Pick someone else’s
‣
Use automated tools to enforce
‣
php-cs-fixer
‣
PHP_CodeSniffer
‣
Refactor bit-by-bit
‣
It’s time for a coding standard!

Thursday, November 7, 13
Bonus!

Thursday, November 7, 13
PHP: The Right Way

Thursday, November 7, 13
PHP: The Right Way
‣

Thursday, November 7, 13

Go to http://www.phptherightway.com/
PHP: The Right Way
‣
Start reading
‣

Go to http://www.phptherightway.com/

Thursday, November 7, 13
PHP: The Right Way
‣
Start reading
‣
Don’t stop reading
‣

Go to http://www.phptherightway.com/

Thursday, November 7, 13
PHP: The Right Way
‣
Start reading
‣
Don’t stop reading
‣
Do it “The Right Way” for 6 months
‣

Go to http://www.phptherightway.com/

Thursday, November 7, 13
PHP: The Right Way
‣
Start reading
‣
Don’t stop reading
‣
Do it “The Right Way” for 6 months
‣
Then pick and choose
‣

Go to http://www.phptherightway.com/

Thursday, November 7, 13
Thanks!
jeremy@jeremykendall.net
http://about.me/jeremykendall
@jeremykendall
http://365.jeremykendall.net

Thursday, November 7, 13

More Related Content

What's hot

Drupal Development : Tools, Tips, and Tricks
Drupal Development : Tools, Tips, and TricksDrupal Development : Tools, Tips, and Tricks
Drupal Development : Tools, Tips, and TricksGerald Villorente
 
There's Nothing so Permanent as Temporary
There's Nothing so Permanent as TemporaryThere's Nothing so Permanent as Temporary
There's Nothing so Permanent as TemporaryPositive Hack Days
 
Bo0oM - There's Nothing so Permanent as Temporary (PHDays IV, 2014)
Bo0oM - There's Nothing so Permanent as Temporary (PHDays IV, 2014)Bo0oM - There's Nothing so Permanent as Temporary (PHDays IV, 2014)
Bo0oM - There's Nothing so Permanent as Temporary (PHDays IV, 2014)Дмитрий Бумов
 
44CON London 2015 - reverse reverse engineering
44CON London 2015 - reverse reverse engineering44CON London 2015 - reverse reverse engineering
44CON London 2015 - reverse reverse engineering44CON
 
Developing OpenResty Framework
Developing OpenResty FrameworkDeveloping OpenResty Framework
Developing OpenResty FrameworkAapo Talvensaari
 
Palm Developer Day PhoneGap
Palm Developer Day PhoneGap Palm Developer Day PhoneGap
Palm Developer Day PhoneGap Brian LeRoux
 
Ember.js Module Loading
Ember.js Module LoadingEmber.js Module Loading
Ember.js Module LoadingMatthew Beale
 
Using React for the Mobile Web
Using React for the Mobile WebUsing React for the Mobile Web
Using React for the Mobile WebC4Media
 
徒手打造自己的粉專客服機器人
徒手打造自己的粉專客服機器人 徒手打造自己的粉專客服機器人
徒手打造自己的粉專客服機器人 Sasaya Hu
 
톰캣 #02-설치환경
톰캣 #02-설치환경톰캣 #02-설치환경
톰캣 #02-설치환경GyuSeok Lee
 
Updates on Offline: “My AppCache won’t come back” and “ServiceWorker Tricks ...
Updates on Offline: “My AppCache won’t come back” and  “ServiceWorker Tricks ...Updates on Offline: “My AppCache won’t come back” and  “ServiceWorker Tricks ...
Updates on Offline: “My AppCache won’t come back” and “ServiceWorker Tricks ...Natasha Rooney
 
Be a microservices hero
Be a microservices heroBe a microservices hero
Be a microservices heroOpenRestyCon
 
Debugging PHP With Xdebug
Debugging PHP With XdebugDebugging PHP With Xdebug
Debugging PHP With XdebugMark Niebergall
 
Angular js活用事例:filydoc
Angular js活用事例:filydocAngular js活用事例:filydoc
Angular js活用事例:filydocKeiichi Kobayashi
 
W.E.B. 2010 - Web, Exploits, Browsers
W.E.B. 2010 - Web, Exploits, BrowsersW.E.B. 2010 - Web, Exploits, Browsers
W.E.B. 2010 - Web, Exploits, BrowsersSaumil Shah
 

What's hot (20)

Drupal Development : Tools, Tips, and Tricks
Drupal Development : Tools, Tips, and TricksDrupal Development : Tools, Tips, and Tricks
Drupal Development : Tools, Tips, and Tricks
 
There's Nothing so Permanent as Temporary
There's Nothing so Permanent as TemporaryThere's Nothing so Permanent as Temporary
There's Nothing so Permanent as Temporary
 
Bo0oM - There's Nothing so Permanent as Temporary (PHDays IV, 2014)
Bo0oM - There's Nothing so Permanent as Temporary (PHDays IV, 2014)Bo0oM - There's Nothing so Permanent as Temporary (PHDays IV, 2014)
Bo0oM - There's Nothing so Permanent as Temporary (PHDays IV, 2014)
 
Transforming WebSockets
Transforming WebSocketsTransforming WebSockets
Transforming WebSockets
 
44CON London 2015 - reverse reverse engineering
44CON London 2015 - reverse reverse engineering44CON London 2015 - reverse reverse engineering
44CON London 2015 - reverse reverse engineering
 
Developing OpenResty Framework
Developing OpenResty FrameworkDeveloping OpenResty Framework
Developing OpenResty Framework
 
Front-end tools
Front-end toolsFront-end tools
Front-end tools
 
Palm Developer Day PhoneGap
Palm Developer Day PhoneGap Palm Developer Day PhoneGap
Palm Developer Day PhoneGap
 
Introduction to Kalabox
Introduction to KalaboxIntroduction to Kalabox
Introduction to Kalabox
 
Ember.js Module Loading
Ember.js Module LoadingEmber.js Module Loading
Ember.js Module Loading
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIs
 
Using React for the Mobile Web
Using React for the Mobile WebUsing React for the Mobile Web
Using React for the Mobile Web
 
徒手打造自己的粉專客服機器人
徒手打造自己的粉專客服機器人 徒手打造自己的粉專客服機器人
徒手打造自己的粉專客服機器人
 
톰캣 #02-설치환경
톰캣 #02-설치환경톰캣 #02-설치환경
톰캣 #02-설치환경
 
Updates on Offline: “My AppCache won’t come back” and “ServiceWorker Tricks ...
Updates on Offline: “My AppCache won’t come back” and  “ServiceWorker Tricks ...Updates on Offline: “My AppCache won’t come back” and  “ServiceWorker Tricks ...
Updates on Offline: “My AppCache won’t come back” and “ServiceWorker Tricks ...
 
Be a microservices hero
Be a microservices heroBe a microservices hero
Be a microservices hero
 
Drupal Development Tips
Drupal Development TipsDrupal Development Tips
Drupal Development Tips
 
Debugging PHP With Xdebug
Debugging PHP With XdebugDebugging PHP With Xdebug
Debugging PHP With Xdebug
 
Angular js活用事例:filydoc
Angular js活用事例:filydocAngular js活用事例:filydoc
Angular js活用事例:filydoc
 
W.E.B. 2010 - Web, Exploits, Browsers
W.E.B. 2010 - Web, Exploits, BrowsersW.E.B. 2010 - Web, Exploits, Browsers
W.E.B. 2010 - Web, Exploits, Browsers
 

Viewers also liked

PHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBeneluxPHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBeneluxNick Belhomme
 
Chatbot in Sale Management
Chatbot in Sale ManagementChatbot in Sale Management
Chatbot in Sale ManagementVõ Duy Tuấn
 
Php & mysql course syllabus
Php & mysql course syllabusPhp & mysql course syllabus
Php & mysql course syllabusPapitha Velumani
 
complete Php code for a project .... (hospital management system)
complete Php code for a project .... (hospital management system)complete Php code for a project .... (hospital management system)
complete Php code for a project .... (hospital management system)Iftikhar Ahmad
 
ONLINE COMPLAINT MANAGEMENT SYSTEM
ONLINE COMPLAINT MANAGEMENT SYSTEMONLINE COMPLAINT MANAGEMENT SYSTEM
ONLINE COMPLAINT MANAGEMENT SYSTEMHimanshu Chaurishiya
 

Viewers also liked (7)

PHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBeneluxPHP Quality Assurance Workshop PHPBenelux
PHP Quality Assurance Workshop PHPBenelux
 
Chatbot in Sale Management
Chatbot in Sale ManagementChatbot in Sale Management
Chatbot in Sale Management
 
Composer
ComposerComposer
Composer
 
Php & mysql course syllabus
Php & mysql course syllabusPhp & mysql course syllabus
Php & mysql course syllabus
 
complete Php code for a project .... (hospital management system)
complete Php code for a project .... (hospital management system)complete Php code for a project .... (hospital management system)
complete Php code for a project .... (hospital management system)
 
Project on PHP for Complaint management system
Project on PHP for Complaint management systemProject on PHP for Complaint management system
Project on PHP for Complaint management system
 
ONLINE COMPLAINT MANAGEMENT SYSTEM
ONLINE COMPLAINT MANAGEMENT SYSTEMONLINE COMPLAINT MANAGEMENT SYSTEM
ONLINE COMPLAINT MANAGEMENT SYSTEM
 

Similar to 5 Ways to Awesome-ize Your (PHP) Code

Android Design: Beyond the Guidelines
Android Design: Beyond the GuidelinesAndroid Design: Beyond the Guidelines
Android Design: Beyond the Guidelineskevingrant5
 
Multiplatform, Promises and HTML5
Multiplatform, Promises and HTML5Multiplatform, Promises and HTML5
Multiplatform, Promises and HTML5C4Media
 
deSymfony 2012 - El entorno de Symfony2
deSymfony 2012 - El entorno de Symfony2deSymfony 2012 - El entorno de Symfony2
deSymfony 2012 - El entorno de Symfony2Albert Jessurum
 
TDD with LEGO at SDEC13
TDD with LEGO at SDEC13TDD with LEGO at SDEC13
TDD with LEGO at SDEC13BillyGarnet
 
What Ops Can Learn From Design
What Ops Can Learn From DesignWhat Ops Can Learn From Design
What Ops Can Learn From DesignRobert Treat
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkJeremy Kendall
 
3 reasons to contribute to drupal florian loretan (eng)
3 reasons to contribute to drupal florian loretan (eng)3 reasons to contribute to drupal florian loretan (eng)
3 reasons to contribute to drupal florian loretan (eng)drupalconf
 
Software Libraries And Numbers
Software Libraries And NumbersSoftware Libraries And Numbers
Software Libraries And NumbersRobert Reiz
 
[Nuxeo World 2013] MARKETPLACE PACKAGES - THIBAUD ARGUILLERE
[Nuxeo World 2013] MARKETPLACE PACKAGES - THIBAUD ARGUILLERE[Nuxeo World 2013] MARKETPLACE PACKAGES - THIBAUD ARGUILLERE
[Nuxeo World 2013] MARKETPLACE PACKAGES - THIBAUD ARGUILLERENuxeo
 
Writing SaltStack Modules - OpenWest 2013
Writing SaltStack Modules - OpenWest 2013Writing SaltStack Modules - OpenWest 2013
Writing SaltStack Modules - OpenWest 2013SaltStack
 
Bankers Association Communications Conference Deck
 Bankers Association Communications Conference Deck Bankers Association Communications Conference Deck
Bankers Association Communications Conference DeckHodges_Digital
 
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...Pablo Godel
 
Show an Open Source Project Some Love and Start Using Travis-CI
Show an Open Source Project Some Love and Start Using Travis-CIShow an Open Source Project Some Love and Start Using Travis-CI
Show an Open Source Project Some Love and Start Using Travis-CIJoel Byler
 
Some simple tips for front-end performance in WordPress
Some simple tips for front-end performance in WordPressSome simple tips for front-end performance in WordPress
Some simple tips for front-end performance in WordPressiparr
 
Slaying Bugs with Gradle and Jenkins
Slaying Bugs with Gradle and JenkinsSlaying Bugs with Gradle and Jenkins
Slaying Bugs with Gradle and JenkinsDavid Kay
 
Lessons I Learned While Scaling to 5000 Puppet Agents
Lessons I Learned While Scaling to 5000 Puppet AgentsLessons I Learned While Scaling to 5000 Puppet Agents
Lessons I Learned While Scaling to 5000 Puppet AgentsPuppet
 

Similar to 5 Ways to Awesome-ize Your (PHP) Code (20)

Android Design: Beyond the Guidelines
Android Design: Beyond the GuidelinesAndroid Design: Beyond the Guidelines
Android Design: Beyond the Guidelines
 
Multiplatform, Promises and HTML5
Multiplatform, Promises and HTML5Multiplatform, Promises and HTML5
Multiplatform, Promises and HTML5
 
deSymfony 2012 - El entorno de Symfony2
deSymfony 2012 - El entorno de Symfony2deSymfony 2012 - El entorno de Symfony2
deSymfony 2012 - El entorno de Symfony2
 
TDD with LEGO at SDEC13
TDD with LEGO at SDEC13TDD with LEGO at SDEC13
TDD with LEGO at SDEC13
 
What Ops Can Learn From Design
What Ops Can Learn From DesignWhat Ops Can Learn From Design
What Ops Can Learn From Design
 
Keeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
 
SPRINT3R-SWPSDLC2556-CLOSING
SPRINT3R-SWPSDLC2556-CLOSINGSPRINT3R-SWPSDLC2556-CLOSING
SPRINT3R-SWPSDLC2556-CLOSING
 
3 reasons to contribute to drupal florian loretan (eng)
3 reasons to contribute to drupal florian loretan (eng)3 reasons to contribute to drupal florian loretan (eng)
3 reasons to contribute to drupal florian loretan (eng)
 
Software Libraries And Numbers
Software Libraries And NumbersSoftware Libraries And Numbers
Software Libraries And Numbers
 
[Nuxeo World 2013] MARKETPLACE PACKAGES - THIBAUD ARGUILLERE
[Nuxeo World 2013] MARKETPLACE PACKAGES - THIBAUD ARGUILLERE[Nuxeo World 2013] MARKETPLACE PACKAGES - THIBAUD ARGUILLERE
[Nuxeo World 2013] MARKETPLACE PACKAGES - THIBAUD ARGUILLERE
 
Writing SaltStack Modules - OpenWest 2013
Writing SaltStack Modules - OpenWest 2013Writing SaltStack Modules - OpenWest 2013
Writing SaltStack Modules - OpenWest 2013
 
When Tdd Goes Awry
When Tdd Goes AwryWhen Tdd Goes Awry
When Tdd Goes Awry
 
13 Ddply
13 Ddply13 Ddply
13 Ddply
 
Bankers Association Communications Conference Deck
 Bankers Association Communications Conference Deck Bankers Association Communications Conference Deck
Bankers Association Communications Conference Deck
 
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
 
Show an Open Source Project Some Love and Start Using Travis-CI
Show an Open Source Project Some Love and Start Using Travis-CIShow an Open Source Project Some Love and Start Using Travis-CI
Show an Open Source Project Some Love and Start Using Travis-CI
 
Behat
BehatBehat
Behat
 
Some simple tips for front-end performance in WordPress
Some simple tips for front-end performance in WordPressSome simple tips for front-end performance in WordPress
Some simple tips for front-end performance in WordPress
 
Slaying Bugs with Gradle and Jenkins
Slaying Bugs with Gradle and JenkinsSlaying Bugs with Gradle and Jenkins
Slaying Bugs with Gradle and Jenkins
 
Lessons I Learned While Scaling to 5000 Puppet Agents
Lessons I Learned While Scaling to 5000 Puppet AgentsLessons I Learned While Scaling to 5000 Puppet Agents
Lessons I Learned While Scaling to 5000 Puppet Agents
 

More from Jeremy Kendall

Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPJeremy Kendall
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPJeremy Kendall
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodJeremy Kendall
 
Keeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkJeremy Kendall
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkJeremy Kendall
 
PHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the GoodPHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the GoodJeremy Kendall
 
Intro to #memtech PHP 2011-12-05
Intro to #memtech PHP   2011-12-05Intro to #memtech PHP   2011-12-05
Intro to #memtech PHP 2011-12-05Jeremy Kendall
 
TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25Jeremy Kendall
 
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
Zend_Form to the Rescue - A Brief Introduction to Zend_FormZend_Form to the Rescue - A Brief Introduction to Zend_Form
Zend_Form to the Rescue - A Brief Introduction to Zend_FormJeremy Kendall
 
Zero to ZF in 10 Minutes
Zero to ZF in 10 MinutesZero to ZF in 10 Minutes
Zero to ZF in 10 MinutesJeremy Kendall
 
Tdd in php a brief example
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief exampleJeremy Kendall
 
A Brief Introduction to Zend_Form
A Brief Introduction to Zend_FormA Brief Introduction to Zend_Form
A Brief Introduction to Zend_FormJeremy Kendall
 
Zero to Zend Framework in 10 minutes
Zero to Zend Framework in 10 minutesZero to Zend Framework in 10 minutes
Zero to Zend Framework in 10 minutesJeremy Kendall
 

More from Jeremy Kendall (14)

Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Leveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHPLeveraging the Power of Graph Databases in PHP
Leveraging the Power of Graph Databases in PHP
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
 
Keeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro Framework
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro framework
 
Php 101: PDO
Php 101: PDOPhp 101: PDO
Php 101: PDO
 
PHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the GoodPHP 102: Out with the Bad, In with the Good
PHP 102: Out with the Bad, In with the Good
 
Intro to #memtech PHP 2011-12-05
Intro to #memtech PHP   2011-12-05Intro to #memtech PHP   2011-12-05
Intro to #memtech PHP 2011-12-05
 
TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25TDD in PHP - Memphis PHP 2011-08-25
TDD in PHP - Memphis PHP 2011-08-25
 
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
Zend_Form to the Rescue - A Brief Introduction to Zend_FormZend_Form to the Rescue - A Brief Introduction to Zend_Form
Zend_Form to the Rescue - A Brief Introduction to Zend_Form
 
Zero to ZF in 10 Minutes
Zero to ZF in 10 MinutesZero to ZF in 10 Minutes
Zero to ZF in 10 Minutes
 
Tdd in php a brief example
Tdd in php   a brief exampleTdd in php   a brief example
Tdd in php a brief example
 
A Brief Introduction to Zend_Form
A Brief Introduction to Zend_FormA Brief Introduction to Zend_Form
A Brief Introduction to Zend_Form
 
Zero to Zend Framework in 10 minutes
Zero to Zend Framework in 10 minutesZero to Zend Framework in 10 minutes
Zero to Zend Framework in 10 minutes
 

Recently uploaded

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 

Recently uploaded (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

5 Ways to Awesome-ize Your (PHP) Code

  • 1. 5 Ways to Awesome-ize Your (PHP) Code Jeremy Kendall Thursday, November 7, 13
  • 3. I love to code Thursday, November 7, 13
  • 4. I love to code I’m terribly forgetful Thursday, November 7, 13
  • 5. I love to code I’m terribly forgetful I take pictures Thursday, November 7, 13
  • 6. I love to code I’m terribly forgetful I take pictures I work at OpenSky Thursday, November 7, 13
  • 7. What Are These 5 Ways of Which You Speak? Thursday, November 7, 13
  • 9. Use Version Control ‣ Thursday, November 7, 13 If you aren’t using version control, use git
  • 10. Use Version Control ‣ If you aren’t using version control, use git Install git Thursday, November 7, 13
  • 11. Use Version Control ‣ If you aren’t using version control, use git Install git cd /path/to/project Thursday, November 7, 13
  • 12. Use Version Control ‣ If you aren’t using version control, use git Install git cd /path/to/project git init Thursday, November 7, 13
  • 13. Use Version Control ‣ If you aren’t using version control, use git Install git cd /path/to/project git init git add . Thursday, November 7, 13
  • 14. Use Version Control ‣ If you aren’t using version control, use git Install git cd /path/to/project git init git add . git commit -m “Just saved the company” Thursday, November 7, 13
  • 15. Use Version Control ‣ If you aren’t using version control, use git Install git cd /path/to/project git init git add . git commit -m “Just saved the company” ‣ Thursday, November 7, 13 Interactive tutorial at http://try.github.io
  • 16. or Else . . . Thursday, November 7, 13
  • 17. Error Reporting: Turn it Up! Thursday, November 7, 13
  • 18. Error Reporting: Turn it Up! ‣ Thursday, November 7, 13 Turn error reporting all the way up in dev
  • 19. Error Reporting: Turn it Up! ‣ Helps find existing problems ‣ Turn error reporting all the way up in dev Thursday, November 7, 13
  • 20. Error Reporting: Turn it Up! ‣ Helps find existing problems ‣ Helps head off future pain ‣ Turn error reporting all the way up in dev Thursday, November 7, 13
  • 21. Error Reporting: Turn it Up! ‣ Helps find existing problems ‣ Helps head off future pain ‣ Don’t say it’s just an E_NOTICE . . . ‣ Turn error reporting all the way up in dev Thursday, November 7, 13
  • 22. Error Reporting: Turn it Up! ‣ Helps find existing problems ‣ Helps head off future pain ‣ Don’t say it’s just an E_NOTICE . . . ‣ Turn error reporting all the way up in dev Thursday, November 7, 13
  • 23. Error Reporting: Dev display_errors = On display_startup_errors = On error_reporting = -1 log_errors = On Thursday, November 7, 13
  • 24. Error Reporting: Prod display_errors = Off display_startup_errors = Off error_reporting = E_ALL log_errors = On Thursday, November 7, 13
  • 26. Ditch NIH ‣ Thursday, November 7, 13 If you write it all yourself . . .
  • 27. Ditch NIH ‣ . . . you maintain it all yourself ‣ If you write it all yourself . . . Thursday, November 7, 13
  • 28. Ditch NIH ‣ . . . you maintain it all yourself ‣ Eventually you have very little time for either . . . ‣ If you write it all yourself . . . Thursday, November 7, 13
  • 29. Real, Actual Work Thursday, November 7, 13
  • 30. Real, Actual Work Thursday, November 7, 13
  • 33. Ditch NIH ‣ Thursday, November 7, 13 Offload work to the open source community
  • 34. Ditch NIH ‣ Install Composer (http://getcomposer.org) ‣ Offload work to the open source community Thursday, November 7, 13
  • 35. Ditch NIH ‣ Install Composer (http://getcomposer.org) ‣ Search Packagist (http://packagist.org) ‣ Offload work to the open source community Thursday, November 7, 13
  • 36. Ditch NIH ‣ Install Composer (http://getcomposer.org) ‣ Search Packagist (http://packagist.org) ‣ Add dependency to composer.json ‣ Offload work to the open source community Thursday, November 7, 13
  • 37. Ditch NIH ‣ Install Composer (http://getcomposer.org) ‣ Search Packagist (http://packagist.org) ‣ Add dependency to composer.json ‣ Run composer install or composer update ‣ Offload work to the open source community Thursday, November 7, 13
  • 38. Ditch NIH ‣ Install Composer (http://getcomposer.org) ‣ Search Packagist (http://packagist.org) ‣ Add dependency to composer.json ‣ Run composer install or composer update ‣ Everyone needs logging. Go install monolog. ‣ Offload work to the open source community Thursday, November 7, 13
  • 39. DRY Up Your DB Thursday, November 7, 13
  • 40. DRY Up Your DB ‣ Thursday, November 7, 13 If you’re not using PDO, switch now.
  • 41. DRY Up Your DB ‣ If you’re not using prepared statements, switch now. ‣ If you’re not using PDO, switch now. Thursday, November 7, 13
  • 42. DRY Up Your DB ‣ If you’re not using prepared statements, switch now. ‣ Replace connections and queries one at a time ‣ If you’re not using PDO, switch now. Thursday, November 7, 13
  • 43. DRY Up Your DB ‣ If you’re not using prepared statements, switch now. ‣ Replace connections and queries one at a time ‣ (or one group at a time) ‣ If you’re not using PDO, switch now. Thursday, November 7, 13
  • 44. DRY Up Your DB ‣ If you’re not using prepared statements, switch now. ‣ Replace connections and queries one at a time ‣ (or one group at a time) ‣ Combine with simple data access objects ‣ If you’re not using PDO, switch now. Thursday, November 7, 13
  • 45. DRY Up Your DB class UserDao { protected $db; public function __construct(PDO $db) { $this->db = $db; } public function find($id) { $sql = 'SELECT * FROM users WHERE id = :id'; $stmt = $this->db->prepare($sql); $stmt->bindValue(':id', $id); $stmt->execute(); return $stmt->fetch(); } } Thursday, November 7, 13
  • 46. DRY Up Your DB class UserDao { protected $db; public function __construct(PDO $db) { $this->db = $db; } public function find($id) { $sql = 'SELECT * FROM users WHERE id = :id'; $stmt = $this->db->prepare($sql); $stmt->bindValue(':id', $id); $stmt->execute(); return $stmt->fetch(); } } Thursday, November 7, 13
  • 47. DRY Up Your DB class UserDao { protected $db; public function __construct(PDO $db) { $this->db = $db; } public function find($id) { $sql = 'SELECT * FROM users WHERE id = :id'; $stmt = $this->db->prepare($sql); $stmt->bindValue(':id', $id); $stmt->execute(); return $stmt->fetch(); } } Thursday, November 7, 13
  • 48. DRY Up Your DB class UserDao { protected $db; public function __construct(PDO $db) { $this->db = $db; } public function find($id) { $sql = 'SELECT * FROM users WHERE id = :id'; $stmt = $this->db->prepare($sql); $stmt->bindValue(':id', $id); $stmt->execute(); return $stmt->fetch(); } } Thursday, November 7, 13
  • 49. DRY Up Your DB class UserDao { protected $db; public function __construct(PDO $db) { $this->db = $db; } public function find($id) { $sql = 'SELECT * FROM users WHERE id = :id'; $stmt = $this->db->prepare($sql); $stmt->bindValue(':id', $id); $stmt->execute(); return $stmt->fetch(); } } Thursday, November 7, 13
  • 50. Or Just Pick Something from Packagist Thursday, November 7, 13
  • 51. Start Writing Beautiful Code Thursday, November 7, 13
  • 52. Start Writing Beautiful Code ‣ Thursday, November 7, 13 It’s time for a coding standard!
  • 53. Start Writing Beautiful Code ‣ Makes life so much easier ‣ It’s time for a coding standard! Thursday, November 7, 13
  • 54. Start Writing Beautiful Code ‣ Makes life so much easier ‣ Pick someone else’s ‣ It’s time for a coding standard! Thursday, November 7, 13
  • 55. Start Writing Beautiful Code ‣ Makes life so much easier ‣ Pick someone else’s ‣ Use automated tools to enforce ‣ It’s time for a coding standard! Thursday, November 7, 13
  • 56. Start Writing Beautiful Code ‣ Makes life so much easier ‣ Pick someone else’s ‣ Use automated tools to enforce ‣ php-cs-fixer ‣ It’s time for a coding standard! Thursday, November 7, 13
  • 57. Start Writing Beautiful Code ‣ Makes life so much easier ‣ Pick someone else’s ‣ Use automated tools to enforce ‣ php-cs-fixer ‣ PHP_CodeSniffer ‣ It’s time for a coding standard! Thursday, November 7, 13
  • 58. Start Writing Beautiful Code ‣ Makes life so much easier ‣ Pick someone else’s ‣ Use automated tools to enforce ‣ php-cs-fixer ‣ PHP_CodeSniffer ‣ Refactor bit-by-bit ‣ It’s time for a coding standard! Thursday, November 7, 13
  • 60. PHP: The Right Way Thursday, November 7, 13
  • 61. PHP: The Right Way ‣ Thursday, November 7, 13 Go to http://www.phptherightway.com/
  • 62. PHP: The Right Way ‣ Start reading ‣ Go to http://www.phptherightway.com/ Thursday, November 7, 13
  • 63. PHP: The Right Way ‣ Start reading ‣ Don’t stop reading ‣ Go to http://www.phptherightway.com/ Thursday, November 7, 13
  • 64. PHP: The Right Way ‣ Start reading ‣ Don’t stop reading ‣ Do it “The Right Way” for 6 months ‣ Go to http://www.phptherightway.com/ Thursday, November 7, 13
  • 65. PHP: The Right Way ‣ Start reading ‣ Don’t stop reading ‣ Do it “The Right Way” for 6 months ‣ Then pick and choose ‣ Go to http://www.phptherightway.com/ Thursday, November 7, 13