D
D
Dmitry Morozov2018-03-01 16:12:18
PHP
Dmitry Morozov, 2018-03-01 16:12:18

How to integrate PHPAuth into MVC project?

I started to study MVC and I can't figure out how to properly integrate https://github.com/PHPAuth/PHPAuth into the project. It is clear that you can do inside the view:

include 'languages/ru_RU.php';
include 'Config.php';
include 'Auth.php';

global $auth,$config;

$dbh = new PDO("mysql:host=localhost;dbname=crm", "crm", "pass");
$dbh->exec("set names utf8");

$config = new PHPAuth\Config($dbh);
$auth   = new PHPAuth\Auth($dbh, $config, "ru_RU");

if ($auth->isLogged()){
        $user = $auth->getUser( $auth->getSessionUID( $auth->getSessionHash() ) );
}

But the gut tells me that this is VERY crooked

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question