PHPackages                             tuyenlaptrinh/php-mega-nz - 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. tuyenlaptrinh/php-mega-nz

ActiveLibrary[API Development](/categories/api)

tuyenlaptrinh/php-mega-nz
=========================

A php API wrapper to connect to mega.nz API

1.0(3y ago)023MITPHPPHP &gt;=5.3.0

Since Oct 18Pushed 3y ago1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (2)Used By (0)

php-mega-nz
===========

[](#php-mega-nz)

A php API wrapper to connect to mega.nz API, in full object oriented mode.

This library takes care of not disabling https certificate checking when calling for mega servers.

This API is in construction, only few of its methods are available, but contributions are welcome!

This library is inspired by the [smartinm/mega-php-client](https://github.com/smartinm/mega-php-client) library and the [tutorial by Julien Marchand](http://julien-marchand.fr/blog/using-the-mega-api-with-php-examples/).

Installation
------------

[](#installation)

The installation of this library is made via composer. Download `composer.phar` from [their website](https://getcomposer.org/download/). Then add to your composer.json :

```
	"require": {
		...
		"tuyenlaptrinh/php-mega-nz": "^1",
		...
	}
```

Then run `php composer.phar update` to install this library. The autoloading of all classes of this library is made through composer's autoloader.

Basic Usage
-----------

[](#basic-usage)

For downloading the files of a folder on mega, and put them into a folder on your filesystem, please look at [the example script](download_to_folder.php).

This library offers an API to see files, and download them, as follows :

The constructor needs the full url to access mega. This means that the url fragment should contains the node id, and the key to decode the node. `Mega::__construct(string $full_url):Mega`

Once a new `Mega` object is created, you may search for its root folder with the method : `Mega::getRootNodeInfo():MegaNode;`

Once you have a `MegaNode` object, you may search for its children with the method : `Mega::getChildren(MegaNodeId $node_id):MegaNode[];`

The `MegaNodeId` object may be obtained with the `MegaNode:getNodeId():MegaNodeId`method. Node Ids are common objects to refer to specific nodes in a hierarchy, and the `Mega` class may retrieve `MegaNode` objects with the method `Mega::getNodeInfo(MegaNodeId $node_id):MegaNode`.

To separate nodes that represents folders and node that represents files, use the `MegaNode::getNodeType():integer` method. If the value is `MegaNode::TYPE_FOLDER`, then the node represents a folder, and if the value is `MegaNode::TYPE_FILE`, then it represents a downloadable file.

Then, to download files (folders are not downloadable for obvious reasons), use the `Mega::downloadFile(MegaNode $node):string` method, that returns the raw string data of the downloaded file, unencrypted.

Beware that this method does not uses streams directly to your filesystem, and may use a lot of memory if the file is really big.

To check the size of a file (folders have no size given Mega's API), use the `MegaNode::getNodeSize():integer` method. Beware that 32 bits system (or 32 bits php as windows have) may not handle the file sizes for large files very well.

Finally, almost every method of this library throws `PhpExtended\Mega\MegaException`dues to various factors, mainly because cryptographic errors that may occur anywhere. Remember to encapsulate calls to this library with `try { ... } catch(MegaException $e) { ... }`blocks.

License
-------

[](#license)

MIT (See [license file](LICENSE)).

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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

1298d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e0e0f6dc215c0224ae731034c9e03203675be0ebd2c35f52987f29bfb93ff70a?d=identicon)[tuyenlaptrinh](/maintainers/tuyenlaptrinh)

---

Top Contributors

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

---

Tags

phpapiclientwrappermegamega.nzmega.co.nz

### Embed Badge

![Health badge](/badges/tuyenlaptrinh-php-mega-nz/health.svg)

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

###  Alternatives

[kunalvarma05/dropbox-php-sdk

Dropbox PHP API V2 SDK (Unofficial)

3633.0M18](/packages/kunalvarma05-dropbox-php-sdk)

PHPackages © 2026

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