- fix url root directory return
 - adding arguments to command bin.php
This commit is contained in:
Emmanuel ROY 2021-04-22 10:44:29 +02:00
parent a09f93cddc
commit aed63829d0
9 changed files with 21 additions and 7 deletions

View file

@ -236,13 +236,18 @@ class Url
} else {
$scheme = 'http';
}
$base_url = $scheme . "://" . $url . "/";
$base_url = $scheme . "://" . $url ;
$url = $base_url;
}else{
$url = PATH_URL;
}
return $url . BASE_SERVER_DIRECTORY;
if(str_ends_with($url . "/" . BASE_SERVER_DIRECTORY , '/')){
return substr($url . "/" . BASE_SERVER_DIRECTORY,0,-1);
}else {
return $url . "/" . BASE_SERVER_DIRECTORY;
}
}
/**
* Obtiens le fragment depuis une variable serveur,
* ce qui est selon moi possible avec une bonne configuration serveur

View file

@ -11,30 +11,39 @@ require dirname(__DIR__) . DIRECTORY_SEPARATOR . "vendor" . DIRECTORY_SEPARATOR
if (isset($argv[1])) {
$option = explode(':', $argv[1]);
$command_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "command" . DIRECTORY_SEPARATOR . ucfirst($option[0]) . ".php";
//récupération des arguments de la commande pour passage en paramètre de la méthode
$arguments = array();
if (isset($argv[2])) {
for ($i = 2; $i < count($argv); $i++) {
$arguments[] = $argv[$i];
}
}
if (is_file($command_file)) {
$class = "\MVC\Command\\" . ucfirst($option[0]);
$static_method = $option[1];
$errors = $class::$static_method();
$errors = $class::$static_method(...$arguments);
if ($errors !== null) {
\MVC\Classe\Logger::logCommandErrors($errors);
}
} else {
$command_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "command" . DIRECTORY_SEPARATOR . "app" . DIRECTORY_SEPARATOR. ucfirst($option[0]) . ".php";
$command_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "command" . DIRECTORY_SEPARATOR . "App" . DIRECTORY_SEPARATOR. ucfirst($option[0]) . ".php";
if (is_file($command_file)) {
$class = "\MVC\Command\\App\\" . ucfirst($option[0]);
$static_method = $option[1];
$errors = $class::$static_method();
$errors = $class::$static_method(...$arguments);
if ($errors !== null) {
\MVC\Classe\Logger::logCommandErrors($errors);
}
}else {
$command_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "command" . DIRECTORY_SEPARATOR . "sand" . DIRECTORY_SEPARATOR. ucfirst($option[0]) . ".php";
$command_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "command" . DIRECTORY_SEPARATOR . "Sand" . DIRECTORY_SEPARATOR. ucfirst($option[0]) . ".php";
if (is_file($command_file)) {
$class = "\MVC\Command\\Sand\\" . ucfirst($option[0]);
$static_method = $option[1];
$errors = $class::$static_method();
$errors = $class::$static_method(...$arguments);
if ($errors !== null) {
\MVC\Classe\Logger::logCommandErrors($errors);