PHP code example of polaris / username

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

    

polaris / username example snippets


use Polaris\Username\UsernamePlugin;

$polaris = Polaris::create(new Config(..., plugins: [new UsernamePlugin()]));

use Polaris\Username\Rules;

new UsernamePlugin(new Rules(
    minLength: 3,
    maxLength: 30,
    pattern: '/^[A-Za-z0-9_.]+$/',
    reserved: [...Rules::RESERVED, 'billing'],   // compared without regard to case
));

new SentinelPlugin(routes: SentinelMiddleware::ROUTES + UsernamePlugin::SENTINEL_ROUTES);