Skip to content

codelusion/OOP-Best-Practices-in-PHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Presentation: "Doing OOP/BDD in PHP"

Sample PHP Cart application using BDD/OOP

######This code was used to illustrate the basics of OOP principles and best practices.

Illustrates:

  • Encapsulation with Setters and Getters vs exposing Class internals
  • Self-validating Object instances, rather than validations sprinkled throughout code
  • Interfaces and type-hinting to reduce runtime exceptions
  • Writing classes with extension in mind

Also used the PHPSpec Behavior Driven Development tool vs. the more traditional PHPUnit testing framework.

Install & Run

git clone https://github.com/codelusion/PHP-BDD-OOP-Sample
composer update
php Cart.php //old ways of doing things
php App.php //good practices
chmod +x ./runSpec.sh
./runSpec.sh //PHPSpec tests

About

Presentation: "Doing OOP/BDD in PHP" -- Sample PHP Cart application illustrating best practices

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published