34 Commits
Author SHA1 Message Date
Dave Mc Nicoll 254ea744c3 - Merged with master done 2026-10-19 20:01:25 +00:00
Dave Mc Nicoll 5839041e4c - Fixed conflicts 2026-10-19 20:01:18 +00:00
mcndave c8f4e181be - Added createStream methods and fixed multiple errors views 2026-10-19 20:01:17 +00:00
mcndave 5ea4e70988 - Added MethodNotAllowed interface 2026-10-19 20:01:11 +00:00
mcndave 3281713534 - Added createStream methods and fixed multiple errors views 2026-10-19 20:01:10 +00:00
Dave Mc Nicoll e3b22335e1 - Merged with master done 2026-10-19 20:01:01 +00:00
Dave Mc Nicoll 6cb5e7bba8 - Rebased 2026-10-19 20:00:54 +00:00
Dave Mc Nicoll e6a41fbfab - WIP on ulmus-user mechanics updates 2026-10-19 20:00:45 +00:00
mcndave e0f2cbac92 - Added MethodNotAllowed interface 2026-10-19 20:00:27 +00:00
Dave Mc Nicoll e32b092749 - Merged with master done 2026-10-19 20:00:26 +00:00
Dave Mc Nicoll 538e0b9aec - Fixed conflicts 2026-10-19 19:59:54 +00:00
Dev 7bad9a69c9 - Fixed default view order to 1000 2026-10-19 19:59:44 +00:00
mcndave f1570d1c42 - Added createStream methods and fixed multiple errors views 2026-10-19 19:59:43 +00:00
mcndave 71b9ca68ec - Added MethodNotAllowed interface 2026-10-19 19:59:28 +00:00
Dave Mc Nicoll 020227abfe - Fixed email route argument pattern and added getenvonce() method 2026-10-19 19:58:55 +00:00
Dave Mc Nicoll 8090e493b5 -Rebasing 2026-10-19 19:58:21 +00:00
mcndave 75c480496a - WIP on skeleton 2026-10-19 19:56:06 +00:00
mcndave bbf8566fd2 - Added createStream methods and fixed multiple errors views 2026-10-19 19:56:06 +00:00
Dave Mc Nicoll 9c5e8c66ff - Merged with master done 2026-10-19 19:55:34 +00:00
Dave Mc Nicoll 50b17ec8b6 - WIP on ulmus-user mechanics updates 2026-10-19 19:55:28 +00:00
mcndave 064d94d32a - Fixed conflict 2026-10-19 19:54:02 +00:00
mcndave aa15850baa - Done working on package manager 2026-10-19 19:54:02 +00:00
mcndave c7469af952 - WIP on package manager 2026-10-19 19:54:02 +00:00
mcndave 3a60aaaf56 - Allowed next Ulmus version into lean 2026-10-19 19:54:02 +00:00
mcndave dce553d688 - WIP on integrating package manager 2026-10-19 19:54:02 +00:00
mcndave 1a5d4dd0b2 - Some bugfixes made in skeleton dir and fixed 'email' route pattern 2026-10-19 19:53:59 +00:00
mcndave 5769f600fe - Added PHP 8.5 supports
- Fixed some minor bugs
2026-10-19 19:53:02 +00:00
mcndave 7a292fe373 - Removed E_STRICT error type, added some more content to skeleton and removed 'methods' of route attributes (replaced with 'method') 2026-10-19 19:52:24 +00:00
mcndave 79287f28cc - Fixed a missing variable bug 2026-10-19 19:52:24 +00:00
mcndave 2a688935cc - Fixed errorLogPath default value if none is provided 2026-10-19 19:52:24 +00:00
mcndave a903153fe2 - Fix conflicts 2026-10-19 19:52:24 +00:00
Dave Mc Nicoll ec59a36afb - removed getenvonce, placed in env dir instead 2026-10-19 19:52:24 +00:00
mcndave 9556a2cba6 - Added createStream methods and fixed multiple errors views 2026-10-19 19:52:23 +00:00
mcndave 1c44342bbf - Added MethodNotAllowed interface 2026-10-19 19:51:33 +00:00
27 changed files with 228 additions and 144 deletions

No files matched your search

