From b4f66ea8d884ef3c51b5cd65e9454eb2eeb8c1f8 Mon Sep 17 00:00:00 2001 From: sksaju Date: Thu, 17 Dec 2020 00:33:18 +0600 Subject: [PATCH] update namespace --- composer.json | 3 +- controllers/AuthController.php | 8 +- controllers/Controller.php | 8 +- controllers/SiteController.php | 8 +- core/Application.php | 101 ----------------- core/Database.php | 98 ----------------- core/DbModel.php | 52 --------- core/Model.php | 131 ----------------------- core/Request.php | 59 ---------- core/Response.php | 22 ---- core/Router.php | 70 ------------ core/Session.php | 69 ------------ core/UserModel.php | 15 --- core/View.php | 44 -------- core/exception/ForbiddenException.php | 16 --- core/exception/NotFoundException.php | 16 --- core/form/BaseField.php | 49 --------- core/form/Form.php | 31 ------ core/form/InputField.php | 50 --------- core/form/TextareaField.php | 22 ---- core/middlewares/AuthMiddleware.php | 37 ------- core/middlewares/BaseMiddleware.php | 15 --- migrations.php | 2 +- migrations/m0001_initial.php | 2 +- migrations/m0002_add_password_column.php | 2 +- models/ContactForm.php | 2 +- models/LoginForm.php | 4 +- models/User.php | 2 +- public/index.php | 2 +- views/contact.php | 8 +- views/home.php | 2 +- views/layouts/main.php | 4 +- views/login.php | 6 +- views/profle.php | 2 +- views/register.php | 6 +- 35 files changed, 36 insertions(+), 932 deletions(-) delete mode 100644 core/Application.php delete mode 100644 core/Database.php delete mode 100644 core/DbModel.php delete mode 100644 core/Model.php delete mode 100644 core/Request.php delete mode 100644 core/Response.php delete mode 100644 core/Router.php delete mode 100644 core/Session.php delete mode 100644 core/UserModel.php delete mode 100644 core/View.php delete mode 100644 core/exception/ForbiddenException.php delete mode 100644 core/exception/NotFoundException.php delete mode 100644 core/form/BaseField.php delete mode 100644 core/form/Form.php delete mode 100644 core/form/InputField.php delete mode 100644 core/form/TextareaField.php delete mode 100644 core/middlewares/AuthMiddleware.php delete mode 100644 core/middlewares/BaseMiddleware.php diff --git a/composer.json b/composer.json index 7150ce6..a442449 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ } }, "require": { - "vlucas/phpdotenv": "^5.2" + "vlucas/phpdotenv": "^5.2", + "sksaju/php-micro-framework-core": "^1.0" } } diff --git a/controllers/AuthController.php b/controllers/AuthController.php index 7d04f7d..66625d4 100644 --- a/controllers/AuthController.php +++ b/controllers/AuthController.php @@ -2,10 +2,10 @@ namespace app\controllers; -use app\core\Application; -use app\core\middlewares\AuthMiddleware; -use app\core\Request; -use app\core\Response; +use sksaju\phpmvc\Application; +use sksaju\phpmvc\middlewares\AuthMiddleware; +use sksaju\phpmvc\Request; +use sksaju\phpmvc\Response; use app\models\LoginForm; use app\models\User; diff --git a/controllers/Controller.php b/controllers/Controller.php index 92f1511..4130181 100644 --- a/controllers/Controller.php +++ b/controllers/Controller.php @@ -2,8 +2,8 @@ namespace app\controllers; -use app\core\Application; -use app\core\middlewares\BaseMiddleware; +use sksaju\phpmvc\Application; +use sksaju\phpmvc\middlewares\BaseMiddleware; /** * Class Controller @@ -18,7 +18,7 @@ class Controller public string $action = ''; /** - * @var app\core\middlewares\BaseMiddleware[] + * @var sksaju\phpmvc\middlewares\BaseMiddleware[] */ protected array $middlewares = []; @@ -38,7 +38,7 @@ public function registerMiddleware(BaseMiddleware $middleware) } /** - * @return app\core\middlewares\BaseMiddleware[] + * @return sksaju\phpmvc\middlewares\BaseMiddleware[] */ public function getMiddlewares(): array { diff --git a/controllers/SiteController.php b/controllers/SiteController.php index f5337b5..f74c108 100644 --- a/controllers/SiteController.php +++ b/controllers/SiteController.php @@ -2,9 +2,9 @@ namespace app\controllers; -use app\core\Application; -use app\core\Request; -use app\core\Response; +use sksaju\phpmvc\Application; +use sksaju\phpmvc\Request; +use sksaju\phpmvc\Response; use app\models\ContactForm; /** @@ -36,7 +36,7 @@ public function contact(Request $request, Response $response) return; } } - + return $this->render('contact', [ 'model' => $contact, ]); diff --git a/core/Application.php b/core/Application.php deleted file mode 100644 index ec4c54d..0000000 --- a/core/Application.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @package app\core - */ - -class Application -{ - public static string $ROOT_DIR; - - public string $layout = 'main'; - public string $userClass; - public Router $router; - public Request $request; - public Response $response; - public Session $session; - public Database $db; - public ?UserModel $user; - public View $view; - - - public static Application $app; - public ?Controller $controller = null; - - /** - * Application constructor. - * - * @param string $ROOT_DIR - * @param array $config - */ - public function __construct($ROOT_DIR, $config) - { - $this->userClass = $config['userClass']; - self::$app = $this; - self::$ROOT_DIR = $ROOT_DIR; - $this->request = new Request(); - $this->response = new Response(); - $this->session = new Session(); - $this->router = new Router($this->request, $this->response); - $this->view = new View(); - - $this->db = new Database($config['db']); - - $primaryValue = $this->session->get('user'); - if ($primaryValue) { - $primaryKey = $this->userClass::primaryKey(); - $this->user = $this->userClass::findOne([$primaryKey => $primaryValue]); - } else { - $this->user = null; - } - } - - public static function isGuest() - { - return !self::$app->user; - } - - public function run() - { - try { - echo $this->router->resolve(); - } catch (\Exception $e) { - $this->response->setStatusCode($e->getCode()); - echo $this->view->renderView('_error', [ - 'exception' => $e - ]); - } - } - - public function getController() - { - return $this->controller; - } - - public function setController(Controller $controller) - { - $this->controller = $controller; - } - - public function login(UserModel $user) - { - $this->user = $user; - $primaryKey = $user->primaryKey(); - $primaryValue = $user->{$primaryKey}; - $this->session->set('user', $primaryValue); - return true; - } - - public function logout() - { - $this->user = null; - $this->session->remove('user'); - } -} diff --git a/core/Database.php b/core/Database.php deleted file mode 100644 index 930bd3a..0000000 --- a/core/Database.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @package app\core - */ - -class Database -{ - public \PDO $pdo; - - /** - * Database constructor. - * - * @param array $config - */ - public function __construct($config) - { - $dsn = $config['dsn'] ?? ''; - $user = $config['user'] ?? ''; - $password = $config['password'] ?? ''; - $this->pdo = new PDO($dsn, $user, $password); - $this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); - } - - public function applyMigrations() - { - $this->createMigrationsTable(); - $appliedMigrations = $this->getAppliedMigrations(); - - $files = scandir(Application::$ROOT_DIR . '/migrations'); - $toApplyMigrations = array_diff($files, $appliedMigrations); - - $newMigrations = []; - foreach ($toApplyMigrations as $migration) { - if ($migration == '.' || $migration == '..') { - continue; - } - - require_once Application::$ROOT_DIR . '/migrations/' . $migration; - $className = pathinfo($migration, PATHINFO_FILENAME); - $instance = new $className(); - - $this->log("Applying migration $migration"); - $instance->up(); - $this->log("Applied migration $migration"); - $newMigrations[] = $migration; - } - - if (!empty($newMigrations)) { - $this->saveMigrations($newMigrations); - } else { - $this->log("All migrations are applied"); - } - } - - public function createMigrationsTable() - { - $this->pdo->exec("CREATE TABLE IF NOT EXISTS migrations ( - id INT AUTO_INCREMENT PRIMARY KEY, - migration VARCHAR(255), - created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP - ) ENGINE=INNODB;"); - } - - public function getAppliedMigrations() - { - $statement = $this->pdo->prepare("SELECT migration FROM migrations"); - $statement->execute(); - - return $statement->fetchAll(\PDO::FETCH_COLUMN); - } - - public function saveMigrations(array $migrations) - { - $str = implode(',', array_map(fn ($m) => "('$m')", $migrations)); - $statement = $this->pdo->prepare("INSERT INTO migrations (migration) VALUES - $str - "); - $statement->execute(); - } - - public function prepare($sql) - { - return $this->pdo->prepare($sql); - } - - protected function log($message) - { - echo '[' . date('Y-m-d H:i:s') . '] - ' . $message . PHP_EOL; - } -} diff --git a/core/DbModel.php b/core/DbModel.php deleted file mode 100644 index 1d4a86f..0000000 --- a/core/DbModel.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @package app\core - */ - -abstract class DbModel extends Model -{ - abstract public function tableName(): string; - - abstract public function attributes(): array; - - abstract public function primaryKey(): string; - - public function save() - { - $tableName = $this->tableName(); - $attributes = $this->attributes(); - $params = array_map(fn($attr) => ":$attr", $attributes); - $statement = self::prepare("INSERT INTO $tableName (" . implode(",", $attributes) . ") - VALUES (" . implode(",", $params) . ")"); - foreach ($attributes as $attribute) { - $statement->bindValue(":$attribute", $this->{$attribute}); - } - $statement->execute(); - return true; - } - - public static function findOne($where) - { - $tableName = static::tableName(); - $attributes = array_keys($where); - $sql = implode("AND ", array_map(fn($attr) => "$attr = :$attr", $attributes)); - $statement = self::prepare("SELECT * FROM $tableName WHERE $sql"); - foreach ($where as $key => $value) { - $statement->bindValue(":$key", $value); - } - - $statement->execute(); - return $statement->fetchObject(static::class); - } - - public static function prepare($sql): \PDOStatement - { - return Application::$app->db->prepare($sql); - } -} \ No newline at end of file diff --git a/core/Model.php b/core/Model.php deleted file mode 100644 index 44d2a1e..0000000 --- a/core/Model.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @package app\core - */ - -abstract class Model -{ - public const RULE_REQUIRED = 'required'; - public const RULE_EMAIL = 'email'; - public const RULE_MIN = 'min'; - public const RULE_MAX = 'max'; - public const RULE_MATCH = 'match'; - public const RULE_UNIQUE = 'unique'; - - public function loadData($data) - { - foreach ($data as $key => $value) { - if (property_exists($this, $key)) { - $this->{$key} = $value; - } - } - } - - abstract public function rules(): array; - - public function labels(): array - { - return []; - } - - public function getLabel($attribute) - { - return $this->labels()[$attribute] ?? $attribute; - } - - public array $errors = []; - - public function validate() - { - foreach ($this->rules() as $attribute => $rules) { - $value = $this->{$attribute}; - foreach ($rules as $rule) { - $ruleName = $rule; - if (!is_string($ruleName)) { - $ruleName = $rule[0]; - } - - if ($ruleName === self::RULE_REQUIRED && !$value) { - $this->addErrorForRule($attribute, self::RULE_REQUIRED); - } - - if ($ruleName === self::RULE_EMAIL && !filter_var($value, FILTER_VALIDATE_EMAIL)) { - $this->addErrorForRule($attribute, self::RULE_EMAIL); - } - - if ($ruleName === self::RULE_MIN && strlen($value) < $rule['min']) { - $this->addErrorForRule($attribute, self::RULE_MIN, $rule); - } - - if ($ruleName === self::RULE_MAX && strlen($value) > $rule['max']) { - $this->addErrorForRule($attribute, self::RULE_MAX, $rule); - } - - if ($ruleName === self::RULE_MATCH && $value !== $this->{$rule['match']}) { - $rule['match'] = $this->getLabel($rule['match']); - $this->addErrorForRule($attribute, self::RULE_MATCH, $rule); - } - - if ($ruleName === self::RULE_UNIQUE) { - $className = $rule['class']; - $uniqueAttr = $rule['attribute'] ?? $attribute; - $tableName = $className::tableName(); - - $statement = Application::$app->db->prepare("SELECT * FROM $tableName WHERE $uniqueAttr = :attr"); - $statement->bindValue(':attr', $this->{$uniqueAttr}); - $statement->execute(); - $record = $statement->fetchObject(); - - if ($record) { - $this->addErrorForRule($attribute, self::RULE_UNIQUE, ['field' => $this->getLabel($attribute)]); - } - } - } - } - - return empty($this->errors); - } - - private function addErrorForRule(string $attribute, string $rule, $params = []) - { - $message = $this->errorMessage()[$rule] ?? ''; - - foreach ($params as $key => $value) { - $message = str_replace("{{$key}}", $value, $message); - } - - $this->errors[$attribute][] = $message; - } - - - public function addError(string $attribute, string $message) - { - $this->errors[$attribute][] = $message; - } - - public function errorMessage() - { - return [ - self::RULE_REQUIRED => 'This field is required', - self::RULE_EMAIL => 'This field must be valid email address', - self::RULE_MIN => 'Min length of this field must be {min}', - self::RULE_MAX => 'Max length of this field must be {max}', - self::RULE_MATCH => 'This field must be the same as {match}', - self::RULE_UNIQUE => 'Record with this {field} already exists' - ]; - } - - public function hasError(string $attribute) { - return $this->errors[$attribute] ?? false; - } - - public function getFirstError(string $attribute) { - return $this->errors[$attribute][0] ?? false; - } -} \ No newline at end of file diff --git a/core/Request.php b/core/Request.php deleted file mode 100644 index 71dea41..0000000 --- a/core/Request.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @package app\core - */ - -class Request -{ - public function getPath() - { - $path = $_SERVER['REQUEST_URI'] ?? '/'; - $position = strpos($path, '?'); - - if ($position === false) { - return $path; - } - - return substr($path, 0, $position); - } - - public function method() - { - return strtolower($_SERVER['REQUEST_METHOD']); - } - - public function isGet() - { - return $this->method() === 'get'; - } - - public function isPost() - { - return $this->method() === 'post'; - } - - public function body() - { - $body = []; - - if ($this->isGet()) { - foreach ($_GET as $key => $value) { - $body[$key] = filter_input(INPUT_GET, $key, FILTER_SANITIZE_SPECIAL_CHARS); - } - } - - if ($this->isPost()) { - foreach ($_POST as $key => $value) { - $body[$key] = filter_input(INPUT_POST, $key, FILTER_SANITIZE_SPECIAL_CHARS); - } - } - - return $body; - } -} \ No newline at end of file diff --git a/core/Response.php b/core/Response.php deleted file mode 100644 index 582ffc2..0000000 --- a/core/Response.php +++ /dev/null @@ -1,22 +0,0 @@ - - * @package app\core - */ - -class Response -{ - public function setStatusCode(int $code) { - http_response_code($code); - } - - public function redirect(string $string) - { - header("location: $string"); - } -} \ No newline at end of file diff --git a/core/Router.php b/core/Router.php deleted file mode 100644 index fa559f3..0000000 --- a/core/Router.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @package app\core - */ - -class Router -{ - public Request $request; - public Response $response; - protected array $routes = []; - - /** - * Router constructor. - * - * @param \app\core\Request $request - * @param \app\core\Response $response - */ - public function __construct(Request $request, Response $response) - { - $this->request = $request; - $this->response = $response; - } - - public function get($path, $callback) - { - $this->routes['get'][$path] = $callback; - } - - public function post($path, $callback) - { - $this->routes['post'][$path] = $callback; - } - - public function resolve() - { - $path = $this->request->getPath(); - $method = $this->request->method(); - $callback = $this->routes[$method][$path] ?? false; - - if ($callback === false) { - throw new NotFoundException(); - } - - if (is_string($callback)) { - Application::$app->view->renderView($callback); - } - - if (is_array($callback)) { - /** @var \app\core\Controller $controller */ - $controller = new $callback[0](); - Application::$app->controller = $controller; - $controller->action = $callback[1]; - $callback[0] = $controller; - - foreach ($controller->getMiddlewares() as $middleware) { - $middleware->execute(); - } - } - - return call_user_func($callback, $this->request, $this->response); - } -} \ No newline at end of file diff --git a/core/Session.php b/core/Session.php deleted file mode 100644 index a1e2e93..0000000 --- a/core/Session.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @package app\core - */ - -class Session -{ - protected const FLASH_KEY = 'flash_messages'; - - public function __construct() - { - session_start(); - $flashMessages = $_SESSION[self::FLASH_KEY] ?? []; - - foreach ($flashMessages as $key => &$flashMessage) { - // Mark to be removed - $flashMessage['remove'] = true; - } - - $_SESSION[self::FLASH_KEY] = $flashMessages; - } - - public function setFlash($key, $message) - { - $_SESSION[self::FLASH_KEY][$key] = [ - 'remove' => false, - 'value' => $message - ]; - } - - public function getFlash($key) - { - return $_SESSION[self::FLASH_KEY][$key]['value'] ?? false; - } - - public function set($key, $value) - { - $_SESSION[$key] = $value; - } - - public function get($key) - { - return $_SESSION[$key] ?? false; - } - - public function remove($key) - { - unset($_SESSION[$key]); - } - - public function __destruct() - { - $flashMessages = $_SESSION[self::FLASH_KEY] ?? []; - foreach ($flashMessages as $key => $flashMessage) { - // Mark to be removed - if ($flashMessage['remove']) { - unset($flashMessages[$key]); - } - } - - $_SESSION[self::FLASH_KEY] = $flashMessages; - } -} \ No newline at end of file diff --git a/core/UserModel.php b/core/UserModel.php deleted file mode 100644 index 79f255b..0000000 --- a/core/UserModel.php +++ /dev/null @@ -1,15 +0,0 @@ - - * @package app\core - */ - -abstract class UserModel extends DbModel -{ - abstract public function getDisplayName(): string; -} \ No newline at end of file diff --git a/core/View.php b/core/View.php deleted file mode 100644 index 603a107..0000000 --- a/core/View.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @package app\core - */ - -class View -{ - public string $title = ''; - - public function renderView($view, $params = []) - { - $viewContent = $this->renderViewOnly($view, $params); - $layoutContent = $this->layoutContent($view); - return str_replace('{{content}}', $viewContent, $layoutContent); - } - - protected function layoutContent($view) - { - $layout = Application::$app->layout; - if (Application::$app->controller) { - $layout = Application::$app->controller->layout; - } - ob_start(); - include_once Application::$ROOT_DIR."./views/layouts/$layout.php"; - return ob_get_clean(); - } - - protected function renderViewOnly($view, $params) - { - foreach ($params as $key => $value) { - $$key = $value; - } - - ob_start(); - include_once Application::$ROOT_DIR."./views/$view.php"; - return ob_get_clean(); - } -} \ No newline at end of file diff --git a/core/exception/ForbiddenException.php b/core/exception/ForbiddenException.php deleted file mode 100644 index 5059068..0000000 --- a/core/exception/ForbiddenException.php +++ /dev/null @@ -1,16 +0,0 @@ - - * @package app\core\exception - */ - -class ForbiddenException extends \Exception -{ - protected $code = 403; - protected $message = 'You don\'t have permission to access this page'; -} \ No newline at end of file diff --git a/core/exception/NotFoundException.php b/core/exception/NotFoundException.php deleted file mode 100644 index 6cadaa1..0000000 --- a/core/exception/NotFoundException.php +++ /dev/null @@ -1,16 +0,0 @@ - - * @package app\core\exception - */ - -class NotFoundException extends \Exception -{ - protected $code = 404; - protected $message = 'Page not found'; -} \ No newline at end of file diff --git a/core/form/BaseField.php b/core/form/BaseField.php deleted file mode 100644 index c81a36f..0000000 --- a/core/form/BaseField.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @package app\core\form - */ - -abstract class BaseField -{ - public Model $model; - public string $attribute; - - /** - * BaseField constructor. - * - * @param Model $model - * @param string $attribute - */ - public function __construct(Model $model, string $attribute) - { - $this->model = $model; - $this->attribute = $attribute; - } - - abstract public function renderInput(): string; - - public function __toString() - { - return sprintf(' -
- - %s -
- %s -
-
- ', - $this->model->getLabel($this->attribute), - $this->renderInput(), - $this->model->getFirstError($this->attribute), - ); - } -} \ No newline at end of file diff --git a/core/form/Form.php b/core/form/Form.php deleted file mode 100644 index 5d20bcd..0000000 --- a/core/form/Form.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @package app\core\form - */ - -class Form -{ - public static function begin($action, $method) - { - echo sprintf('
', $action, $method); - return new Form(); - } - - public static function end() - { - return '
'; - } - - public function field(Model $model, string $attribute) - { - return new InputField($model, $attribute); - } -} \ No newline at end of file diff --git a/core/form/InputField.php b/core/form/InputField.php deleted file mode 100644 index bad0f5a..0000000 --- a/core/form/InputField.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @package app\core\form - */ - -class InputField extends BaseField -{ - public const TYPE_TEXT = 'text'; - public const TYPE_PASSWORD = 'password'; - public const TYPE_NUMBER = 'number'; - - public string $type; - - /** - * Field constructor. - * - * @param Model $model - * @param string $attribute - */ - public function __construct(Model $model, string $attribute) - { - $this->type = self::TYPE_TEXT; - - parent::__construct($model, $attribute); - } - - public function passwordField() - { - $this->type = self::TYPE_PASSWORD; - return $this; - } - - public function renderInput(): string - { - return sprintf('', - $this->type, - $this->attribute, - $this->model->{$this->attribute}, - $this->model->hasError($this->attribute) ? ' is-invalid' : '' - ); - } -} \ No newline at end of file diff --git a/core/form/TextareaField.php b/core/form/TextareaField.php deleted file mode 100644 index 87e8e18..0000000 --- a/core/form/TextareaField.php +++ /dev/null @@ -1,22 +0,0 @@ - - * @package app\core\form - */ - -class TextareaField extends BaseField -{ - public function renderInput(): string - { - return sprintf('', - $this->model->hasError($this->attribute) ? ' is-invalid' : '', - $this->attribute, - $this->model->{$this->attribute}, - ); - } -} \ No newline at end of file diff --git a/core/middlewares/AuthMiddleware.php b/core/middlewares/AuthMiddleware.php deleted file mode 100644 index 201db90..0000000 --- a/core/middlewares/AuthMiddleware.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @package app\core\middlewares - */ - -class AuthMiddleware extends BaseMiddleware -{ - public array $actions = []; - - /** - * AuthMiddleware constructor - * - * @param array $actions - */ - public function __construct(array $actions = []) - { - $this->actions = $actions; - } - - public function execute() - { - if (Application::isGuest()) { - if (empty($this->actions) || in_array(Application::$app->controller->action, $this->actions)) { - throw new ForbiddenException(); - } - } - } -} \ No newline at end of file diff --git a/core/middlewares/BaseMiddleware.php b/core/middlewares/BaseMiddleware.php deleted file mode 100644 index 039118f..0000000 --- a/core/middlewares/BaseMiddleware.php +++ /dev/null @@ -1,15 +0,0 @@ - - * @package app\core\middlewares - */ - -abstract class BaseMiddleware -{ - abstract public function execute(); -} \ No newline at end of file diff --git a/migrations.php b/migrations.php index 877a2ac..65ef50c 100644 --- a/migrations.php +++ b/migrations.php @@ -1,7 +1,7 @@ title = 'Contact'; ?> @@ -11,13 +11,13 @@

Contact

- + field($model, 'subject'); ?> field($model, 'email'); ?> - +
\ No newline at end of file diff --git a/views/home.php b/views/home.php index aae7c57..d69dbe7 100644 --- a/views/home.php +++ b/views/home.php @@ -1,6 +1,6 @@ title = 'Home'; diff --git a/views/layouts/main.php b/views/layouts/main.php index 02aee66..28dbcea 100644 --- a/views/layouts/main.php +++ b/views/layouts/main.php @@ -1,5 +1,5 @@ @@ -35,7 +35,7 @@
session->getFlash('success'); + $flash_message = \sksaju\phpmvc\Application::$app->session->getFlash('success'); if ($flash_message) : ?>
diff --git a/views/login.php b/views/login.php index 7707297..3c7322b 100644 --- a/views/login.php +++ b/views/login.php @@ -1,6 +1,6 @@ title = 'Login'; @@ -9,13 +9,13 @@

Login

- + field($model, 'email'); ?> field($model, 'password')->passwordField(); ?> - +
\ No newline at end of file diff --git a/views/profle.php b/views/profle.php index 56df67d..bced204 100644 --- a/views/profle.php +++ b/views/profle.php @@ -1,6 +1,6 @@ title = 'Profile'; diff --git a/views/register.php b/views/register.php index 975f480..66b07b3 100644 --- a/views/register.php +++ b/views/register.php @@ -1,6 +1,6 @@ title = 'Register'; @@ -9,7 +9,7 @@

Create an Account

- +
@@ -26,6 +26,6 @@ - +
\ No newline at end of file