PHPackages                             talk2cerlin/akamai - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. talk2cerlin/akamai

ActiveLibrary[File &amp; Storage](/categories/file-storage)

talk2cerlin/akamai
==================

Akamai Netstorage Library

v3.1.0(9y ago)31942MITPHP

Since Jul 25Pushed 9y ago1 watchersCompare

[ Source](https://github.com/talk2cerlin/akamai)[ Packagist](https://packagist.org/packages/talk2cerlin/akamai)[ RSS](/packages/talk2cerlin-akamai/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (3)Versions (12)Used By (0)

Netstorage API library package for Akamai
-----------------------------------------

[](#netstorage-api-library-package-for-akamai)

This package follows [facade design pattern](https://en.wikipedia.org/wiki/Facade_pattern) (Click on the link to read more on this).

### Features:

[](#features)

1. Upload a file to Akamai Netstorage
2. List the files and directories of a given directory
3. Download a file
4. Delete a file
5. Rename a file
6. Remove a directory (Directory must be empty to remove)
7. Create a new directory
8. Generate Video Auth token for playback

### Sample `.env.akamai`

[](#sample-envakamai)

```
AKAMAI_HOST="Your Netstorage Host"
AKAMAI_KEY="Your Netstorage Key"
AKAMAI_KEYNAME="Your Netstorage Key Name"
AKAMAI_VIDEO_TOKEN="Your Video Token"

```

### Explanation:

[](#explanation)

This package has three facade classes

#### 1) Akamai\\Facades\\Config

[](#1-akamaifacadesconfig)

##### Introduction:

[](#introduction)

`Config` facade is used to load/set the credentials which are used for API requests

##### Methods:

[](#methods)

###### 1) Config::loadFromENV($path, $name);

[](#1-configloadfromenvpath-name)

This method is used to load the credentials from an `env` file. This method will try to load all four env variables which are mentioned in the sample `.env.akamai` file.

```
/*
    @param: $path - Path of the env file. Default is current working directory.
    @param: $name - Name of the env file to load. Default is `.env.akamai`.
    @return: Array - Loaded configuration.
    @throws: Akamai\Exceptions\DotEnvException.
*/

```

###### 2) Config::setAkamaiConfig($config)

[](#2-configsetakamaiconfigconfig)

This method is to set the credentials in runtime. Will be usefull when the credentials are stored in database or any other mode of storage.

```
/*
    @param: $config - Configuration to be updated.
    @return: Array - Loaded configuration.
    @throws: Akamai\Exceptions\InvalidDataTypeFoundException;
*/

```

###### 3) Config::getAkamaiConfig()

[](#3-configgetakamaiconfig)

This method is to get the credentials in runtime.

```
/*
    @return: Array - Loaded configuration.
*/

```

#### 2) Akamai\\Facades\\Akamai

[](#2-akamaifacadesakamai)

##### Introduction:

[](#introduction-1)

`Akamai` facade is used to do the basic operations like upload, download etc. All API operations return responses as an array with fields for "data" and "code".

```
/*
    [
        "data" => API response (simple string or xml string),
        "code" => API response status code
    ]
*/

```

For a list of all possible status codes, see [https://control.akamai.com/dl/customers/NS/NS\_http\_api\_FS.pdf](https://control.akamai.com/dl/customers/NS/NS_http_api_FS.pdf)

##### Methods:

[](#methods-1)

###### 1) Akamai::upload($akamai\_path, $file\_path);

[](#1-akamaiuploadakamai_path-file_path)

This method is used to upload a file to Akamai.

```
/*
    @param: $akamai_path - File location with file name and extension to which the file should be uploaded. ex: /cpcode/folder/path/file.mp4
    @param: $file_path - Path to the file to be written.
    @return: Array - ["data" => API response, "code" => API response status code]
*/

```

###### 2) Akamai::dir($akamai\_path);

[](#2-akamaidirakamai_path)

This method is used to list the files in a particular directory.

```
/*
    @param: $akamai_path - Directory path to be listed. ex: /cpcode/folder/path
    @return: Array - ["data" => API response, "code" => API response status code]
*/

```

###### 3) Akamai::download($akamai\_path);

[](#3-akamaidownloadakamai_path)

This method is to download a file

```
/*
    @param: $akamai_path - File location with file name and extension. ex: /cpcode/folder/path/file.mp4
    @return: Array - ["data" => API response (contents of file on success), "code" => API response status code]
*/

```

###### 4) Akamai::delete($akamai\_path);

[](#4-akamaideleteakamai_path)

This method is to delete a file

```
/*
    @param: $akamai_path - File location with file name and extension. ex: /cpcode/folder/path/file.mp4
    @return: Array - ["data" => API response, "code" => API response status code]
*/

```

###### 5) Akamai::rename($old\_akamai\_path, $new\_akamai\_path);

[](#5-akamairenameold_akamai_path-new_akamai_path)

This method is to rename a file

```
/*
    @param: $old_akamai_path - Existing file location with file name and extension. ex: /cpcode/folder/path/file.mp4
    @param: $new_akamai_path - Desired file location with file name and extension. ex: /cpcode/new_folder/new_path/new_file.mp4
    @return: Array - ["data" => API response, "code" => API response status code]
*/

```

###### 6) Akamai::rmdir($akamai\_path);

[](#6-akamairmdirakamai_path)

This method is to delete a directory. \[CAUTION: Directory has to be empty. (ie, list and delete all files individually before performing this API call)\].

```
/*
    @param: $akamai_path - Directory path to be deleted. ex: /cpcode/folder/path
    @return: Array - ["data" => API response, "code" => API response status code]
*/

```

###### 7) Akamai::mkdir($akamai\_path);

[](#7-akamaimkdirakamai_path)

This method is to create a directory.

```
/*
    @param: $akamai_path - Directory path to be added. ex: /cpcode/folder/path
    @return: Array - ["data" => API response, "code" => API response status code]
*/

```

###### 8) Akamai::generateToken($duration, $type);

[](#8-akamaigeneratetokenduration-type)

\[DEPRECATED\] Please use Token facade to generate video tokens

This method is to generate video authentication token.

```
/*
    @param: $duration - Time to live (ttl) of that token. (In seconds)
    @param: $type - It should be `hdnts` or `hdnea`.
    @return: String - Final token which has to be appended with the m3u8 request.
*/

```

#### 3) Akamai\\Facades\\Token

[](#3-akamaifacadestoken)

##### Introduction:

[](#introduction-2)

`Token` facade is used to generate video auth tokens.

##### Methods:

[](#methods-2)

###### 1) Token::generateVideoToken($duration, $type);

[](#1-tokengeneratevideotokenduration-type)

This method is to generate video authentication token.

```
/*
    @param: $duration - Time to live (ttl) of that token. (In seconds)
    @param: $type - It should be `hdnts` or `hdnea`.
    @return: String - Final token which has to be appended with the m3u8 request.
*/

```

---

### Usage sample

[](#usage-sample)

```
 200
     *           ]
     */
    $dirResponse = Akamai::dir('/cpcode/directory/to/list');

    /** @var array */
    $uploadResponse = Akamai::upload('/cpcode/path/to/file/testing.mp4', './testing.mp4');
    /** @var string */
    $uploadResponseData = $uploadResponse["data"];
    /** @var int */
    $uploadResponseCode = $uploadResponse["code"];

    /** @var array */
    $downloadResponse = Akamai::download('/cpcode/path/to/file/testing.mp4');
    if ($downloadReponse["code"] === 200) {
        file_put_contents('./testing.mp4', $downloadResponse["data"]);
    } else {
        // perform some error handling based on status code
    }

    /** @var array - ['data' => "could be simple string or xml string",'code' => 200] */
    $renameResponse = Akamai::rename('/cpcode/path/to/file/testing.mp4', '/cpcode/new_path/to/file/new_testing.mp4');

    /** @var array - ['data' => "could be simple string or xml string",'code' => 200] */
    $deleteResponse = Akamai::delete('/cpcode/newpath/to/file/new_testing.mp4');

    /** @var array - ['data' => "could be simple string or xml string",'code' => 200] */
    $mkdirResponse = Akamai::mkdir('/cpcode/new_dir');

    /** @var array - ['data' => "could be simple string or xml string",'code' => 200] */
    $rmdirResponse = Akamai::rmdir('/cpcode/new_dir');

    $token = Token::generateVideoToken(100, "hdnts");
    var_dump($token);
    /**
     * hdnts=st=1470130755~exp=1470130855~acl=*~hmac=99665898830y435t37487889hl672055956t9p7455e14g765c056i413u433125;
     */

} catch (Exception $e) {
    echo $e->getMessage();
}
```

\###Change Log:

\####v3.1.0 Thanks to [Julian Griggs](https://github.com/JulianGriggs)

1. New mkdir and rename functions

\####v3.0.0 Thanks to [Julian Griggs](https://github.com/JulianGriggs)

1. Standardization of API
2. Refactor
3. Document update
4. Removed unwanted test

\####v2.0.1 Thanks to [Julian Griggs](https://github.com/JulianGriggs)

1. Added missing return statement for `delete` method.

\####v2.0.0

1. New `Token` facade
2. Code refactor
3. Bug fixes
4. Deprecated `Akamai::generateToken($duration, $type)`

\####v1.1.1

1. Issue fix
2. Document update

\####v1.1.0

1. Added video token api for generating tokens for video based on duration.

\####v1.0.3

1. Code optimization

\####v1.0.2

1. Issue fixes

\####v1.0.1

1. Issue fixes

\####v1.0.0

1. Initial version with support for upload, list directory, download, remove directory and delete

#### NOTE: This package is based on [Akamai plugin by Raben](https://github.com/raben/Akamai/). So credits goes to him. I have added Video auth token with this and packaged it.

[](#note-this-package-is-based-on-akamai-plugin-by-raben-so-credits-goes-to-him-i-have-added-video-auth-token-with-this-and-packaged-it)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Recently: every ~29 days

Total

10

Last Release

3505d ago

Major Versions

v1.1.1 → v2.0.02016-08-02

v2.0.1 → v3.0.02016-10-21

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3783401?v=4)[Cerlin](/maintainers/talk2cerlin)[@talk2cerlin](https://github.com/talk2cerlin)

---

Top Contributors

[![talk2cerlin](https://avatars.githubusercontent.com/u/3783401?v=4)](https://github.com/talk2cerlin "talk2cerlin (4 commits)")

### Embed Badge

![Health badge](/badges/talk2cerlin-akamai/health.svg)

```
[![Health](https://phpackages.com/badges/talk2cerlin-akamai/health.svg)](https://phpackages.com/packages/talk2cerlin-akamai)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45344.0k1](/packages/pressbooks-pressbooks)[bacula-web/bacula-web

The open source web based reporting and monitoring tool for Bacula

1557.6k](/packages/bacula-web-bacula-web)[duxweb/dux-lite

The lightweight framework based on slim php

161.0k9](/packages/duxweb-dux-lite)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
