PHP code example of iftakharalamrizve / mvc-core

1. Go to this page and download the library: Download iftakharalamrizve/mvc-core 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/ */

    

iftakharalamrizve / mvc-core example snippets



use app\controllers\AuthController;

$router->get( '/registration', [ AuthController::class , 'register']);
$router->post('/registration',[AuthController::class,'register']);
$router->get('/login',[AuthController::class,'login']);
$router->post('/login',[AuthController::class,'login']);
$router->get('/logout',[AuthController::class,'logout']);
$router->get('/profile',[AuthController::class,'profile']);
shell
 config/config.php
 'routeMiddleware'=>[
        'auth'=>app\middleware\AuthMiddleware::class
  ]

    $router->get('/profile',[AuthController::class,'profile'])->middleware('auth');
 

namespace app\middleware;

use e2c\mvc\auth\Auth;
use e2c\mvc\Middleware;
use e2c\mvc\Request;

class AuthMiddleware extends Middleware
{
    public function handle ( Request $request )
    {
        if(Auth::isGuest()){
            return $request->redirect ( '/login');
        }

    }