Non ero sicuro se stavi richiedendo un IDE o un framework MVC, ma volevo condividere un nuovo MVC per PHP che sia molto vicino a .NET.
link
Ecco come funziona:
Definisci il tuo modello di vista:
require_once('bin/System.php');
class MovieViewModel
{
public $Id = 0;
public $Title = "";
public $Rating = '';
public $ReleaseDate = '';
public function __construct($id, $title, $rating, $releaseDate)
{
$this->Id = $id;
$this->Title = $title;
$this->Rating = $rating;
$this->ReleaseDate = $releaseDate;
}
}
Definisci il tuo controller:
require_once('/repositories/MovieRepository.php');
require_once('/models/MovieViewModel.php');
class HomeController
{
public $MovieRepo;
public function __construct()
{
$this->MovieRepo = new MovieRepository(); // create an instance of our repo
}
public function Index()
{
$model = []; // create a variable to store our movies (don't actually need this, but it's nice)
$movies = $this->MovieRepo->GetMovies(); // get data from our repo
// do some transformations and populate our view model
foreach ($movies as $movie)
{
$model[] = new MovieViewModel(
$movie->Id,
$movie->Title,
$movie->IsRRated ? 'R' : 'PG',
$movie->ReleaseDate->format('F jS, Y')
);
}
View::Render('views/home/index.php', null, $model); // call our view and send the model
}
}
Definisci la tua vista:
<ul class="list-group">
<?php
foreach($Model as $movie)
{
echo <<<HTML
<li class="list-group-item">
<strong>{$movie->Title}</strong> ({$movie->Rating}) - {$movie->ReleaseDate}
</li>
HTML;
}
?>
</ul>
E, presto!