PHP code example of leafs / auth

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

    

leafs / auth example snippets


auth()->connect([
  'dbtype' => '...',
  'charset' => '...',
  'port' => '...',
  'host' => '...',
  'dbname' => '...',
  'user' => '...',
  'password' => '...'
]);

$db = new PDO('mysql:dbname=test;host=127.0.0.1', 'root', '');

auth()->dbConnection($db);

// you can use leaf auth the same way you always have

auth()->login([
  'email' => '[email protected]',
  'password' => 'password'
]);

auth()->register([
  'username' => 'example',
  'email' => '[email protected]',
  'password' => 'password'
]);

auth()->middleware('auth./login');
});

app()->get('/protected', ['middleware' => 'auth.oute group
app()->group('/protected', ['middleware' => 'auth.