Note: This library is under active development as I expand it to cover Cloudflare API. Consider the public API of this package a little unstable as I work towards a v1.0. See Coverage.

Scripts

Cloudflare API docs

List Workers

Fetch a list of uploaded workers.

php
$response = $client->workers()->scripts()->get('account_id');

Download Worker

Fetch raw script content for your worker. Note this is the original script content, not JSON encoded.

php
$response = $client->workers()->scripts()->get('account_id', 'script_name');

$content = $response->body();

Upload Worker Module

Upload a worker module. You can find more about the multipart metadata on CloudFlare docs.

php
//TODO

Get Content

Fetch script content only.

php
$response = $client->workers()->scripts()->getContent('account_id', 'script_name');

$content = $response->body();

Update Content

Put script content without touching config or metadata

php
//TODO

Get Script Settings

Get script-level settings when using Worker Versions. Includes Logpush and Tail Consumers.

php
$response = $client->workers()->scripts()->getScriptSettings('account_id', 'script_name');

Update Script Settings

Patch script-level settings when using Worker Versions. Includes Logpush and Tail Consumers.

php
$response = $client->workers()->scripts()->updateScriptSettings('account_id', 'script_name', [
    'logpush' => false,
    'tail_consumers' => [
        [
            'environment' => 'production'
        ]
    ]
]);

Get Settings

Get metadata and config, such as bindings or usage model

php
$response = $client->workers()->scripts()->getSettings('account_id', 'script_name');

Update Settings

Patch metadata or config, such as bindings or usage model

php
$response = $client->workers()->scripts()->updateSettings('account_id', 'script_name');

Get Usage Model

Fetches the Usage Model for a given Worker.

php
$response = $client->workers()->scripts()->getUsageModel('account_id', 'script_name');

Update Usage Model

Updates the Usage Model for a given Worker. Requires a Workers Paid subscription.

php
$response = $client->workers()->scripts()->updateUsageModel('account_id', 'script_name', 'usage_model');

Delete Worker

Delete your worker. This call has no response body on a successful delete.

php
$response = $client->workers()->scripts()->delete('account_id', 'script_name', true|false);