PHP library for interacting with the Packet API
Switch branches/tags
Nothing to show
Clone or download
dkenzox Merge pull request #86 from packethost/add-invoice-user
Add user attribute to invoices
Latest commit 9ff9c2c Aug 16, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/PacketHost/Client Add user attribute to invoices Aug 16, 2016
tests Add project usages route Mar 23, 2016
.gitignore Hello packeteers! May 19, 2015
Gruntfile.js
README.md Update readme to include queryParams Jun 6, 2016
composer.json Set php_codesniffer version Apr 12, 2016
package.json Hello packeteers! May 19, 2015
phpunit-cc.xml
phpunit.xml Hello packeteers! May 19, 2015
ruleset.xml Hello packeteers! May 19, 2015
shippable.yml Update shippable config to 3.0 Jul 30, 2015

README.md

Packet PHP Library

Build Status

####Requirements

  • PHP Curl Extension
  • PHP XSL Extension

Install with Composer

 "require": {
        "packethost/packet": "dev-master"
    },

How to use it

<?php

require __DIR__ . '/vendor/autoload.php';

//Create a configuration object
$config = new PacketHost\Client\Adapter\Configuration\DefaultConfiguration(
    'YOUR_API_KEY'
);

//Build the adapter and Api
$adapter = new PacketHost\Client\Adapter\GuzzleAdapter($config);
$api = new PacketHost\Client\PacketApi($adapter);

//Create options array with request params
$options = [
    'queryParams' => 'per_page=20'
];

// Fetching projects
$projects = $api->project()->getAll($params);
var_dump($projects);

// Fetching facilities
$facilities = $api->facility()->getAll();

// Fetching Operating Systems
$oses = $api->operatingSystem()->getAll();

// Fetching Plans
$plans = $api->plan()->getAll();

// Creating a device
$device = new \PacketHost\Client\Domain\Device();

$projectId = 'PROJECT_ID';

$device->hostname = 'sample';
$device->facility = $facilities[0]->code;
$device->plan = $plans[0]->slug;
$device->operatingSystem = $oses[0]->slug;

$device = $api->device()->create($projectId, $device);

var_dump($device);

Running the tests

grunt ci