PHP code example of axsor / laravel-phpipam
1. Go to this page and download the library: Download axsor/laravel-phpipam 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/ */
axsor / laravel-phpipam example snippets
'providers' => [
Axsor\PhpIPAM\PhpIPAMServiceProvider::class,
],
$config = [
'url' => 'https://phpipam.net/api',
'user' => 'axsor',
'pass' => 'secure',
'app' => 'api-client',
'token' => 'my_awesome_token',
'verify_cert' => false
];
PhpIPAM::use($config)->address(22); // Sets custom configuration before execute method
PhpIPAM::ping(22); // Keeps custom configuration when execute method
PhpIPAM::useDefaultConfig(); // Discard custom configuration and uses default configuration
use Axsor\PhpIPAM\Facades\PhpIPAM;
class MyController extends Controller
{
public function ping(Request $request, $addressId)
{
return PhpIPAM::ping($addressId); // Returns true if address is online
}
public function address(Request $request, $addressId)
{
$user = Auth::user();
$config = config('phpipam');
$config['user'] = $user->phpipam_user;
$config['pass'] = $user->phpipam_pass;
return PhpIPAM::use($config)->address($addressId); // Returns address using custom config
}
public function addressUpdate(Request $request, $addressId)
{
$address = PhpIPAM::address($addressId);
$address->hostname = 'New Hostname';
$address->update();
// Or
PhpIPAM::addressUpdate($addressId);
// Or
$address = PhpIPAM::address($addressId);
// Do some actions with address
$newData = [...];
PhpIPAM::addressUpdate($address, $newData);
}
}
PhpIPAM::sections();
PhpIPAM::section($section);
PhpIPAM::sectionSubnets($section);
PhpIPAM::sectionByName($section);
PhpIPAM::sectionCreate($section);
PhpIPAM::sectionUpdate($section, $newData);
PhpIPAM::sectionDrop($section);
$section->update();
$section->drop();
$section->subnets();
PhpIPAM::devices();
PhpIPAM::device($device);
PhpIPAM::deviceAddresses($device);
PhpIPAM::deviceSubnets($device);
PhpIPAM::deviceCreate($data);
PhpIPAM::deviceUpdate($device, $data);
PhpIPAM::deviceDrop($device);
$device->subnets();
$device->addresses();
$device->deviceTypes();
$device->update();
$device->drop();
$device->ping();
PhpIPAM::subnet($subnet);
PhpIPAM::subnetUsage($subnet);
PhpIPAM::subnetFreeAddress($subnet);
PhpIPAM::subnetSlaves($subnet);
PhpIPAM::subnetSlavesRecursive($subnet);
PhpIPAM::subnetAddresses($subnet);
PhpIPAM::subnetIp($subnet, "192.168.1.4");
PhpIPAM::subnetFreeSubnet($subnet, $mask);
PhpIPAM::subnetFreeSubnets($subnet, $mask);
PhpIPAM::subnetCustomFields();
PhpIPAM::subnetByCidr("192.168.1.0/24");
PhpIPAM::subnetCreate($subnetData);
PhpIPAM::subnetCreateInSubnet($subnet, $subnetData);
PhpIPAM::subnetUpdate($subnet, $subnetData);
PhpIPAM::subnetResize($subnet, $mask);
PhpIPAM::subnetSplit($subnet, $number);
PhpIPAM::subnetDrop($subnet);
PhpIPAM::subnetTruncate($subnet);
$subnet->update();
$subnet->drop();
$subnet->usage();
$subnet->freeAddress();
$subnet->slaves();
$subnet->slavesRecursive();
$subnet->addresses();
$subnet->ip("192.168.168.4");
$subnet->freeSubnet($mask);
$subnet->freeSubnet($mask);
$subnet->resize($mask);
$subnet->split($number);
$subnet->truncate();
PhpIPAM::address($address);
PhpIPAM::ping($address);
PhpIPAM::addressByIp("10.140.128.1");
PhpIPAM::addressByHostname("phpipam.net");
PhpIPAM::addressCustomFields();
PhpIPAM::addressTags();
PhpIPAM::addressTag($tag);
PhpIPAM::tagAddresses($tag);
PhpIPAM::addressCreate($data);
PhpIPAM::addressCreateFirstFree($subnet);
PhpIPAM::addressUpdate($address, $data);
PhpIPAM::addressDrop($address);
$address->update();
$address->drop();
$address->ping();
PhpIPAM::circuits();
PhpIPAM::circuit($circuit);
PhpIPAM::circuitCreate($circuit);
PhpIPAM::circuitUpdate($circuit, $newData);
PhpIPAM::circuitDrop($circuit);
$circuit->update();
$circuit->drop();
$circuit->subnets();
PhpIPAM::locations();
PhpIPAM::location($location);
PhpIPAM::locationCreate($location);
PhpIPAM::locationUpdate($location, $newData);
PhpIPAM::locationDrop($location);
PhpIPAM::tags();
PhpIPAM::tag($tag);
PhpIPAM::tagCreate($tag);
PhpIPAM::tagUpdate($tag, $newData);
PhpIPAM::tagDrop($tag);
PhpIPAM::deviceTypes();
$location->update();
$location->drop();
$tag->update();
$tag->drop();