GithubHelp home page GithubHelp logo

webreinvent / laravel-cpanel Goto Github PK

View Code? Open in Web Editor NEW
21.0 6.0 11.0 45 KB

Laravel CPanel UAPI | Manage your CPanel from Laravel

Home Page: https://www.webreinvent.com

License: MIT License

PHP 100.00%
laravel laravel-package cpanel cpanel-uapi

laravel-cpanel's Introduction

Laravel CPanel

Laravel Package for CPanel UAPI

Please consider starring the project to show your ❤️ and support.

This laravel package allows you to manage you CPanel based hosting using CPanel UAPI.

Some practical usages are:

  • Programmatically create database, sub domains, emails or accounts etc
  • Programmatically create database users
  • Programmatically set privileges on database of any user

Learn more about at CPanel UAPI

Installation

Step 1) Install the Package

Use following composer command to install the package

composer require webreinvent/laravel-cpanel  

or Add webreinvent/laravel-cpanel as a requirement to composer.json:

{
    ...
    "require": {
        ...
        "webreinvent/laravel-cpanel": "dev-master"
    },
}

Update composer:

$ composer update

Step 2) Register the ServiceProvider

Add following service provider in config/app.php

/*  
 * Package Service Providers...  
 */ 
 'providers' => [  
        //...  
        WebReinvent\CPanel\CPanelServiceProvider::class,   
        //...  
    ],

Step 3) Publish Configurations

Run following command:

php artisan vendor:publish --provider="WebReinvent\CPanel\CPanelServiceProvider" --tag=config

Step 4) Set CPanel details in .env

CPANEL_DOMAIN= 
CPANEL_PORT=
CPANEL_API_TOKEN=
CPANEL_USERNAME=

or

$cpanel = new CPanel($cpanel_domain=null, $cpanel_api_token=null, $cpanel_username=null, $protocol='https', $port=2083);

To generate CPANEL_API_TOKEN, login to the CPanel >> SECURITY >> Manage API Tokens >> Create.

Usages & available methods

Make sure you import:

use WebReinvent\CPanel\CPanel;

To Create Database

Database name should be prefixed with cpanel username cpanelusername_databasename

If your CPanel username is foo then your database name | should be foo_website.

$cpanel = new CPanel();
$response = $cpanel->createDatabase('cpanelusername_databasename');

Find More Details at CPanel UAPI - Mysql::create_database

To Delete Database

$cpanel = new CPanel();  
$response = $cpanel->deleteDatabase('cpanelusername_databasename');

CPanel UAPI - Mysql::delete_database

To Get List of All Databases in the CPanel

$cpanel = new CPanel();  
$response = $cpanel->listDatabases();

To Create Database User

$cpanel = new CPanel();  
$response = $cpanel->createDatabaseUser($username, $password);

To Delete Database User

$cpanel = new CPanel();  
$response = $cpanel->deleteDatabaseUser($username);

To Give All Privileges to a Database User On a Database

$cpanel = new CPanel();  
$response = $cpanel->setAllPrivilegesOnDatabase($database_user, $database_name);

Those were the available method but you can also call all the method available at CPanel UAPI using following method:

$cpanel = new CPanel();  
$response = $cpanel->callUAPI($Module, $function, $parameters_array);

Example if you want to add new ftp account, documetation is available at CPanel UAPI - Ftp::add_ftp then use the method as represented below:

$cpanel = new CPanel();  
$Module = 'Ftp';
$function = 'add_ftp';
$parameters_array = [
'user'=>'ftp_username',
'pass'=>'ftp_password', //make sure you use strong password
'quota'=>'42',
];
$response = $cpanel->callUAPI($Module, $function, $parameters_array);

Support us

WebReinvent is a web agency based in Delhi, India. You'll find an overview of all our open source projects on github.

License

The MIT License (MIT). Please see License File for more information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.