Class List
- App\Middleware\Cors
- App\Middleware\Auth
- App\Middleware\Env
- AppMin
- Application
- Route
- Data\Database
- Data\Db2Database
- Data\OdbcDatabase
- Data\Validator
- Data\KeyValue\SqliteStorage
- Data\Log\FileLogger
- Data\Log\HtmlLogger
- Encoding\Base64Url
- Encoding\Json
- Encoding\Utf8
- Environment\DotEnv
- Environment\System
- FileSystem\Search
- FileSystem\Security
- FileSystem\Sync
- Lang\I18N
- Lang\L10N
- Lang\Time
- Media\Image
- Net\Config
- Net\Email
- Net\HttpClient
- Net\HttpResponse
- Net\IP
- Net\SmtpClient
- Security\Crypto
- Security\Password
- Security\Crypto\Encryption
- Security\Crypto\FileEncryption
- Security\Crypto\JWT
- Security\Crypto\PublicKey
- Security\Crypto\Random
- Security\Crypto\SignedData
- Security\Web\CsrfSession
- Security\Web\CsrfStateless
- Security\Web\RateLimit
- Web\Request
- Web\Response
FastSitePHP\Net\Config
Network Configuration Info for your Server or Environment
Source Code
رمز المثال
Get Network and Server Info
// Create a Networking Config Object
$config = new \FastSitePHP\Net\Config();
// Get a (fqdn) 'fully-qualified domain name' for the server ['server.example.com']
$host = $config->fqdn();
// Get the Network IPv4 Address for the computer or server
$ip = $config->networkIp();
// Get a list of all IPv4 Addresses for the computer or server
$ip_list = $config->networkIpList();
// Get a text string of info from the server using one of the following commands:
// - Linux / Unix = [ip addr] or [ifconfig]
// - Mac = [ifconfig]
// - Windows = [ipconfig]
$info = $config->networkInfo();
// Convert the Network Info String to an Object
$info = $config->parseNetworkInfo($info);
Methods
fqdn()
Return a (fqdn) 'fully-qualified domain name' for the server that is running this script. A fqdn might not be available which will result in null being returned. This function performs a DNS lookup on the hostname of the server.
Returns: string | null 'server.example.com'
networkIp()
Return the IPv4 Address of the computer or server that is running the script. This can be used if a site is installed in an environment with multiple web servers to determine what server a specific user is accessing. If a computer is not connected to a network and PHP is running from a development environment then this function will likely return the localhost address '127.0.0.1' however if connected to the internet or a corporate network then this function will return the computer's network IP address. To get the IP Address of the Web Server Software see the function [FastSitePHP\Web\Request->serverIp()].
Returns: string | null
networkIpList()
Return any array of IPv4 Address of the computer or server that is running the script. Often a server will have more than 1 IP assigned.
Returns: array
networkInfo($all = false)
Return a string of Network Info from the OS. If Network info can't be determined then null will be returned. This function works with various OS's including Windows, Mac, and recent versions of Linux. It runs the following commands:
Win: ipconfig
ipconfig /all (If the optional [$all] parameter is true)
Mac: ifconfig
Other: ip addr
ifconfig
For Linux newer versions will typically include the [ip] command. For older versions of Linux or Unix OS's [ifconfig] will usually be used.
Returns: null
parseNetworkInfo($config_text, $exception_on_parse_error = false)
Parse Network Info that from the function [networkInfo()] from a string to a PHP Basic Object. By default an error will cause [null] to be returned unless the parameter [$exception_on_parse_error] is set to [true].
Returns: null | \stdClass