PHP code example of bmnd / core

1. Go to this page and download the library: Download bmnd/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/ */

    

bmnd / core example snippets




\BMND\Router\Router::setup('app/Controllers', 'App\\Controllers\\', 'path/to/cacheDir')->run();
#+END_SRC

* Установка
** Composer
#+BEGIN_SRC bash
composer er
{
#[Route('/test/{id}', 'GET', 'test.show')]
	public function show(int $id)
	{
		return "ID: {$id}";
	}

namespace App\Middleware;

use BMND\Http\MiddlewareInterface;
use BMND\Http\RequestInterface;
use BMND\Http\ResponseInterface;
use BMND\Http\RequestHandlerInterface;

class AuthMiddleware implements MiddlewareInterface
{
	public function process(RequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
	{
		if (!auth_check()) {
			return new Response('Unauthorized', 401);
		}
		return $handler->handle($request);
	}