PHP code example of nexagon / flow-php

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

    

nexagon / flow-php example snippets






$flow = new Flow\FlowClient("api-key-goes-here");
[$customer,] = $flow->customers->create([
    "name" => "Test customer",
    "email" => "[email protected]",
    "reference_identifier" => "some reference",
    "locations" => [
        "name" => "Headquarters",
        "phone" => "004588888888",
        "address_line_1" => "Test street 2",
        "postal_code" => "8000",        
        "city" => "Aarhus",
        "country" => "DK",
    ], 
]);

[$order,] = $flow->orders->create([
    "customer_group" => $customer->id,
]);
echo $order;


$flow = new Flow\FlowClient("api-key-goes-here", "http://localhost:8000/");
// or
$flow->setApiEndpoint("http://sometest-endpoint.test");

$flow = new Flow\FlowClient("api-key-goes-here");
$stream = fopen("path/to/file.png", "r");
$mimetype = mime_content_type("path/to/file.png");
[$file,] = $flow->files->createAndUpload($stream, "file.png", $mimetype);

// Consume the file on order lines or other resources
$order_line_data = [
    "files" => [$file->id],
    ... // Any other 

$flow = new Flow\FlowClient("api-key-goes-here");
$stream = ...;
$name = ...;
$mimetype = ...;
[$file, ] = $flow->files->addFileVersion($stream, $name, $mimetype);

// You have access to all version
foreach ($file->versions as &$version) {
    if ($version->latest) {
        print_r("Im the latest version ($version->last_modified)! Download me here: $version->url");
    }
}

$flow = new Flow\FlowClient("api-key-goes-here");
[$order, $request] = $flow->orders->retrieve(1);

echo $request->getStatusCode();
bash
composer