1. Go to this page and download the library: Download asamserver/wam library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
asamserver / wam example snippets
namespace WHMCS\Module\Addon\YourAddon\app\Controllers;
class DashboardController extends BaseController
{
public function index(array $vars)
{
return $this->renderView('admin.dashboard', [
'title' => 'Dashboard'
]);
}
}
use WHMCS\Module\Addon\YourAddon\app\Controllers\Admin\DashboardController;
$this->get('/admin/dashboard', DashboardController::class, 'index');
$this->get('/client/dashboard', ClientDashboardController::class, 'index');
namespace WHMCS\Module\Addon\YourAddon\app\Models;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $fillable = ['name', 'email'];
}
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email');
$table->timestamps();
});
}
}
namespace WHMCS\Module\Addon\YourAddon\app\Hooks;
class ClientLoginHook
{
public function handle(array $params)
{
// Hook logic here
}
}
public function index(array $vars)
{
return $this->renderView('admin.dashboard', [
'title' => 'Dashboard',
'data' => $someData
]);
}
// Get current client ID
$clientId = YourAddon_getClientId();
// Generate random number
$random = YourAddon_generateRandomNumber();
try {
// Your code here
} catch (\Exception $e) {
$this->hooksManager->log("Error: " . $e->getMessage(), 'ERROR');
}