Vestacp.php 860 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Heanup\Library;
  3. use ProfiCloS\VestaCP\Client;
  4. use ProfiCloS\VestaCP\ClientException;
  5. class Vestacp
  6. {
  7. private static $instance;
  8. /**
  9. * @var Client
  10. */
  11. private static $client;
  12. public function __construct()
  13. {
  14. $vst_hostname = \Heanup\App\Api\Config\Vestacp::getData("hostname");
  15. $vst_username = \Heanup\App\Api\Config\Vestacp::getData("username");
  16. $vst_password = \Heanup\App\Api\Config\Vestacp::getData("password");
  17. try {
  18. self::$client = Client::simpleFactory($vst_hostname, $vst_username, $vst_password);
  19. } catch (ClientException $e) {
  20. }
  21. }
  22. public static function getInstance(){
  23. if (!isset(self::$instance)) {
  24. $instance = new self();
  25. self::$instance = $instance;
  26. }
  27. return self::$client;
  28. }
  29. }