首页 > 解决方案 > I'm including this BurakBoz/CyberLink Library in my example project but it displays error for the sub classes included

问题描述

I'm trying to use a pre-built library to use Cyberpanel which is an opensource web hosting control panel but when I use it in my application it displays me error of Class not found, I've run command "composer require burakboz/cyberlink:dev-master" but it didn't help as well.

Error: Fatal error: Uncaught Error: Class 'phpseclib\Net\SSH2' not found in 
D:\PHP\xamp\htdocs\localphp\bornbee\CyberLink.php:42 Stack trace: #0 
D:\PHP\xamp\htdocs\localphp\bornbee\index.php(12): BurakBoz\CyberLink- 
>__construct('127.0.0.1', 'root', 'TopSecretPasswo...', NULL, 22, 10, false) 
#1 {main} thrown in D:\PHP\xamp\htdocs\localphp\bornbee\CyberLink.php on line 42

index.php (My example class)

<?php
    require("CyberLink.php");
    // If you need public key auth on ssh connection provide private key string to $key parameter otherwise it should be null.
    // $enableSecureFTP parameter should be true for using setCustomSSL method. 
    // If you don't need this don't set it true.
    $ip         = "127.0.0.1";
    $user       = "root"; // use only root user
    $password   = "TopSecretPassword"; // root password
    $port       = 22; // ssh port
    $timeout    = 20; // connection timeout
    $enableSecureFTP = false; // set it true if you use $cyberlink->setCustomSSL() method.
    $cyberlink  = new \BurakBoz\CyberLink($ip, $user, $password, $key = null, $port = 22, $timeout = 10, $enableSecureFTP = false);
    $phpVersion = "7.3";
    $owner      = "admin";
    $package    = "Default";
    try
    {
        if($cyberlink->createWebsite("merhaba.com", "admin@siteowner.com", $package, $owner, $phpVersion))
        {
            echo "Host created.";
        }
        else
        {
            echo "Error: " . $cyberlink->getLastMessage();
        }
    }
    catch (Exception $e)
    {
        echo "Error: " . $e->getMessage();
    }
?>

CyberLink Library https://github.com/BurakBoz/CyberLink/tree/master/src

标签: phpcakephpimportcomposer-php

解决方案


The problem was, I didn't include the autoloader.php in my index.php file as it demands the autoloader.php that has been created using composer command, which was needed alternately without requiring each php library.

require_once 'vendor/autoload.php';

推荐阅读