PHPackages                             planetthecloud/mofh-callback-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. planetthecloud/mofh-callback-client

ActiveLibrary[API Development](/categories/api)

planetthecloud/mofh-callback-client
===================================

API Callback client for MyOwnFreeHost in PHP

1.2.0(4y ago)261[1 issues](https://github.com/PlanetTheCloud/mofh-callback-client/issues)Apache-2.0PHPPHP &gt;=7.4

Since Apr 29Pushed 4y ago2 watchersCompare

[ Source](https://github.com/PlanetTheCloud/mofh-callback-client)[ Packagist](https://packagist.org/packages/planetthecloud/mofh-callback-client)[ RSS](/packages/planetthecloud-mofh-callback-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

MyOwnFreeHost API Callback Client
=================================

[](#myownfreehost-api-callback-client)

An API callback client to parse the callback from [MyOwnFreeHost](https://myownfreehost.net/).

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

[](#installation)

This package is best installed through Composer:

```
composer require planetthecloud/mofh-callback-client

```

Usage
-----

[](#usage)

The `create` method accepts the following parameters:

- ip: IP address of MyOwnFreeHost.

**Where to find the IP address of MyOwnFreeHost?**
You can find the IP address from the [Reseller Panel](https://panel.myownfreehost.net/). Login and go to API -&gt; Setup WHM API -&gt; Select the domain you want to configure, and copy the IP address shown beside "MyOwnFreeHost IP address to connect to".

**Callback Handlers**
The following methods accepts a callable as the parameter.
These methods will be called accordingly with the callback from MyOwnFreeHost.
Here are the list of the methods and the parameters that will be given to the callable:

- onAccountActivated
    - username: vPanel username of the account.
    - raw: Raw callback data.
- onAccountSuspended
    - username: vPanel username of the account.
    - reason: Reason for suspension.
    - raw: Raw callback data.
    - common\_reason: Common reason for suspension, see `parseCommonSuspensionReason` section below.
- onAccountReactivated
    - username: vPanel username of the account.
    - raw: Raw callback data.
- onSqlServer
    - username: vPanel username of the account.
    - cluster: sql cluster of the account.
    - raw: Raw callback data.
- onAccountDeleted
    - username: vPanel username of the account.
    - raw: Raw callback data.

**Handler**
The `handle` method accepts the following parameters:

- data: Callback data from MyOwnFreeHost.
- ip: (optional) IP address of the caller. **NOT MyOwnFreeHost's IP**.

**Inspect Callback**
There are also methods to inspect the callback before and after it is handled.
The following methods accepts a callbable as the parameter:

- `beforeCallback`: called before the callback is handled.
- `afterCallback`: called after the callback is handled.

The callable will be given the following parameters:

- data: Callback data from MyOwnFreeHost.
- ip: (optional) IP address of the caller. **NOT MyOwnFreeHost's IP**.

on the `beforeCallback` method, you can set `$this->shouldHandle = false` to prevent the callback from being handled. It is not recommended to log the callback with `beforeCallback` as it is executed before any validation is performed.

**Parsing Common Suspension Reason**The `parseCommonSuspensionReason` method accepts the following parameters:

- reason: Raw suspension reason from MyOwnFreeHost. Which will either return null if the reason is not related to daily suspension, or the reason itself in a short form (eg. DAILY\_HIT, DAILY\_CPU, DAILY\_IO, DAILY\_EP).

Example
-------

[](#example)

```
use PlanetTheCloud\MofhCallbackClient\Callback;

// Create a new callback handler.
$callback = Callback::create([
    'ip' => '::1' // MyOwnFreeHost IP / Allowed caller IP address
]);

// Function to be executed when an account has been successfully activated
$callback->onAccountActivated(function ($username) {
    echo "Account successfully activated: {$username}";
});

// Function to be executed when an account has been suspended
$callback->onAccountSuspended(function ($username, $reason, ..., $common_reason) {
    echo "Account {$username} has been suspended with the following reason: {$reason}";
    if ($common_reason) {
        $reason = str_replace(['DAILY_EP', 'DAILY_CPU', 'DAILY_HIT', 'DAILY_IO'], ['Entry Process', 'CPU Usage', 'Website Hits', 'Input/Output'], $common_reason);
    }
    echo "Your account has been suspended because the daily {$reason} quota has been exhausted";
});

// Function to be executed when an account has been reactivated
$callback->onAccountReactivated(function ($username) {
    echo "Account {$username} has been reactivated";
});

// Function to be executed when SQL cluster callback is received
$callback->onSqlServer(function ($username, $cluster) {
    echo "Account {$username} has been moved to the {$cluster} cluster";
});

// Function to be executed when an account has been deleted
$callback->onAccountDeleted(function ($username) {
    echo "Account {$username} has been deleted";
});

// Function to be executed before the callback is handled
$callback->beforeCallback(function ($data, $ip) {
    // Do something before the callback is handled
    // Here are just an example
    if($data['status'] == 'SUSPENDED') {
        // This will skip handling of any callback with status SUSPENDED
        $this->shouldHandle = false;
    }
});

// Function to be executed after the callback is handled
$callback->afterCallback(function ($data, $ip) {
    file_put_contents('/tmp/mofh-callback-client.log', json_encode($data) . PHP_EOL, FILE_APPEND);
    echo "Callback has been logged to file";
});

// Wrap in a try-catch block. See Exception section for more information
try {
    $callback->handle($_POST);
} catch (\Exception $e) {
    echo $e->getMessage();
}
```

Exceptions
----------

[](#exceptions)

The following exceptions are thrown by the `handle` method:

- InvalidCallbackParameters: Thrown when the callback data is invalid.
- IpAddressMismatched: Thrown when the IP address of the caller does not match the allowed IP address given in the `create` method.

Support
-------

[](#support)

Support is offered for problems related to errors/bugs that may be present in the library.
If you seek programming support, this is not the place.
[![Join our Discord Server](https://camo.githubusercontent.com/5d7451822ad62f79e61a530fe3f67c4ff8c6370ed3c74b69304f6b11e284199d/68747470733a2f2f646973636f72646170702e636f6d2f6170692f6775696c64732f3339393432393436363536363432363633352f7769646765742e706e673f7374796c653d62616e6e657232 "Planet Dev Network")](https://discord.gg/mmEWpnwB8D)

License
=======

[](#license)

Copyright 2022 PlanetTheCloud

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

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

Every ~3 days

Total

3

Last Release

1464d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/planetthecloud-mofh-callback-client/health.svg)

```
[![Health](https://phpackages.com/badges/planetthecloud-mofh-callback-client/health.svg)](https://phpackages.com/packages/planetthecloud-mofh-callback-client)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M452](/packages/google-gax)

PHPackages © 2026

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