This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class View { | |
private $templateExtension = '.tpl.php'; | |
private $contentType; | |
private $controllerName; | |
public function __construct($controllerName = '', $contentType = '') { | |
$this->controllerName = $controllerName; | |
$this->contentType = $contentType; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Controller { | |
public function renderTemplate($templateName, $data = null, $contentType = 'html') { | |
try { | |
$viewObject = new View(get_called_class(), $contentType); | |
$viewObject->render($templateName, $data); | |
} catch(Exception $e) { | |
echo $e->getMessage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Model { | |
private $DBConnection = null; | |
private $DBHandler = null; | |
public function getConnection() { | |
try { | |
$this->DBConnection = new DBConnection(DBConfig::connInfo()); | |
$this->DBHandler = $this->DBConnection->connect(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DBConnection { | |
private $connection = null; | |
private $DBDriver = ''; | |
private $DBHost = ''; | |
private $DBUser = ''; | |
private $DBPassword = ''; | |
private $DBName = ''; | |
public function __construct($connInfo = array()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DBConfig { | |
public static function connInfo() { | |
$database = array( | |
'dbdriver' => 'mysql', | |
'dbhost' => 'localhost', | |
'dbusername' => 'root', | |
'dbpassword' => '', | |
'dbname' => 'webdev' | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!defined('DS')) { | |
define('DS', DIRECTORY_SEPARATOR); | |
} | |
define('APP_PATH', 'C:'.DS.'xampp'.DS.'htdocs'.DS.'testdrive'); | |
define('HOSTNAME', 'http://localhost/testdrive'); | |
define('LIBS_PATH', APP_PATH.DS.'Libs'); | |
define('ASSETS_PATH', HOSTNAME.'/Assets'); | |
define('VENDORS_PATH', APP_PATH.DS.'Vendors'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Product extends Model { | |
public function createProduct() { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ProductController extends Controller { | |
public function index() { | |
$this->renderTemplate('index'); | |
} | |
public function sebuahMethodAction() { | |
$this->renderTemplate('sebuah_method_action'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include('Bootstrap.php'); | |
require_once(APP_PATH.DS.'Controllers'.DS.'ProductController.php'); | |
$product = new ProductController(); | |
$action = $product->getAction(); | |
switch ($action) { | |
case 'index': | |
$product->index(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h2 style="color:brown;">Walalalalalala</h2> | |
<p> | |
Ini adalah output template method sebuahMethodAction() xixixixixixi | |
kamu suka kan? harus suka donk! | |
</p> |
OlderNewer