adelynx/cpanel

此包已被 弃用 并不再维护。未建议替代包。
关于此包最新版本(1.0)没有可用的许可证信息。

cPanel API 包

1.0 2013-06-10 02:29 UTC

This package is auto-updated.

Last update: 2021-08-05 11:49:58 UTC


README

由 Adel KEDJOUR 为 Laravel 4 开发的 cPanel API 包(a.kedjour@corex.dz

安装

首先,通过 Composer 安装此包。编辑您项目的 composer.json 文件,以添加 adelynx/cpanel

"require": {
	"laravel/framework": "4.0.*",
	"adelynx/cpanel": "dev-master"
}

接下来,从终端更新 Composer

composer update

此操作完成后,添加服务提供者、别名和配置文件。

1 - 提供者:打开 app/config/app.php,并将新项目添加到 providers 数组中。

'Adelynx\Cpanel\CpanelServiceProvider'

2 - 别名:将文件 Facades/Cpanel.php 复制到 /you_project_dir/vendor/laravel/framework/src/Illuminate/Support/Facades,并将新项目添加到 aliases 数组中。

'Cpanel' => 'Illuminate\Support\Facades\Cpanel',

3 - Cpanel 配置:将文件 config/cpanel.php 复制到 you_project_dir/app/config/ 文件夹中,并将新项目添加到 aliases 数组中。

'Cpanel' => 'Illuminate\Support\Facades\Cpanel',

最后一步是配置您的 cpanel.php 配置文件

<?php

return array(

    // should debugging statements be printed?
    'debug' => true,

    // The host to connect to (Eg: 127.0.0.1 or yourwebsite.com or whm.yourwebsite.com)
    'host' => '127.0.0.1',

    // the port to connect to
    'port' => '2087',

    // should be the literal strings http or https
    'protocol' => 'https',

    // output that should be given by the cpanel api (xml or json)
    'output' => 'json',

    // literal strings hash or password
    'auth_type' => 'password',

    //  the actual password or hash
    'auth' => 'your_cpanel_password or your_cpanel_hash',

    // username to authenticate as
    'user' => 'your_cpanel_username',

    // The HTTP Client to use
    'http_client' => 'curl'

);

就这么多!您已准备好出发了。

使用方法

<?php

class CpanelController extends Controller {

    public function getListAccounts()
    {        
         try {

                $listaccts = array(json_decode(Cpanel::listaccts(), true));
                return $listaccts;

         } catch (Exception $e) {
                return 'Exception: ' .$e->getMessage();
         }      

    }

}