projet_php/index.php
2026-02-20 18:20:01 +01:00

36 lines
923 B
PHP

<?php
session_start();
require(__DIR__ . "/vendor/autoload.php");
//environnement
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->safeLoad();
$strCtrl = $_GET['ctrl']??'project';
$strMethod = $_GET['action']??'home';
$boolError = false;
$strFileName = "./controllers/".$strCtrl."_controller.php";
if(file_exists($strFileName)){
require($strFileName);
$strClassName = ucfirst($strCtrl)."Ctrl";
if(class_exists($strClassName)){
$objController = new $strClassName();
if(method_exists($objController,$strMethod)){
$objController->$strMethod ();
}else{
$boolError = true;
}
}else{
$boolError = true;
}
}else{
$boolError = true;
}
if($boolError){
echo "error 404 - la page elle existe pas ";
}