PHP code example of bizhub / impersonate

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

    

bizhub / impersonate example snippets


  protected $middlewareGroups = [
      'web' => [
          // ...
          
          \Bizhub\Impersonate\Middleware\CheckIfImpersonating::class,
      ]
  ];

namespace App;

use Bizhub\Impersonate\Traits\CanImpersonate;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use CanImpersonate;
    
    // ...
}

// Retrieve your user model
$user = User::find(1);

// Start impersonating
$user->impersonate();

// Redirect/reload the page

// ...

// Stop impersonating
Auth::user()->stopImpersonating();