1. Go to this page and download the library: Download celarius/spin-framework 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/ */
celarius / spin-framework example snippets
declare(strict_types=1);
namespace App\Controllers;
use \App\Controllers\AbstractPlatesController;
class IndexController extends AbstractPlatesController
{
public function handleGET(array $args)
{
$model = ['title' => 'Welcome to SPIN', 'user' => 'Guest'];
$html = $this->engine->render('pages::index', $model);
return response($html);
}
}
declare(strict_types=1);
namespace App\Middlewares;
use Spin\Core\Middleware;
class AuthMiddleware extends Middleware
{
public function initialize(array $args): bool
{
$this->secret = config('application.secret');
return true;
}
public function handle(array $args): bool
{
$token = getRequest()->getHeaderLine('Authorization');
if (!$this->validateToken($token)) {
responseJson(['error' => 'Unauthorized'], 401);
return false;
}
return true;
}
}