PHP code example of ocolin / maclookup

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

    

ocolin / maclookup example snippets


$maclookup = Ocolin\MacLookup::file();

$maclookup = Ocolin\MacLookup::file( dataPath: __DIR__ . '/files', autoUpdate: false );

$maclookup = Ocolin\MacLookup::memory();

$maclookup = Ocolin\MacLookup::memory( dataPath: __DIR__ . '/files', autoUpdate: false );

$maclookup = Ocolin\MacLookup::database();

$maclookup = Ocolin\MacLookup::database( dataPath: __DIR__ . '/files', autoUpdate: false );


$vendor = $maclookup->lookup( mac: '54:91:AF:B2:02:3A' );
print_r( $vendor );

/*
Ocolin\MacLookup\Vendor Object
(
    [mac] => 54:91:AF:B2:02:3A
    [registry] => MA-M
    [assignment] => 5491AFB
    [name] => Hyperconn Pte. ltd
    [address] => 128 Tanjong Pagar Road Singapore(088535) Singapore  SG 088535 
)
*/

$vendors = $maclookup->bulkLookup( macs: [ '54:91:AF:B2:02:3A', '[B8:27:EB:00:00:01' ] );
print_r( $vendors )

/*
Array
(
    [54:91:AF:B2:02:3A] => Ocolin\MacLookup\Vendor Object
        (
            [mac] => 54:91:AF:B2:02:3A
            [registry] => MA-M
            [assignment] => 5491AFB
            [name] => Hyperconn Pte. ltd
            [address] => 128 Tanjong Pagar Road Singapore(088535) Singapore  SG 088535 
        )

    [B8:27:EB:00:00:01] => Ocolin\MacLookup\Vendor Object
        (
            [mac] => B8:27:EB:00:00:01
            [registry] => MA-L
            [assignment] => B827EB
            [name] => Raspberry Pi Foundation
            [address] => Mitchell Wood House Caldecote Cambridgeshire US CB23 7NU 
        )
)
*/

Ocolin\MacLookup\Vendor Object
(
    [mac] => ZZ:91:AF:B2:02:3A 
    [registry] => Invalid
    [assignment] => 
    [name] => 
    [address] => 
)

Ocolin\MacLookup\Vendor Object
(
    [mac] => 52:91:AF:B2:02:00 
    [registry] => Private
    [assignment] => 
    [name] => 
    [address] => 
)

// Don't have a known Not Found MAC to use in example!
Ocolin\MacLookup\Vendor Object
(
    [mac] => 99:91:AF:B2:99:99 
    [registry] => Not Found
    [assignment] => 
    [name] => 
    [address] => 
)

$macLookup->update();
// Returns void. Will throw an error if update is unsuccessful.