PHP code example of globus-studio / atomic-framework
1. Go to this page and download the library: Download globus-studio/atomic-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/ */
use Engine\Atomic\Core\Middleware\MiddlewareInterface;
class Authenticate implements MiddlewareInterface
{
public function handle(\Base $atomic): bool
{
return Guard::is_authenticated();
}
public function process(mixed $request, callable $next): \Engine\Atomic\Http\Response
{
if (Guard::is_authenticated()) {
return $next($request);
}
return \Engine\Atomic\Http\Response::json(['error' => 'Unauthorized'], 401);
}
}
use Engine\Atomic\App\Controller;
class DashboardController extends Controller
{
public function index(\Base $f3): void
{
$this->display('dashboard/index.html');
}
}
use Engine\Atomic\App\Model;
class User extends Model
{
protected $fieldConf = [
'email' => ['type' => \DB\SQL\Schema::DT_VARCHAR256, 'nullable' => false],
'password' => ['type' => \DB\SQL\Schema::DT_VARCHAR256, 'nullable' => false],
];
}