Net
The component Net
provides useful methods for dealing with domains as well as it is the maintainer of the domain repository of the Cloudrexx installation.
Contents
[hide]Domains
All mapped domains (managed by component NetManager
) of a Cloudrexx website are stored in a domain repository by the component Net
.
Net
provides the legacy environment variable $_CONFIG['domainUrl']
.Domain Repository
The domain repository holds the list of mapped domains of a Cloudrexx installation and can be accessed as follows:
$repo = $this->cx->getComponent('Net')->getDomainRepository();
The domain repository is a YamlRepository and does therefore provide the common getters findAll()
, find($id)
and findBy($criteria)
for fetching any of the mapped domains (instances of \Cx\Core\Net\Model\Entity\Domain
).
Main domain
The main domain (as set by configuration option Main domain under Administration > Global Configuration > System > Site) can be fetched as follows:
$repo = $this->cx->getComponent('Net')->getDomainRepository();
$domain = $repo->getMainDomain();
Hostname domain
The name of the server can be fetched as domain instance as follows:
$repo = $this->cx->getComponent('Net')->getDomainRepository();
$hostDomain = $repo->getHostDomain();
Hostname
The hostname of the server (as string) can be fetched as follows:
$hostname = $this->cx->getComponent('Net')->getHostname();
Helpers
Internationalized domain name conversion
Use the following helpers to convert an internationalized domain name into Punycode and vice-versa:
$punycode = $this->cx->getComponent('Net')->convertIdnToAsciiFormat($idnName);
$idnName = $this->cx->getComponent('Net')->convertIdnToUtf8Format($punycode);
Resolve hostname of IP
Get the hostname of an IP-address:
$host = $this->cx->getComponent('Net')->getHostByAddr($ip);
$ip
.