vikrant
Posts: 32
|
Posted: 05/10/2014, 2:40 AM |
|
Hi,
Using codecharge - php, how to achive MVC pattern programming?
_________________
Vikrant |
|
|
eratech
Posts: 513
|
Posted: 05/10/2014, 11:08 PM |
|
CCS doesn't do MVC, really, but why do you need MVC? What benefits of MVC are you looking for?
Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
|
|
spaul8808
Posts:
|
Posted: 05/30/2014, 4:43 AM |
|
Yes, We can use MVC(Model View Controller) model in PHP.
It is possible to write a web application in PHP whose architecture is based on the MVC pattern. Let’s start with a bare bones example:
<?php
class Model
{
public $string;
public function __construct(){
$this->string = "MVC + PHP = Awesome!";
}
}
<?php
class View
{
private $model;
private $controller;
public function __construct($controller,$model) {
$this->controller = $controller;
$this->model = $model;
}
public function output(){
return "<p>" . $this->model->string . "</p>";
}
}
<?php
class Controller
{
private $model;
public function __construct($model) {
$this->model = $model;
}
}
We have our project started with some very basic classes for each part of the pattern. Now we need to set up the relationships between them:
<?php
$model = new Model();
$controller = new Controller($model);
$view = new View($controller, $model);
echo $view->output();
------------------------------------
Reference:- http://www.logicspice.co.uk/php-programming-services
|
|
|
eratech
Posts: 513
|
Posted: 05/31/2014, 2:08 AM |
|
spaul8808
I know you can do MVC in PHP, but you don't in Codecharge, and you would lose the benefits of the quick development that CodeCharge offers.
I use CCS because I can get the job done fast without needing to dig through code all the time - that's the benefit it gives me that outweighs the benefits that MVC might give me.
Cheers
Eric
_________________
CCS 3/4/5 ASP Classic, VB.NET, PHP
Melbourne, Victoria, Australia |
|
|
|