Dependency Injection in Yii

Programming for Search Engines 101. An area for avid PHP and .NET developers to chat about Programming techniques and how to make better use of search engines.

Moderator: Moderators

Dependency Injection in Yii

Postby vinu » Fri Apr 11, 2014 6:43 am

For Testable & Maintainable Codes in PHP
1. Keep code DRY (Don't Repeat Yourself)
2. Implement Dependency Injection
3. Add Interfaces
4. Use Containers
5. Do Unit test with PHPUnit

/**
* SiteController class file.
* @author Winu Sebastian
*/
interface ISite {
public function setClass();
}
class SiteController extends Controller implements ISite{
public function init(){
$this->setClass();//to initialize all objects
}

more..
vinu
 

Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests