PHPackages                             jayasuryacodeingil/mega-php-client - 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. [API Development](/categories/api)
4. /
5. jayasuryacodeingil/mega-php-client

ActiveLibrary[API Development](/categories/api)

jayasuryacodeingil/mega-php-client
==================================

MEGA API Client Library for PHP.

v1.0.0(6mo ago)01MITPHPPHP ^8.0

Since Nov 7Pushed 6mo agoCompare

[ Source](https://github.com/jayasuryacodeingil/mega-php-client-master)[ Packagist](https://packagist.org/packages/jayasuryacodeingil/mega-php-client)[ Docs](https://github.com/smartinm/mega-php-client)[ RSS](/packages/jayasuryacodeingil-mega-php-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

MEGA PHP Client Library
=======================

[](#mega-php-client-library)

PHP client library for the [MEGA API](https://mega.co.nz/#developers).

*Note: This library is still under development and incomplete, so the API is subject to change.*

Requirements
------------

[](#requirements)

- PHP 5.x
- PHP Mcrypt extension
- PHP OpenSSL extension
- PHP cURL extension

Creating the client
-------------------

[](#creating-the-client)

### Using the constructor

[](#using-the-constructor)

```
$mega = new MEGA();
```

### Using a static factory method

[](#using-a-static-factory-method)

```
$mega = MEGA::create_from_login($email, $password);
```

This is equivalent to:

```
$mega = new MEGA();
$mega->user_login_session($email, $password);
```

### Changing the default MEGA API server

[](#changing-the-default-mega-api-server)

```
MEGA::set_default_server(MEGA::SERVER_EUROPE);
```

Working with public files
-------------------------

[](#working-with-public-files)

Download public files not require authentication.

### Gettings file info

[](#gettings-file-info)

```
$mega = new MEGA();

$file_info = $mega->public_file_info($ph, $key);
var_dump($file_info);

// Print filename and size
echo 'Filename: ' . $file_info['at']['n'];
echo 'Size: ' . $file_info['s'];
```

### Using links

[](#using-links)

```
$file_info = $mega->public_file_info_from_link($link);
```

This is equivalents to:

```
$info = MEGA::parse_link($link);
$file_info = $mega->public_file_info($info['ph'], $info['key']);
```

### Downloading public files

[](#downloading-public-files)

```
// Save file to current directory.
$filepath = $mega->public_file_save($ph, $key);
echo 'File saved in ' . $filepath;

// Equivalent using exported link
$filepath = $mega->public_file_save_from_link($link);
echo 'File saved in ' . $filepath;
```

See below for more examples.

Downloading files
-----------------

[](#downloading-files)

### Using streams

[](#using-streams)

```
// Write to file
$fp = fopen($file, 'wb');
$size = $mega->public_file_download($ph, $key, $fp);
fclose($fp);
```

### Returning content

[](#returning-content)

```
// Get content using temporary stream
$content = $mega->public_file_download($ph, $key);
```

### Saving to disk

[](#saving-to-disk)

```
// Save file to temporary directory.
$tmp = sys_get_temp_dir();
$file = $mega->public_file_save($ph, $key, $tmp);
echo 'File saved in ' . $file;
```

Private files
-------------

[](#private-files)

### Listing

[](#listing)

```
$mega = MEGA::create_from_user($email, $password);

$files = $mega->node_list();
print_r($files);

// Get file info
$file_info = $mega->node_file_info($files['f'][5]);
print_r($file_info);
```

### Downloading

[](#downloading)

- The `node_file_save()` function is equivalent to `public_file_save()`
- The `node_file_download()` function is equivalent to `public_file_download()`

User session
------------

[](#user-session)

### Saving session

[](#saving-session)

```
$mega = MEGA::create_from_user($email, $password);

// ...

// Get current session as a base64 string
$session = MEGA::session_save($mega);

// Store in a safe place!
db_store_session($session);
```

### Restoring session

[](#restoring-session)

```
// Retrive saved session
$session = db_get_session();

// Create client from previous session
$mega = MEGA::create_from_session($session);

// ...
```

Status
------

[](#status)

### Operations that don't require user authentication

[](#operations-that-dont-require-user-authentication)

MethodDescriptionStatus`public_file_info`Request public file infoImplemented`public_file_info_from_link`Request public file infoImplemented`public_file_download`Download a public fileImplemented`public_file_download_from_link`Download a public fileImplemented`public_file_save`Download and save a public file to diskImplemented`public_file_save_from_link`Download and save a public file to diskImplemented### Operations that require user authentication

[](#operations-that-require-user-authentication)

MethodDescriptionStatus`node_list`Retrieve folder or user nodesImplemented`node_file_info`Request file node infoImplemented`node_file_download`Download a file nodeImplemented`node_file_save`Download and save a file node to diskImplemented`node_add`Add/copy nodesNot implemented`node_delete`Delete nodeNot implemented`node_move`Move nodeNot implemented`node_update`Set node attributesNot implemented`node_publish` / `node_unpublish`Create/delete public handleNot implemented`node_share`Create/modify/delete outgoing shareNot implementedCredits
-------

[](#credits)

- This library has been written by Sergio Martín ([@smartinm](http://twitter.com/smartinm)) as a port of official MEGA Javascript code.
- Part of the code is based on the work done by [Julien Marchand](http://julien-marchand.fr/).
- This projected is licensed under the terms of the MIT license.

[![Bitdeli Badge](https://camo.githubusercontent.com/2c95bb35e8a93a0da2f51eff7a9c80ba72ffd365ba1f4a2277130ae841dc8034/68747470733a2f2f64327765637a68766c38323376302e636c6f756466726f6e742e6e65742f736d617274696e6d2f6d6567612d7068702d636c69656e742f7472656e642e706e67)](https://bitdeli.com/free "Bitdeli Badge")

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance67

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

192d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82255a1f38028b1dcfd10d9080150848383d15a296ddd7111df3aa9d9891f935?d=identicon)[ijayasurya](/maintainers/ijayasurya)

---

Top Contributors

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

---

Tags

apiclientmegamega.co.nz

### Embed Badge

![Health badge](/badges/jayasuryacodeingil-mega-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/jayasuryacodeingil-mega-php-client/health.svg)](https://phpackages.com/packages/jayasuryacodeingil-mega-php-client)
```

###  Alternatives

[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

1243.1k1](/packages/skeeks-yii2-google-api)

PHPackages © 2026

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