1. Go to this page and download the library: Download celema/core library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
celema / core example snippets
use Celema\Core\App;
use Celema\Router\Group;
$app = App::create();
$app->get('/health', [HealthController::class, 'show'], 'health');
$app->map(['GET', 'POST'], '/login', [AuthController::class, 'login'], 'login');
$app->any('/webhook', $webhook, 'webhook');
$app->group('/admin', function (Group $admin) use ($auth): void {
$admin->middleware($auth);
$admin->controller(AdminController::class);
$admin->get('', 'index', 'admin.index');
$admin->post('/login', 'login', 'admin.login');
});
$app->teardown(static function () use ($mailer): void {
$mailer->disconnect();
});
use Celema\Core\Factory\AbstractFactory;
use GuzzleHttp\Psr7\HttpFactory;
use GuzzleHttp\Psr7\ServerRequest;
use Psr\Http\Message\ServerRequestInterface;
class Guzzle extends AbstractFactory
{
public function __construct()
{
$factory = new HttpFactory();
$this->requestFactory = $factory;
$this->responseFactory = $factory;
$this->serverRequestFactory = $factory;
$this->streamFactory = $factory;
$this->uploadedFileFactory = $factory;
$this->uriFactory = $factory;
}
public function serverRequest(): ServerRequestInterface
{
return ServerRequest::fromGlobals();
}
}
$app = new App(new Guzzle(), new Router(), new Container());