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
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
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
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
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
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
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