PHP code example of onix-systems-php / hyperf-impersonate

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

    

onix-systems-php / hyperf-impersonate example snippets




'vendor/onix-systems-php/hyperf-impersonate/src/',

use OnixSystemsPHP\HyperfImpersonate\Contract\Impersonatable as ImpersonatableInterface;
use OnixSystemsPHP\HyperfImpersonate\Trait\Impersonatable;

class User extends ... implements ImpersonatableInterface
{
    use Impersonatable;
}

public function canImpersonate(): bool
{
    return in_array($this->getRole(), UserRoles::GROUP_ADMINS);
}

public function canBeImpersonated(): bool
{
    return in_array($this->getRole(), UserRoles::GROUP_USERS);
}
shell script
composer 
shell script
php bin/hyperf.php vendor:publish onix-systems-php/hyperf-impersonate -i config
shell script
php bin/hyperf.php vendor:publish onix-systems-php/hyperf-impersonate -i en_us_translation
php bin/hyperf.php vendor:publish onix-systems-php/hyperf-impersonate -i ua_uk_translation
config/autoload/swagger.php