PHP code example of dam-bal / vercel-blob-php

1. Go to this page and download the library: Download dam-bal/vercel-blob-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/ */

    

dam-bal / vercel-blob-php example snippets


$client = new \VercelBlobPhp\Client();

$result = $client->put(
    path: 'test.txt',   // path
    content: 'hello world' // content,
    options: new \VercelBlobPhp\CommonCreateBlobOptions(
        addRandomSuffix: true,      // optional
        contentType: 'text',        // optional
        cacheControlMaxAge: 123,    // optional
    )
);

$client->del(['test.txt']);

$result = $client->copy(
    fromUrl: 'fromUrl',
    toPathname: 'toPathname',
    options: new \VercelBlobPhp\CommonCreateBlobOptions(
        addRandomSuffix: true,      // optional
        contentType: 'text',        // optional
        cacheControlMaxAge: 123,    // optional
    )
);

$result = $client->head('url');

$result = $client->list(
    options: new \VercelBlobPhp\ListCommandOptions(
        limit: 100, // optional
        cursor: 'cursor', // optional
        mode: \VercelBlobPhp\ListCommandMode::EXPANDED, // optional
        prefix: 'prefix', // optional
    )
);