PHP code example of fzipi / zf2-radius-authentication-adapter

1. Go to this page and download the library: Download fzipi/zf2-radius-authentication-adapter 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/ */

    

fzipi / zf2-radius-authentication-adapter example snippets




use Fing\Authentication\Adapter\Radius as RadiusAdapter;
use Zend\Authentication;

$servers = array(
			'realm' => "myrealm",
            'servers' => array(
                array(
                    'hostname' => 'radius01.example.com',
					'port' => 1812,
                    'secret' => '<verysecretstringforthisserver>',
                ),
                array(
                    'hostname' => 'radius02.example.com',
					'port' => 18120, // not default port
                    'secret' => '<anotherverysecretstring>',
					'timeout' => 10,
					'maxTries' => 2
                )
            )
        );

//Create our adapter passing one server (up to 10 can be passed)
$adapter =  new RadiusAdapter($options, $username, $password);

//Authenticate
$result = $adapter->authenticate();

//Using Radius REALMS
$adapter->setRealm("routers"); // if not set in options config previously

$access = $adapter->authenticate()

/** Plugged in to Zend\Authentication **/

// Assuming we're still using the $adapter constructed above:

$authService = new Authentication\AuthenticationService(
    new Authentication\Storage\NonPersistent(),
    $adapter
);

$result = $authService->authenticate();