swalker2 / laravel-cpanel by swalker

the simplest PHP implementation of the cpanel versio 2 api for Laravel
49
3
1
Package Data
Maintainer Username: swalker
Maintainer Contact: edu@rdo.blog.br (swalker2)
Package Create Date: 2017-01-31
Package Last Update: 2017-05-13
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-04-15 15:14:09
Package Statistics
Total Downloads: 49
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 3
Total Watchers: 1
Total Forks: 2
Total Open Issues: 0

#swalker2 - Cpanel

The simplest PHP implementation of the cpanel version 2 api for Laravel

At the moment suporting only the Zone Edit and Email modules

You can write your own modules if you dig into the Guide to cPanel API 2

Install

Require this package with composer using the following command:

composer require swalker2/cpanel

After updating composer, add the service provider to the providers array in config/app.php

Swalker2\Cpanel\CpanelServiceProvider::class,

Also, publish the configuration file using the following command:

php artisan vendor:publish --tag=swalker2.cpanel

Finally, add the .env variables:

CPANEL_HOST=https://domain.com
CPANEL_PORT=2083
CPANEL_USERNAME=yourname
CPANEL_PASSWORD=yourpass

But how do I use it?

After completing the instalation steps, you simply make a cpanel instance, like so:

	$cpanel = app()->make(Cpanel::class);

And then you can call the module implementations

	dd(
		$cpanel->zoneEdit('mydomain.com')->fetch()
	);

Note that the Modules that you create can be instantiated individually:

	$mymodule = new MyCpanelModule();
	dd(
		$mymodule->doSomething()
	);

Writing a module

To write a module you need to extend the class Swalker2\CpanelFunction like so:

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
    }
}

Contributing

Feel free to send pull requests, not just bug reports.

"Bug reports" may also be sent in the form of a pull request containing a failing test.

However, if you file a bug report, your issue should contain a title and a clear description of the issue. You should also include as much relevant information as possible and a code sample that demonstrates the issue. The goal of a bug report is to make it easy for yourself - and others - to replicate the bug and develop a fix.