update readme
This commit is contained in:
parent
b12cf019e7
commit
ab3227b75f
88 changed files with 7546 additions and 176 deletions
|
@ -1,8 +1,10 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use FastRoute\Dispatcher;
|
||||
use Laminas\Diactoros\ResponseFactory;
|
||||
use Lubian\NoFramework\Factory\DiactorosRequestFactory;
|
||||
use Lubian\NoFramework\Factory\DoctrineEm;
|
||||
use Lubian\NoFramework\Factory\PipelineProvider;
|
||||
use Lubian\NoFramework\Factory\RequestFactory;
|
||||
use Lubian\NoFramework\Http\BasicEmitter;
|
||||
|
@ -12,6 +14,7 @@ use Lubian\NoFramework\Http\Pipeline;
|
|||
use Lubian\NoFramework\Http\RoutedRequestHandler;
|
||||
use Lubian\NoFramework\Http\RouteMiddleware;
|
||||
use Lubian\NoFramework\Repository\CachedMarkdownPageRepo;
|
||||
use Lubian\NoFramework\Repository\DoctrineMarkdownPageRepo;
|
||||
use Lubian\NoFramework\Repository\MarkdownPageFilesystem;
|
||||
use Lubian\NoFramework\Repository\MarkdownPageRepo;
|
||||
use Lubian\NoFramework\Service\Time\Now;
|
||||
|
@ -31,21 +34,25 @@ use Symfony\Contracts\Cache\CacheInterface;
|
|||
use function FastRoute\simpleDispatcher;
|
||||
|
||||
return [
|
||||
// alias
|
||||
Now::class => fn (SystemClockNow $n) => $n,
|
||||
ResponseFactoryInterface::class => fn (ResponseFactory $rf) => $rf,
|
||||
Emitter::class => fn (BasicEmitter $e) => $e,
|
||||
MiddlewareInterface::class => fn (RouteMiddleware $r) => $r,
|
||||
RoutedRequestHandler::class => fn (InvokerRoutedHandler $h) => $h,
|
||||
RequestFactory::class => fn (DiactorosRequestFactory $rf) => $rf,
|
||||
CacheInterface::class => fn (FilesystemAdapter $a) => $a,
|
||||
MarkdownPageRepo::class => fn (CachedMarkdownPageRepo $r) => $r,
|
||||
|
||||
// Factories
|
||||
ResponseInterface::class => fn (ResponseFactory $rf) => $rf->createResponse(),
|
||||
ServerRequestInterface::class => fn (RequestFactory $rf) => $rf->fromGlobals(),
|
||||
Now::class => fn (SystemClockNow $n) => $n,
|
||||
Renderer::class => fn (Mustache_Engine $e) => new MustacheRenderer($e),
|
||||
MLF::class => fn (Settings $s) => new MLF($s->templateDir, ['extension' => $s->templateExtension]),
|
||||
ME::class => fn (MLF $mfl) => new ME(['loader' => $mfl]),
|
||||
ResponseFactoryInterface::class => fn (ResponseFactory $rf) => $rf,
|
||||
Emitter::class => fn (BasicEmitter $e) => $e,
|
||||
RoutedRequestHandler::class => fn (InvokerRoutedHandler $h) => $h,
|
||||
MiddlewareInterface::class => fn (RouteMiddleware $r) => $r,
|
||||
Dispatcher::class => fn () => simpleDispatcher(require __DIR__ . '/routes.php'),
|
||||
RequestFactory::class => fn (DiactorosRequestFactory $rf) => $rf,
|
||||
Pipeline::class => fn (PipelineProvider $p) => $p->getPipeline(),
|
||||
CacheInterface::class => fn (FilesystemAdapter $a) => $a,
|
||||
MarkdownPageFilesystem::class => fn (Settings $s) => new MarkdownPageFilesystem($s->pagesPath),
|
||||
CachedMarkdownPageRepo::class => fn (CacheInterface $c, MarkdownPageFilesystem $r) => new CachedMarkdownPageRepo($c, $r),
|
||||
MarkdownPageRepo::class => fn (MarkdownPageFilesystem $r) => $r,
|
||||
CachedMarkdownPageRepo::class => fn (CacheInterface $c, MarkdownPageFilesystem $r, Settings $s) => new CachedMarkdownPageRepo($c, $r, $s),
|
||||
EntityManagerInterface::class => fn (DoctrineEm $f) => $f->create(),
|
||||
];
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
use Lubian\NoFramework\Http\RouteMiddleware;
|
||||
use Lubian\NoFramework\Middleware\CacheMiddleware;
|
||||
use Middlewares\TrailingSlash;
|
||||
use Middlewares\Whoops;
|
||||
|
||||
return [
|
||||
Whoops::class,
|
||||
TrailingSlash::class,
|
||||
\Lubian\NoFramework\Middleware\CacheMiddleware::class,
|
||||
CacheMiddleware::class,
|
||||
RouteMiddleware::class,
|
||||
];
|
||||
|
|
|
@ -8,7 +8,8 @@ use Psr\Http\Message\ResponseInterface as Response;
|
|||
|
||||
return function (RouteCollector $r): void {
|
||||
$r->addRoute('GET', '/hello[/{name}]', Hello::class);
|
||||
$r->addRoute('GET', '/page/{page}', Page::class);
|
||||
$r->addRoute('GET', '/page', [Page::class, 'list']);
|
||||
$r->addRoute('GET', '/page/{page}', [Page::class, 'show']);
|
||||
$r->addRoute('GET', '/another-route', [Other::class, 'someFunctionName']);
|
||||
$r->addRoute('GET', '/', fn (Response $r) => $r->withStatus(302)->withHeader('Location', '/hello'));
|
||||
};
|
||||
|
|
|
@ -3,10 +3,21 @@
|
|||
use Lubian\NoFramework\Settings;
|
||||
|
||||
return new Settings(
|
||||
environment: 'dev',
|
||||
environment: 'prod',
|
||||
dependenciesFile: __DIR__ . '/dependencies.php',
|
||||
middlewaresFile: __DIR__ . '/middlewares.php',
|
||||
templateDir: __DIR__ . '/../templates',
|
||||
templateExtension: '.html',
|
||||
pagesPath: __DIR__ . '/../data/pages/'
|
||||
pagesPath: __DIR__ . '/../data/pages/',
|
||||
connection: [
|
||||
'driver' => 'pdo_sqlite',
|
||||
'user' => '',
|
||||
'password' => '',
|
||||
'path' => __DIR__ . '/../data/db.sqlite',
|
||||
],
|
||||
doctrine: [
|
||||
'devMode' => true,
|
||||
'metadataDirs' => [__DIR__ . '/../src/Model/'],
|
||||
'cacheDir' => __DIR__ . '/../data/cache/',
|
||||
],
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue