PHP code example of forticas / minimal-php-skeleton-mvc
1. Go to this page and download the library: Download forticas/minimal-php-skeleton-mvc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
forticas / minimal-php-skeleton-mvc example snippets
// project-name/src/controller/DefaultController.php
declare(strict_types=1);
namespace App\controller;
use App\core\Controller;
class DefaultController extends Controller
{
public function my_first_action(){
//...
$message = 'Hello World!';
$user = 'John Doe';
$this->renderView('defaut_folder_name/file_name',[
'message' => $message,
'userName' => $user
//...
]);
}
public function my_second_action(mixed ...$values){
}
}
// project-name/src/model/Post.php
declare(strict_types=1);
namespace App\model;
use App\core\Model;
class Post extends Model
{
private int $id;
private string $title;
//...
/**
* @return int
*/
public function getId(): int{
return $this->id;
}
/**
* @return string
*/
public function getTitle(): string{
return $this->title;
}
/**
* @param string $title
* @return Post
*/
public function setTitle(string $title):self {
$this->title = $title;
return $this;
}
}