PHP code example of phoxphp / auth

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

    

phoxphp / auth example snippets


    // calling it as a registered service
    $auth = app()->load('auth');
    
    // registering a user
    $auth->register(
        '[email protected]',
        'password',
        'password'
    );
    
    // If auto_login is not enabled then you can login manually
    $auth->login(
        '[email protected]',
        'password'
    );

        // calling it as a registered service
        $auth = app()->load('auth');
        
        // log user in
        $auth->login(
            '[email protected]',
            'password'
        );

    $auth = app()->load('auth');
    $auth->logout();

        
        // calling as registered service
        $auth = app()->load('auth');
        
        $confirmation_code = '********';
        $auth->activateAccount($confirmation_code);

        // calling as registered service
        $auth = app()->load('auth');
        
        // Blocking account using email
        $auth->blockAccount(
            '[email protected]'
        );
        
        // Blocking account using id
        $userId = 5;
        $auth->blockAccount($userId);

        // calling as registered service
        $auth = app()->load('auth');
        
        // Blocking account using email
        $auth->unblockAccount(
            '[email protected]'
        );
        
        // Blocking account using id
        $userId = 5;
        $auth->unblockAccount($userId);

        // calling as registered service
        $auth = app()->load('auth');
        
        // Delete account using email
        $auth->deleteAccount(
            '[email protected]'
        );
        
        // Delete account using id
        $userId = 5;
        $auth->deleteAccount($userId);

        // calling as registered service
        $auth = app()->load('auth');
        
        $oldPassword = 'old-password';
        $newPassword = 'new-password';
        
        $auth->changePassword(
            $oldPassword,
            $newPassword
        );