PHP code example of nilemin / php-http-virtualmin-api
1. Go to this page and download the library: Download nilemin/php-http-virtualmin-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nilemin / php-http-virtualmin-api example snippets
use Nilemin\Virtualmin\DNS\DNSRecord;
use Nilemin\Virtualmin\Managers\DNS\DNSRecordTypes;
use Nilemin\Virtualmin\Managers\Server\ServerTypes;
use Nilemin\Virtualmin\Managers\SSL\CSRInfo;
use Nilemin\Virtualmin\Virtualmin;
use Nilet\Components\Configuration\Config;
use Nilet\Components\FileSystem\Directory;
$dBManager = $api->createDatabaseManager();
$dBManager->createDatabase($domain, "mysqldbtest");
$dBManager->deleteDatabase($domain, "mysqldbtest");
$dBManager->fetchDatabasesNames($domain);
$dBManager->fetchDatabases($domain);
$dBManager->grantDatabaseAccess($domain, "emailaccount1", "test2");
$dBManager->grantDatabaseAccess($domain, "onlyftp1", "test1");
$dBManager->removeDatabaseAccess($domain, "emailaccount1", "test2");
$dBManager->removeDatabaseAccess($domain, "onlyftp1", "test1");
$vsManager = $api->createVirtualServerManager();
$vsManager->changeServerName($domain, "newdomain.org");
$vsManager->changeAdminPassword($domain, "7777");
$options = [
"dns",
"mail"
];
$vsManager->createSubServer("sub1.domain.org", $domain, "Sub 1", $options);
$vsManager->deleteServer("sub1.domain.org");
$vsManager->fetchAddonServers("domain");
$vsManager->fetchSubServers("domain");
$vsManager->fetchSubServersNames($domain, "domain");
$vsManager->fetchAddonServersNames($domain, "domain");
$vsManager->fetchServer($domain, ServerTypes::TOP_LEVEL_SERVER);
$vsManager->createServerAlias("domain-alias.org", "domain.org", "");
$vsManager->fetchAliasServers("domain");
$vsManager->addServerRedirect("domain.org", "/", "http://domain-redirect.org");
$vsManager->addServerRedirect("domain.org", "/asas", "http://domain-redirect-asas.org");
$vsManager->fetchServerRedirects($domain);
$vsManager->deleteServerRedirect($domain, "/");
$vsManager->deleteServerRedirect($domain, "/asas");
$dnsManager = $api->createDnsManager();
$dnsManager->addSpfHostnames($domain, ["domain-spf-test.org", "192.168.1"]);
$dnsManager->deleteSpfHostnames($domain, ["domain-spf-test.org", "192.168.1"]);
$dnsRecords = [
new DNSRecord("TXT-test1", DNSRecordTypes::TXT, "TXT test value", 666),
new DNSRecord("TXT-test2", DNSRecordTypes::TXT, "TXT test value", 777),
new DNSRecord("TXT-test4", DNSRecordTypes::TXT, "TXT test value", 777)
];
$dnsManager->deleteDnsRecords($domain, $dnsRecords);
$dnsManager->addDnsRecords($domain, $dnsRecords);
$dnsManager->fetchDNSRecords($domain);
$dnsManager->fetchSPFOptions($domain);
$sslManager = $api->createSslManager();
$csrInfo = new CSRInfo();
$csrInfo->setOrganization("Organization")
->setOrganizationUnit("unit")
->setCountryCode("dk")
->setState("MidtJylland")
->setCity("Viborg")
->setEmail("[email protected] ")
->setDomainName($domain);
echo $sslManager->generateCSR($csrInfo);
echo $sslManager->getCSRContent($domain);
$phpManager = $api->createPhpManager();
$phpManager->fetchPHPDirectories($domain);
$phpManager->fetchInstalledPHPVersions();
$phpManager->addPHPDirectory($domain, "test_php_dr2", "7.0");
$phpManager->addPHPDirectory($domain, "test_php_dr3", "5.6");
$phpManager->deletePHPDirectory($domain, "test_php_dr2");
$phpManager->deletePHPDirectory($domain, "test_php_dr3");
$phpManager->fetchPHPIniVars($domain, "7.0", $config->get("config")["userModifiableIniVars"]);
$phpManager->modifyPHPIniVars($domain, "7.0", ["max_execution_time" => 60, "display_errors" => 0]);
$scriptManager = $api->createScriptsManager();
$scriptManager->installCMS($domain, $config->get("config")["scripts"]["cms"]["wordpress"]);
$scriptManager->installPHPMyAdmin($domain, $config->get("config")["scripts"]["dbPanels"]["phpmyadmin"]);
$scriptManager->deleteScript($domain, "phpmyadmin");
$scriptManager->fetchInstalledScripts($domain);
$scriptManager->fetchInstalledScript($domain, "wordpress");
javascript
{
"/php-http-virtualmin-api": ">=v1.0"
}
}