1. Go to this page and download the library: Download swalker2/cpanel 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/ */
swalker2 / cpanel example snippets
Swalker2\Cpanel\CpanelServiceProvider::class,
$cpanel = app()->make(Cpanel::class);
dd(
$cpanel->zoneEdit('mydomain.com')->fetch()
);
$mymodule = new MyCpanelModule();
dd(
$mymodule->doSomething()
);
namespace App;
use Swalker2\Cpanel\CpanelBaseModule;
class CpanelModule extends CpanelBaseModule
{
function __construct()
{
parent::__construct();
$this->cpanel->mergeFields([
'cpanel_jsonapi_module' => 'ModuleName', //reference this from the Guide to cPanel API 2
]);
}
public function someAction()
{
$this->cpanel->mergeFields([
'cpanel_jsonapi_func' => 'some_action',
]);
$response = $this->getApiData();
//do something with the response
}
}