- Removed E_STRICT error type, added some more content to skeleton and removed 'methods' of route attributes (replaced with 'method')

This commit is contained in:
Dave M. 2026-07-08 12:11:11 +00:00
parent 6b1be4d245
commit 347e3c3b6c
6 changed files with 38 additions and 14 deletions

View File

@ -16,9 +16,9 @@
"ext-posix": "*", "ext-posix": "*",
"ext-xmlreader": "*", "ext-xmlreader": "*",
"ext-fileinfo": "*", "ext-fileinfo": "*",
"league/route": "^5.0.0-dev", "league/route": "^7.0.0-dev",
"laminas/laminas-diactoros": "2.24.x-dev", "laminas/laminas-diactoros": "3.9.x-dev",
"laminas/laminas-httphandlerrunner": "2.5.x-dev", "laminas/laminas-httphandlerrunner": "2.14.x-dev",
"vlucas/phpdotenv": "^3.4@dev", "vlucas/phpdotenv": "^3.4@dev",
"middlewares/whoops": "dev-master", "middlewares/whoops": "dev-master",
"mcnd/storage": "dev-master", "mcnd/storage": "dev-master",

View File

@ -37,7 +37,7 @@ return [
public function execute(Routing $routing, Route $attribute) : void public function execute(Routing $routing, Route $attribute) : void
{ {
if (null !== ($name = $attribute->name ?? null)) { if (null !== ($name = $attribute->name ?? null)) {
$this->extension->registerRoute($name, $attribute->getRoute(), $attribute->class, $attribute->classMethod, (array) ( $attribute->method ?? $attribute->methods )); $this->extension->registerRoute($name, $attribute->getRoute(), $attribute->class, $attribute->classMethod, (array) ( $attribute->method ));
} }
} }
}, },
@ -52,7 +52,6 @@ return [
{ {
$class = $attribute->class; $class = $attribute->class;
$method = $attribute->classMethod; $method = $attribute->classMethod;
$object = $container->get($class);
$request = $request->withAttribute('lean.route', $attribute); $request = $request->withAttribute('lean.route', $attribute);

View File

@ -13,7 +13,7 @@ use Psr\Http\Server\MiddlewareInterface,
use function DI\{ create, get, autowire }; use function DI\{ create, get, autowire };
error_reporting(getenv('ERROR_REPORTING') ?: ( E_ALL & ~E_USER_DEPRECATED & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE )); error_reporting(getenv('ERROR_REPORTING') ?: ( E_ALL & ~E_USER_DEPRECATED & ~E_DEPRECATED & ~E_NOTICE ));
return [ return [
/* do nothing in production !*/ /* do nothing in production !*/

View File

@ -8,5 +8,7 @@ try {
new class($projectPath) extends %NAMESPACE%\Kernel {}; new class($projectPath) extends %NAMESPACE%\Kernel {};
} }
catch(\Throwable $t) { catch(\Throwable $t) {
echo sprintf("%s in <strong>%s</strong> <pre>%s</pre>", $t->getMessage(), $t->getFile() . ":" . $t->getLine(), $t->getTraceAsString()); echo sprintf("%s in <strong>%s</strong> <pre>%s</pre>", $t->getMessage(), $t->getFile() . ":" . $t->getLine(), getenv('DEBUG') ? $t->getTraceAsString() : "");
error_log($t->getMessage());
header("HTTP/1.1 500 Internal Server Error");
} }

View File

@ -58,4 +58,18 @@ class File
return $path; return $path;
} }
public static function assertFileExists(string $filepath) : void
{
if (! is_file($filepath)) {
throw new \InvalidArgumentException("File does not exist: {$filepath}");
}
}
public static function assertFolderExists(string $path) : void
{
if (! is_dir($path)) {
throw new \InvalidArgumentException("Folder does not exist: {$path}");
}
}
} }

View File

@ -24,7 +24,9 @@ class Kernel
public array $paths = []; public array $paths = [];
public int $errorReporting = E_ALL & ~E_USER_DEPRECATED & ~E_DEPRECATED & ~E_NOTICE; public int $errorReportingDev = -1;
public int $errorReportingProd = E_ALL & ~E_USER_DEPRECATED & ~E_DEPRECATED /*& ~E_NOTICE*/;
public array $definitionFilePaths; public array $definitionFilePaths;
@ -34,6 +36,8 @@ class Kernel
public string $projectPath public string $projectPath
) )
{ {
# Still not sure about adding a folder check each call just to add a basic project setup error ...
# File::assertFolderExists($this->projectPath);
$this->setEnvironment(); $this->setEnvironment();
$this->initializeEngine(); $this->initializeEngine();
$this->setupContainer(); $this->setupContainer();
@ -41,7 +45,7 @@ class Kernel
$this->handleRequest(); $this->handleRequest();
} }
public static function putenv($var, $value) public static function putenv($var, $value) : void
{ {
putenv("$var=$value"); putenv("$var=$value");
$_ENV[$var] = $value; $_ENV[$var] = $value;
@ -96,13 +100,17 @@ class Kernel
\Locale::setDefault($this->locale); \Locale::setDefault($this->locale);
} }
ini_set("log_errors", "1");
ini_set("error_log", $this->errorLogPath ?? getenv("LOGS_PATH") . DIRECTORY_SEPARATOR. date("Y-m").".log"); ini_set("error_log", $this->errorLogPath ?? getenv("LOGS_PATH") . DIRECTORY_SEPARATOR. date("Y-m").".log");
ini_set('display_errors', getenv("DEBUG") ? 'on' : 'on'); ini_set("log_errors", true);
ini_set('display_errors', getenv("DEBUG") ? 'on' : 'off');
error_reporting($this->errorReporting); if (getenv("DEBUG")) {
error_reporting(getenv('ERROR_REPORTING_DEV') ?: $this->errorReportingDev);
}
else {
error_reporting(getenv('ERROR_REPORTING_PROD') ?: $this->errorReportingProd);
}
return $this; return $this;
} }
@ -114,7 +122,8 @@ class Kernel
if (getenv("APP_ENV") === "prod") { if (getenv("APP_ENV") === "prod") {
if (getenv("CACHE_PATH")) { if (getenv("CACHE_PATH")) {
# check if ACPU is there first, $containerBuilder->enableDefinitionCache(); # check if ACPU is there first,
$containerBuilder->enableDefinitionCache();
$containerBuilder->enableCompilation(getenv("CACHE_PATH") . "/di/"); $containerBuilder->enableCompilation(getenv("CACHE_PATH") . "/di/");
# No proxies yet... $containerBuilder->writeProxiesToFile(true, getenv("CACHE_PATH") . "/di/"); # No proxies yet... $containerBuilder->writeProxiesToFile(true, getenv("CACHE_PATH") . "/di/");