+14 -42
View File
@@ -16,54 +16,26 @@
"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/dump": "~1.0.0",
"mcnd/lean-console": "dev-master", "mcnd/storage": "~1.0.0",
"mcnd/ulmus": "dev-master", "mcnd/event": "~1.0.0",
"mcnd/tell": "dev-master", "mcnd/tell": "~1.0.0",
"mcnd/dump": "dev-master", "mcnd/ulmus": "^1.0 || ^2.0",
"mcnd/event": "dev-master", "mcnd/kash": "~1.0.0",
"mcnd/thebugs": "dev-master", "mcnd/taxus": "1.1.0",
"mcnd/taxus": "dev-master", "mcnd/notes": "^2.1.1",
"mcnd/notes": "dev-master", "mcnd/thebugs": "^1.0.0",
"psr/simple-cache": "*" "psr/simple-cache": "*"
}, },
"repositories": [ "repositories": [
{ {
"type": "vcs", "type": "composer",
"url": "https://git.mcnd.ca/mcndave/event.git" "url": "https://git.mcnd.ca/api/packages/mcndave/composer"
},
{
"type": "vcs",
"url": "https://git.mcnd.ca/mcndave/the-bugs.git"
},
{
"type": "vcs",
"url": "https://git.mcnd.ca/mcndave/storage.git"
},
{
"type": "vcs",
"url": "https://git.mcnd.ca/mcndave/ulmus.git"
},
{
"type": "vcs",
"url": "https://git.mcnd.ca/mcndave/notes.git"
},
{
"type": "vcs",
"url": "https://git.mcnd.ca/mcndave/tell.git"
},
{
"type": "vcs",
"url": "https://git.mcnd.ca/mcndave/lean-console.git"
},
{
"type": "vcs",
"url": "https://git.mcnd.ca/mcndave/dump.git"
} }
], ],
"autoload": { "autoload": {
+8 -1
View File
@@ -2,13 +2,16 @@
use Lean\Factory\HttpFactoryInterface; use Lean\Factory\HttpFactoryInterface;
use Ulmus\User\{Authorize\HeaderAuthentication, use Ulmus\User\{
Authorize\CookieAuthentication,
Authorize\HeaderAuthentication,
Entity, Entity,
Lib\Authenticate, Lib\Authenticate,
Lib\Authorize, Lib\Authorize,
Middleware\AuthenticationMiddleware, Middleware\AuthenticationMiddleware,
Middleware\HeaderAuthenticationMiddleware, Middleware\HeaderAuthenticationMiddleware,
Middleware\CookieAuthenticationMiddleware,
Middleware\PostRequestAuthenticationMiddleware, Middleware\PostRequestAuthenticationMiddleware,
Authorize\PostRequestAuthentication}; Authorize\PostRequestAuthentication};
@@ -30,6 +33,10 @@ return [
HeaderAuthenticationMiddleware::class => create(HeaderAuthenticationMiddleware::class)->constructor(get(HeaderAuthentication::class)), HeaderAuthenticationMiddleware::class => create(HeaderAuthenticationMiddleware::class)->constructor(get(HeaderAuthentication::class)),
CookieAuthentication::class => autowire(CookieAuthentication::class),
CookieAuthenticationMiddleware::class => create(CookieAuthenticationMiddleware::class)->constructor(get(CookieAuthentication::class), get(Cookie::class)),
PostRequestAuthentication::class => create(PostRequestAuthentication::class)->constructor("email", "email", "password"), PostRequestAuthentication::class => create(PostRequestAuthentication::class)->constructor("email", "email", "password"),
PostRequestAuthenticationMiddleware::class => create(PostRequestAuthenticationMiddleware::class)->constructor(get(PostRequestAuthentication::class)), PostRequestAuthenticationMiddleware::class => create(PostRequestAuthenticationMiddleware::class)->constructor(get(PostRequestAuthentication::class)),
+1 -2
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);
+21 -1
View File
@@ -1,11 +1,15 @@
<?php <?php
use Lean\ApplicationStrategy\{ ThrowableHandler, ThrowableHandlerInterface, NotFoundDecoratorInterface, NotFoundDecorator, MethodNotAllowedInterface, }; use Lean\ApplicationStrategy\{ ThrowableHandler, ThrowableHandlerInterface, NotFoundDecoratorInterface, NotFoundDecorator, MethodNotAllowedInterface, };
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Laminas\{ Diactoros\ServerRequestFactory, HttpHandlerRunner\Emitter\EmitterInterface, HttpHandlerRunner\Emitter\SapiEmitter }; use Laminas\{ Diactoros\ServerRequestFactory, HttpHandlerRunner\Emitter\EmitterInterface, HttpHandlerRunner\Emitter\SapiEmitter };
use Lean\Factory\{ HttpFactory, HttpFactoryInterface }; use Lean\Factory\{ HttpFactory, HttpFactoryInterface };
use Picea\Picea; use Picea\Picea;
use Storage\Cookie,
Storage\Session,
Storage\SessionMiddleware;
use function DI\{ autowire, create, get }; use function DI\{ autowire, create, get };
@@ -24,6 +28,22 @@ return [
HttpFactoryInterface::class => create(HttpFactory::class), HttpFactoryInterface::class => create(HttpFactory::class),
Cookie::class => create(Cookie::class)->constructor([
'secure' => true,
'path' => getenv('URL_BASE') ?: '/',
'httponly' => true,
'samesite'=> "Lax",
], getenv("LEAN_RANDOM")),
Session::class => create(Session::class)->constructor(get(Cookie::class), [ 'path' => getenv('URL_BASE') ?: '/', ]),
SessionMiddleware::class => create(SessionMiddleware::class)->constructor(get(Cookie::class), [
'name' => "lean_sess_" . substr(md5(getenv("LEAN_RANDOM")), 0, 12),
'path' => getenv('URL_BASE') ?: '/',
'samesite' => getenv("LEAN_COOKIE_SAMESITE") ?? "Lax",
'secure' => (bool) getenv('LEAN_COOKIE_SECURE') ?? false
]),
'error.401' => function(ContainerInterface $c, Picea $picea) { 'error.401' => function(ContainerInterface $c, Picea $picea) {
return $c->get(HttpFactoryInterface::class)::createHtmlResponse($picea->renderHtml("lean/error/401", []), 401); return $c->get(HttpFactoryInterface::class)::createHtmlResponse($picea->renderHtml("lean/error/401", []), 401);
}, },
@@ -34,5 +54,5 @@ return [
'error.500' => function(ContainerInterface $c, Picea $picea) { 'error.500' => function(ContainerInterface $c, Picea $picea) {
return $c->get(HttpFactoryInterface::class)::createHtmlResponse($picea->renderHtml("lean/error/500", []), 500); return $c->get(HttpFactoryInterface::class)::createHtmlResponse($picea->renderHtml("lean/error/500", []), 500);
} },
]; ];
-1
View File
@@ -2,7 +2,6 @@
use Tell\I18n; use Tell\I18n;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
use Notes\Tell\LanguageHandler;
use function DI\autowire, DI\create, DI\get, DI\add; use function DI\autowire, DI\create, DI\get, DI\add;
+1 -1
View File
@@ -68,7 +68,7 @@ return [
} }
} }
$router->addPatternMatcher('email', '[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n/]+'); $router->addPatternMatcher('email', '[^@ \t\r\n/]+@[^@ \t\r\n/]+\.[^@ \t\r\n/]+');
$router->addPatternMatcher('ids', '\b\d[\d,]*\b'); $router->addPatternMatcher('ids', '\b\d[\d,]*\b');
$routing = $container->get(Lean\Routing::class); $routing = $container->get(Lean\Routing::class);
-9
View File
@@ -6,9 +6,6 @@ use TheBugs\JavascriptMiddleware;
use Lean\Lean; use Lean\Lean;
use Storage\Cookie,
Storage\Session,
Storage\SessionMiddleware;
use function DI\autowire, DI\create, DI\get, DI\add; use function DI\autowire, DI\create, DI\get, DI\add;
@@ -78,12 +75,6 @@ return [
JavascriptMiddleware::class => create(JavascriptMiddleware::class), JavascriptMiddleware::class => create(JavascriptMiddleware::class),
Cookie::class => create(Cookie::class)->constructor([ 'secure' => true, 'path' => getenv('URL_BASE') ?: '/', ], getenv("LEAN_RANDOM")),
Session::class => create(Session::class)->constructor(get(Cookie::class), [ 'path' => getenv('URL_BASE') ?: '/', ]),
SessionMiddleware::class => create(SessionMiddleware::class)->constructor(get(Cookie::class), [ 'name' => "lean_sess_" . substr(md5(getenv("LEAN_RANDOM")), 0, 12), 'path' => getenv('URL_BASE') ?: '/' ]),
'git.commit' => function($c) { 'git.commit' => function($c) {
if ( getenv("DEBUG") ) { if ( getenv("DEBUG") ) {
return uniqid("debug_"); return uniqid("debug_");
+14 -14
View File
@@ -5,7 +5,8 @@ CRON_KEY = dev
# Route # Route
URL_BASE = "" URL_BASE = ""
APP_URL = "dev.mcnd.ca" APP_URL = "myapp.ca"
ASSET_PATH = "static/"
# Path # Path
CACHE_DIR = "var/cache" CACHE_DIR = "var/cache"
@@ -23,19 +24,18 @@ DEFAULT_TIME = "fr.UTF-8"
DEFAULT_TIME_FALLBACK = "french.UTF-8" DEFAULT_TIME_FALLBACK = "french.UTF-8"
# Database # Database
#SQLITE_PATH = "var/home.sqlite3" SQLITE_PATH = "var/myapp.sqlite3"
#SQLITE_ADAPTER = "SQLite" SQLITE_ADAPTER = "SQLite"
#SQLITE_PRAGMA_BEGIN = "foreign_keys=ON,synchronous=NORMAL" SQLITE_PRAGMA_BEGIN = "foreign_keys=ON,synchronous=NORMAL"
#SQLITE_PRAGMA_DEBUG_BEGIN = "journal_mode=WAL" SQLITE_PRAGMA_DEBUG_BEGIN = "journal_mode=WAL"
#SQLITE_PRAGMA_CLOSE = "analysis_limit=500,optimize" SQLITE_PRAGMA_CLOSE = "analysis_limit=500,optimize"
DATABASE_PORT = "" #DATABASE_PORT = ""
DATABASE_HOST = "" #DATABASE_HOST = ""
DATABASE_NAME = "" #DATABASE_NAME = ""
DATABASE_USERNAME = "" #DATABASE_USERNAME = ""
DATABASE_PASSWORD = "" #DATABASE_PASSWORD = ""
DATABASE_CHARSET = "utf8" #DATABASE_CHARSET = "utf8"
DATABASE_ADAPTER = "MariaDB" #DATABASE_ADAPTER = "MariaDB"
LEAN_RANDOM = "%RAND64%" LEAN_RANDOM = "%RAND64%"
+12 -8
View File
@@ -25,20 +25,20 @@
"league/oauth2-client": "dev-master", "league/oauth2-client": "dev-master",
"php-di/php-di": "dev-master", "php-di/php-di": "dev-master",
"league/commonmark": "^2.7@dev", "league/commonmark": "^2.7@dev",
"assets-package/ace": "dev-master", "assets-package/ace": "1.0.0",
"mcnd/dump": "dev-master", "mcnd/dump": "dev-master",
"mcnd/storage": "dev-master", "mcnd/storage": "dev-master",
"mcnd/cli": "dev-master", "mcnd/cli": "dev-master",
"mcnd/event": "dev-master", "mcnd/event": "dev-master",
"mcnd/ulmus": "dev-master", "mcnd/ulmus": "^1.0 || ^2.0",
"mcnd/ulmus-api": "dev-master", "mcnd/ulmus-api": "^1.3.0",
"mcnd/ulmus-user": "dev-master", "mcnd/ulmus-user": "~1.1.2",
"mcnd/picea": "dev-master", "mcnd/picea": "dev-master",
"mcnd/picea-ui": "dev-master", "mcnd/picea-ui": "dev-master",
"mcnd/picea-asset": "dev-master", "mcnd/picea-asset": "~1.0.2",
"mcnd/cronard": "dev-master", "mcnd/cronard": "dev-master",
"mcnd/lean-api": "dev-master", "mcnd/lean-api": "dev-master",
"mcnd/lean-console": "dev-master", "mcnd/lean-console": "~1.3.2",
"mcnd/kash": "dev-master", "mcnd/kash": "dev-master",
"mcnd/taxus": "dev-master", "mcnd/taxus": "dev-master",
"mcnd/notes": "dev-master", "mcnd/notes": "dev-master",
@@ -47,8 +47,12 @@
}, },
"repositories": [ "repositories": [
{ {
"type": "vcs", "type": "composer",
"url": "https://git.mcnd.ca/mcndave/cronard.git" "url": "https://git.mcnd.ca/api/packages/mcndave/composer"
},
{
"type": "composer",
"url": "https://git.mcnd.ca/api/packages/assets-package/composer"
}, },
{ {
"type": "vcs", "type": "vcs",
+8 -8
View File
@@ -19,7 +19,7 @@ return [
'ulmus' => [ 'ulmus' => [
'connections' => [ 'connections' => [
'default' => [ /*'default' => [
'adapter' => getenv("DATABASE_ADAPTER"), 'adapter' => getenv("DATABASE_ADAPTER"),
'host' => getenv("DATABASE_HOST"), 'host' => getenv("DATABASE_HOST"),
'port' => getenv("DATABASE_PORT"), 'port' => getenv("DATABASE_PORT"),
@@ -29,18 +29,18 @@ return [
'settings' => [ 'settings' => [
'charset' => getenv("DATABASE_CHARSET"), 'charset' => getenv("DATABASE_CHARSET"),
], ],
], ],*/
'sqlite' => [ 'default' => [
'adapter' => getenv("SQLITE_ADAPTER"), 'adapter' => getenv("SQLITE_ADAPTER"),
'path' => getenv('PROJECT_PATH') . DIRECTORY_SEPARATOR . getenv("SQLITE_PATH"), 'path' => getenv('PROJECT_PATH') . DIRECTORY_SEPARATOR . getenv("SQLITE_PATH"),
'pragma' => explode(',', getenv("SQLITE_PRAGMA")), 'pragma' => explode(',', getenv("SQLITE_PRAGMA")),
'pragma_begin' => array_merge( 'pragma_begin' => array_merge(
explode(',', getenv("SQLITE_PRAGMA_BEGIN")), explode(',', getenv('DEBUG') ? getenv("SQLITE_PRAGMA_DEBUG_BEGIN") : "") explode(',', getenv("SQLITE_PRAGMA_BEGIN")), explode(',', getenv('DEBUG') ? getenv("SQLITE_PRAGMA_DEBUG_BEGIN") : "")
), ),
'pragma_close' => array_merge( 'pragma_close' => array_merge(
explode(',', getenv("SQLITE_PRAGMA_CLOSE")), explode(',', getenv('DEBUG') ? getenv("SQLITE_PRAGMA_DEBUG_CLOSE") : "") explode(',', getenv("SQLITE_PRAGMA_CLOSE")), explode(',', getenv('DEBUG') ? getenv("SQLITE_PRAGMA_DEBUG_CLOSE") : "")
), ),
], ],
] ]
] ]
+1 -1
View File
@@ -43,7 +43,7 @@ return [
EmailConfiguration::class => function($c) { EmailConfiguration::class => function($c) {
$email = new EmailConfiguration( EmailConfiguration::AUTH_TYPE_SMTP ); $email = new EmailConfiguration( EmailConfiguration::AUTH_TYPE_SMTP );
$email->smtpHost = getenv('SMTP_HOSTNAME'); $email->smtpHost = getenv('SMTP_HOST');
$email->smtpPort = getenv('SMTP_PORT'); $email->smtpPort = getenv('SMTP_PORT');
$email->smtpUsername = getenv('SMTP_USERNAME'); $email->smtpUsername = getenv('SMTP_USERNAME');
$email->smtpPassword = getenv('SMTP_PASSWORD'); $email->smtpPassword = getenv('SMTP_PASSWORD');
+1 -1
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 !*/
+8 -2
View File
@@ -1,8 +1,14 @@
<?php <?php
try { try {
require_once(dirname(__DIR__)."/src/Kernel.php"); $projectPath = dirname(__DIR__);
require_once $projectPath . '/vendor/autoload.php';
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<hr><small>%s:%d</small><br><pre>%s</pre>", $t->getMessage(), $t->getFile(), $t->getLine(), getenv('DEBUG') ? var_export($t->getTrace(), true) : "");
error_log($t->getMessage());
header("HTTP/1.1 500 Internal Server Error");
} }
+3 -2
View File
@@ -7,6 +7,7 @@ use Storage\Session;
use Ulmus\User\Entity\User; use Ulmus\User\Entity\User;
use Notes\Route\Attribute\Object\Route; use Notes\Route\Attribute\Object\Route;
use Notes\Security\Attribute\Security; use Notes\Security\Attribute\Security;
use DI\Attribute\Inject;
use %NAMESPACE%\{ Entity, Lib, Form }; use %NAMESPACE%\{ Entity, Lib, Form };
@@ -18,9 +19,9 @@ use Notes\Attribute\Ignore;use Ulmus\User\Entity\UserInterface;
trait ControllerTrait { trait ControllerTrait {
use \Lean\ControllerTrait; use \Lean\ControllerTrait;
#[Ignore] #[Inject]
public ? UserInterface $user; public ? UserInterface $user;
#[Ignore] #[Inject]
protected EventManager $eventManager; protected EventManager $eventManager;
} }
+7 -7
View File
@@ -38,12 +38,10 @@ class ApplicationStrategy extends Strategy\ApplicationStrategy {
{ {
return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception); return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception);
} }
/*
<<<<<<< HEAD /*<<<<<<< HEAD
/*=======
public function getMethodNotAllowedDecorator(MethodNotAllowedException $exception): MiddlewareInterface public function getMethodNotAllowedDecorator(MethodNotAllowedException $exception): MiddlewareInterface
{
return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception);
=======
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{ {
if (php_sapi_name() !== 'cli' and ! defined('STDIN')) { if (php_sapi_name() !== 'cli' and ! defined('STDIN')) {
@@ -69,6 +67,8 @@ class ApplicationStrategy extends Strategy\ApplicationStrategy {
return $this->di->get('error.404'); return $this->di->get('error.404');
} }
}; };
>>>>>>> af8b686 (- WIP on ulmus-user mechanics updates) <<<<<<< HEAD
}*/ }
>>>>>>> af8b686 (- WIP on ulmus-user mechanics updates)*/
} }
+2 -1
View File
@@ -27,7 +27,8 @@ class Composer
$source = static::createPath('vendor', 'mcnd', 'lean', 'skeleton'); $source = static::createPath('vendor', 'mcnd', 'lean', 'skeleton');
$dest = static::createPath('skeleton'); $dest = static::createPath('skeleton');
`cp -a $source $dest`; shell_exec("cp -a $source $dest");
#`cp -a $source $dest`;
$iterator = new \RecursiveDirectoryIterator($dest); $iterator = new \RecursiveDirectoryIterator($dest);
$iterator->setFlags(\RecursiveDirectoryIterator::SKIP_DOTS); $iterator->setFlags(\RecursiveDirectoryIterator::SKIP_DOTS);
+18
View File
@@ -9,6 +9,7 @@ use Notes\Route\Attribute\Object\Route;
use Notes\Security\Attribute\Security; use Notes\Security\Attribute\Security;
use Picea, Picea\Ui\Method\FormContext; use Picea, Picea\Ui\Method\FormContext;
use Picea\Ui\Method\FormContextInterface; use Picea\Ui\Method\FormContextInterface;
use Picea\Ui\Method\FormInterface;
use TheBugs\Email\MailerInterface; use TheBugs\Email\MailerInterface;
use Storage\{ Cookie, Session }; use Storage\{ Cookie, Session };
use League\CommonMark\CommonMarkConverter; use League\CommonMark\CommonMarkConverter;
@@ -82,6 +83,13 @@ trait ControllerTrait {
return HttpFactory::createRedirectResponse($url, $code, $headers); return HttpFactory::createRedirectResponse($url, $code, $headers);
} }
#[Ignore]
protected function refresh(int $code = 204, array $headers = []) {
return static::renderNothing($code, [
'Refresh' => 0
] + $headers);
}
#[Ignore] #[Ignore]
public static function renderNothing(int $code = 204, array $headers = []) : ResponseInterface public static function renderNothing(int $code = 204, array $headers = []) : ResponseInterface
{ {
@@ -203,6 +211,16 @@ trait ControllerTrait {
return $this->picea->compiler->getExtensionFromToken('route')->buildRouteUrl($name, $parameters); return $this->picea->compiler->getExtensionFromToken('route')->buildRouteUrl($name, $parameters);
} }
#[Ignore]
public function form(FormInterface $form, ? FormContextInterface $formContext = null) : Picea\Ui\Method\FormHandler
{
if (! $this->picea ) {
throw new \Exception("A picea object must be provided on class initialization to use this method.");
}
return $this->picea->compiler->getExtensionInstanceOf(Picea\Ui\Method\Form::class)->formClass($form, $formContext);
}
#[Ignore] #[Ignore]
public function json($data, int $flags = 0) : string public function json($data, int $flags = 0) : string
{ {
+2 -2
View File
@@ -11,9 +11,9 @@ use Psr\Http\Message\StreamInterface;
class HttpFactory implements HttpFactoryInterface class HttpFactory implements HttpFactoryInterface
{ {
public static function createResponse(string $url, int $code = 302, array $headers = []) : ResponseInterface public static function createResponse(mixed $body = 'php://memory', int $code = 200, array $headers = []) : ResponseInterface
{ {
return new Response($url, $code, $headers); return new Response($body, $code, $headers);
} }
public static function createRedirectResponse(string $url, int $code = 302, array $headers = []) : ResponseInterface public static function createRedirectResponse(string $url, int $code = 302, array $headers = []) : ResponseInterface
+37 -5
View File
@@ -14,20 +14,20 @@ class File
$beginning = false; $beginning = false;
$text = array(); $text = array();
while ($counter && ! $beginning) { while ($counter && !$beginning) {
$t = ""; $t = "";
while ($t !== PHP_EOL) { while ($t !== PHP_EOL) {
if(fseek($handle, $pos, SEEK_END) == -1) { if (fseek($handle, $pos, SEEK_END) == -1) {
$beginning = true; $beginning = true;
break; break;
} }
$t = fgetc($handle); $t = fgetc($handle);
$pos --; $pos--;
} }
$counter --; $counter--;
if ($beginning) { if ($beginning) {
rewind($handle); rewind($handle);
@@ -36,8 +36,40 @@ class File
$text[$lines - $counter - 1] = fgets($handle); $text[$lines - $counter - 1] = fgets($handle);
} }
fclose ($handle); fclose($handle);
return array_reverse($text); return array_reverse($text);
} }
public static function sanitizeFilePath($path) : string
{
// Remove null bytes
$path = str_replace("\0", "", $path);
$path = str_replace([ "\\", "/" ], DIRECTORY_SEPARATOR, $path);
$path = preg_replace('#' . DIRECTORY_SEPARATOR . '+#', DIRECTORY_SEPARATOR, $path);
// Remove . and .. directory traversal attempts
$path = preg_replace('#\.{1,2}/#', '', $path);
$path = trim($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}");
}
}
} }
+40 -23
View File
@@ -11,23 +11,22 @@ use League\Route\Strategy\ApplicationStrategy;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Tell\I18n;
use Ulmus\Container\AdapterProxy;
use Laminas\Diactoros\ServerRequestFactory, use Laminas\Diactoros\ServerRequestFactory,
Laminas\HttpHandlerRunner\Emitter\EmitterInterface; Laminas\HttpHandlerRunner\Emitter\EmitterInterface;
use Ulmus\Ulmus; use Ulmus\Ulmus;
class Kernel { class Kernel
{
protected Container $container; protected Container $container;
protected string $locale; protected string $locale;
public array $paths = []; public array $paths = [];
public int $errorReporting = E_ALL & ~E_USER_DEPRECATED & ~E_DEPRECATED & ~E_NOTICE; public int $errorReportingDev = -1 & ~E_USER_DEPRECATED & ~E_DEPRECATED ;
public int $errorReportingProd = E_ALL & ~E_USER_DEPRECATED & ~E_DEPRECATED /*& ~E_NOTICE*/;
public array $definitionFilePaths; public array $definitionFilePaths;
@@ -36,6 +35,11 @@ class Kernel {
public function __construct( public function __construct(
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);
define('IS_CLI', php_sapi_name() === 'cli' OR defined('STDIN'));
$this->setEnvironment(); $this->setEnvironment();
$this->initializeEngine(); $this->initializeEngine();
$this->setupContainer(); $this->setupContainer();
@@ -43,21 +47,27 @@ 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;
} }
protected function setEnvironment() { protected function setEnvironment() : void
{
static::putenv('PROJECT_PATH', $this->projectPath); static::putenv('PROJECT_PATH', $this->projectPath);
// Environment vars (accessible from \DI\env(), getenv(), $_ENV and $_SERVER) // Environment vars (accessible from \DI\env(), getenv(), $_ENV and $_SERVER)
Dotenv::create(getenv("PROJECT_PATH"))->load(); Dotenv::create(getenv("PROJECT_PATH"))->load();
// Override using headers // Override using headers
if ( ( $keys = getenv('KEYS') ) && ( $auth = $_SERVER["HTTP_X_DEV_AUTH"] ?? null ) && in_array($auth, explode(',', $keys)) ) { if (($keys = getenv('KEYS')) && ($auth = $_SERVER["HTTP_X_DEV_AUTH"] ?? null) && in_array($auth, explode(',', $keys))) {
foreach (['APP_ENV', 'DEBUG',] as $env) { unset($_SERVER["HTTP_X_DEV_AUTH"]);
unset($_ENV['KEYS'], $_SERVER['KEYS']);
putenv("KEYS=");
foreach(['APP_ENV', 'DEBUG',] as $env) {
if (null !== $value = $_SERVER["HTTP_X_$env"] ?? null) { if (null !== $value = $_SERVER["HTTP_X_$env"] ?? null) {
static::putenv($env, $value); static::putenv($env, $value);
} }
@@ -66,12 +76,14 @@ class Kernel {
// Paths and directories // Paths and directories
foreach($this->paths as $name => $envkey) { foreach($this->paths as $name => $envkey) {
if ( ! getenv($name) ) { if (!getenv($name)) {
$path = getenv("PROJECT_PATH") . DIRECTORY_SEPARATOR . getenv($envkey); $path = getenv("PROJECT_PATH") . DIRECTORY_SEPARATOR . getenv($envkey);
if (getenv('DEBUG') && ! file_exists($path)) { if (getenv('DEBUG') && ! file_exists($path)) {
if (false === mkdir($path, 0755, true)) { if (false === @mkdir($path, 0755, true)) {
throw new \Exception(sprintf("Folder '%s' could not be created", $path)); if (! IS_CLI) {
throw new \Exception(sprintf("Folder '%s' could not be created", $path));
}
} }
} }
@@ -88,15 +100,20 @@ class Kernel {
setlocale(LC_ALL, $this->locale = getenv("DEFAULT_LOCAL")); setlocale(LC_ALL, $this->locale = getenv("DEFAULT_LOCAL"));
setlocale(LC_TIME, getenv("DEFAULT_TIME"), getenv("DEFAULT_TIME_FALLBACK")); setlocale(LC_TIME, getenv("DEFAULT_TIME"), getenv("DEFAULT_TIME_FALLBACK"));
if ( class_exists('Locale') ) { if (class_exists('Locale')) {
\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); ini_set("log_errors", true);
ini_set('display_errors', getenv("DEBUG") ? 'on' : 'on'); 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;
} }
@@ -109,7 +126,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(); # Do not work .. ?
$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/");
@@ -118,7 +136,7 @@ class Kernel {
else { else {
$compiled = getenv("CACHE_PATH") . "/di/CompiledContainer.php"; $compiled = getenv("CACHE_PATH") . "/di/CompiledContainer.php";
if ( file_exists($compiled) ) { if (file_exists($compiled)) {
unlink($compiled); unlink($compiled);
} }
} }
@@ -153,8 +171,7 @@ class Kernel {
} }
# Must be removed from KERNEL ! # Must be removed from KERNEL !
$this->container->has('ulmus.caching') and ( Ulmus::$cache = $this->container->get('ulmus.caching') ); $this->container->has('ulmus.caching') and (Ulmus::$cache = $this->container->get('ulmus.caching'));
# $this->container->has(AdapterProxy::class) and ( $ )
return $this; return $this;
} }
@@ -177,4 +194,4 @@ class Kernel {
return $this; return $this;
} }
}; }
+11
View File
@@ -244,4 +244,15 @@ class Lean
return call_user_func($func); return call_user_func($func);
} }
public static function path(...$parts) : string
{
return implode(DIRECTORY_SEPARATOR, $parts);
}
public static function rawPath(...$parts) : string
{
return implode(DIRECTORY_SEPARATOR, $parts);
}
} }
-1
View File
@@ -43,7 +43,6 @@ class FileDownloadResponse extends Response
else { else {
$finfo = finfo_open(FILEINFO_MIME_TYPE); $finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $filepath); $mime = finfo_file($finfo, $filepath);
finfo_close($finfo);
} }
parent::__construct( parent::__construct(
+5
View File
@@ -44,6 +44,11 @@ class Routing {
$container->set(ServerRequestInterface::class, $request); $container->set(ServerRequestInterface::class, $request);
# Decoding arguments received from the router
foreach($arguments as &$arg) {
$arg = urldecode($arg);
}
return $this->response ?? $object->$method($request, $arguments); return $this->response ?? $object->$method($request, $arguments);
}); });
} }
+11
View File
@@ -0,0 +1,11 @@
{% arguments array $contextList %}
{% if $contextList %}
<div class="message-wrapper">{% php
foreach($contextList as $name => $context) {
foreach($context->formContextMessages ?? [] as $message) {
echo $message->render();
}
}
%}</div>
{% endif %}
+1
View File
@@ -2,6 +2,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; "> <meta http-equiv="Content-Type" content="text/html; ">
<meta name="viewport" content="width=device-width"> <meta name="viewport" content="width=device-width">
<title>{{ title() }}</title> <title>{{ title() }}</title>
+1 -1
View File
@@ -22,7 +22,7 @@
{% slot "week.heading", $day, $month, $year %} {% slot "week.heading", $day, $month, $year %}
<div class="day-box"> <div class="day-box">
{# Random calendar date that starts on a sunday #} {# Random calendar date that starts on a sunday #}
{{ substr(( new Date("2019-12-$day") )->formatLocale("%A"), 0, 3) }} {{ new Date("2019-12-$day")->formatLocaleIntl(\IntlDateFormatter::SHORT, \IntlDateFormatter::NONE, 'EEE') }}
</div> </div>
{% endslot %} {% endslot %}
{% endforeach %} {% endforeach %}
+1 -11
View File
@@ -5,14 +5,4 @@
if ($context && ! in_array($context, $messageList)) { if ($context && ! in_array($context, $messageList)) {
$messageList[] = $context; $messageList[] = $context;
} }
%} %}{% block "lean/block/message", $messageList %}{% endblock %}
{% if $messageList %}
<div class="message-wrapper">{% php
foreach($messageList as $name => $context) {
foreach($context->formContextMessages ?? [] as $message) {
echo $message->render();
}
}
%}</div>
{% endif %}