1. Go to this page and download the library: Download divineniiquaye/php-rade 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/ */
divineniiquaye / php-rade example snippets
// Boot the application.
$app = new Flange\Application();
// Add a route to application
$app->match('/hello/{name:\w+}', to: fn (string $name): string => 'Hello ' . $app->escape()->escapeHtml($name));
$extensions = [
[Flange\Extensions\CoreExtension::class, [__DIR__]],
// You can add more extensions here ...
];
//If you want to use extensions, here is an example:
$app->loadExtensions($extensions, ['config' => '%project_dir%/config']);
// You can set custom pages for caught exceptions, using default event dispatcher, or your custom event dispatcher.
$app->getDispatcher()?->addListener(Flange\Events::EXCEPTION, new ErrorListener(), -8);
$app->run();
use function Rade\DI\Loader\{param, phpCode, wrap};
$config = [
'cacheDir' => __DIR__ . '/caches',
'debug' => $_ENV['APP_DEBUG'] ?? false, // Set the debug mode environment
];
// Setup cache for application.
$app = Flange\AppBuilder::build(static function (Flange\AppBuilder $creator): void {
// Add resource to re-compile if changes are made to this file.
$creator->addResource(new FileResource(__FILE__));
// Adding routes ple as its recommended to use extensions to build your application.
$creator->loadExtensions($extensions, ['config' => '%project_dir%/config']);
// You can set custom pages for caught exceptions, using default event dispatcher, or your custom event dispatcher.
$creator->definition('events.dispatcher')->bind('addListener', [Flange\Events::EXCEPTION, wrap(ErrorListener::class), -8]);
}, $config);
$app->run(); // Boot the application.
use Biurad\Http\Response\HtmlResponse;
use Flange\Event\ExceptionEvent;
class ErrorListener
{
public function __invoke(ExceptionEvent $event): void
{
// If extensions were loaded, the %project_dir% will exist, else replace will absolute path
$errorsPath = $event->getApplication()->parameter('%project_dir%/errors/');
$code = $event->getThrowable()->getCode();
$templates = [
$errorsPath . \substr($code, 0, 2) . 'x.html.php', // 40x.html.php format ...
$errorsPath . \substr($code, 0, 1) . 'xx.html.php', // 4xx.html.php format ...
$errorsPath . $code . '.html.php', // 404.html.php format ...
$errorsPath . 'default.html.php',
];
// Tries to load a template file from a list of error templates.
foreach ($template as $template) {
if (\file_exists($template)) {
$event->setResponse(
(static function () use ($template, $code) {
\ob_start();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.