PHP code example of spiralover / nerve-client
1. Go to this page and download the library: Download spiralover/nerve-client 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/ */
spiralover / nerve-client example snippets
use SpiralOver\Nerve\Client\Neuron;
access-token>');
// List
$neurons = $client->list();
// Create
$created = $client->create(
name: 'My Neuron 1',
uniqueName: 'my.neuron.1',
visibility: 'public',
url: 'localhost:7788',
webhook: 'localhost:7788/webhook',
desc: 'Hello World',
);
// Update
$updated = $client->update(
id: $created->neuron_id,
name: 'My Neuron 1',
uniqueName: 'my.neuron.1',
visibility: 'public',
url: 'localhost:7788',
webhook: 'localhost:7788/webhook',
desc: 'Hello World',
);
// Fetch Info
$viewed = $neuron->read($created->neuron_id);
// Delete
$message = $neuron->delete($created->neuron_id);
use SpiralOver\Nerve\Client\Neuron;
access-token>');
$uniqueReference = sprintf('my-unique-app-prefix-%s', uniqid(more_entropy: true));
$response = $client->emitImpulse(
neuronId: 'ba666184-1e8d-43c0-b59a-ac7240897875',
name: 'user.created',
data: [
'first_name' => 'Jane',
'last_name' => 'Doe',
'email' => '[email protected] '
],
endpoint: 'http://localhost:9999',
uniqueReference: $uniqueReference,
callback: 'http://localhost:7777',
callbackOnSuccess: false,
callbackOnFailure: true,
withImpulseMetadata: true
);
use SpiralOver\Nerve\Client\Webhook;
onal-access-token>');
if (!$webhook->isVerified) { // impulse verification failed
http_response_code(401);
}
$message = $webhook->message;
use SpiralOver\Nerve\Client\Neuron;
onal-access-token>',
server: Neuron::SERVER_SPIRALOVER,
apiVersion: Neuron::API_VERSION_1_0
);