1. Go to this page and download the library: Download atk4/login 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/ */
atk4 / login example snippets
$app = new \Atk4\Ui\App();
$app->initLayout([\Atk4\Ui\Layout\Admin::class]);
$app->db = new \Atk4\Data\Persistence($dsn);
// ADD THIS CODE:
$app->auth = new \Atk4\Login\Auth($app);
$app->auth->setModel(new \Atk4\Login\Model\User($app->db));
// The rest of YOUR UI code will now be protected
\Atk4\Ui\Crud::addTo($app)->setModel(new Client($app->db));
$app->auth = new \Atk4\Login\Auth($app, [
'hasPreferences' => false, // do not show Preferences page/form
'pageDashboard' => 'dashboard', // name of the page, where user arrives after login
'pageExit' => 'goodbye', // where to send user after logout
// Oter options:
// 'hasUserMenu' => false, // will disable interaction with Admin Layout user menu
]);
$app->auth->setModel(new User($app->db));
php
$app->auth = new \Atk4\Login\Auth($app, [
'check' => false,
]);
$app->auth->setModel(new User($app->db));
// Now manually use login logic
if (!$app->auth->user->isLoaded()) {
\Atk4\Login\LoginForm::addTo($app, ['auth' => $app->auth]);
}