nkmani / netstorage-cms-api
A lightweight PHP client designed to interact with the Akamai NetStorage Usage and Configuration APIs.
Installs: 15
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/nkmani/netstorage-cms-api
Requires
- php: >=8.2
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.5
- vlucas/phpdotenv: ^5.6
README
A lightweight PHP client for interacting with the Akamai NetStorage Usage API. This package simplifies the process of managing files on Akamai NetStorage by handling authentication signatures and providing a clean interface for common operations.
Features
- Comprehensive File Operations: Support for
dir,list,stat,du,download, anddeleteactions. - Automated Authentication: Handles the generation of complex
X-Akamai-ACS-Auth-DataandX-Akamai-ACS-Auth-Signheaders. - Guzzle Integration: Built on top of Guzzle 7 for reliable HTTP networking.
- PSR-4 Compliant: Easy to integrate into modern PHP projects.
Installation
You can install the package via Composer:
composer require nkmani/netstorage-cms-api
Requirements
- PHP >= 8.2
- Guzzle HTTP Client ^7.0
Configuration
The client requires several Akamai-specific credentials. You can manage these using environment variables:
KEY: Your NetStorage HTTP API key.CP_CODE: Your Content Provider code.DOMAIN_PREFIX: The prefix for your NetStorage domain.UPLOAD_ACCOUNT_ID: Your Akamai upload account ID.
Usage
Basic Setup
use NetStorage\UsageAPI\Actions; $config = [ "key" => 'your-api-key', "cpCode" => 'your-cp-code', "domainPrefix" => 'your-domain-prefix', "uploadAccountId" => 'your-upload-account-id', ]; $client = new Actions($config);
Examples
List Directory Contents
$response = $client->list(["path" => "folder_name"]); echo $response->getBody()->getContents();
Check File Information (Stat)
$response = $client->stat(["path" => "path/to/file.txt"]); echo $response->getBody()->getContents();
Download a File
$response = $client->download(["path" => "path/to/file.txt"]); echo $response->getBody()->getContents();
Get Disk Usage (DU)
$response = $client->du(["path" => "folder_name"]); echo $response->getBody()->getContents();
Development
To run tests or contribute to the package:
- Clone the repository.
- Install development dependencies:
composer install. - Copy
.env.exampleto.envand fill in your credentials.