rmunate/info-server

This package is abandoned and no longer maintained. No replacement package was suggested.

The System Library allows you to query all information related to existing server-side variables, values, and configurations (Server Variables, Environment Variables, PHP Values, and Configurations). It provides an easy and convenient way to work with server data.

v2.3.0 2023-09-08 18:32 UTC

This package is auto-updated.

Last update: 2024-01-07 19:22:53 UTC


README

This package allows you to access all information related to server-side variables, values, and configurations (Server Variables, Environment Variables, PHP Values, and their configurations). It provides an easy and convenient way to work with server data.

⚙️ This library is compatible with Laravel versions 8.0 and above ⚙️

Laravel 8.0+ Laravel 9.0+ Laravel 10.0+

logo-info-server

📖 DOCUMENTATION IN SPANISH 📖

Table of Contents

Installation

To install the package via Composer, execute the following command:

composer require rmunate/info-server

Available Methods

PHP Information

Method Description and Return
PHP::uname() Retrieves the operating system on which PHP is running.
PHP::version() Retrieves the current PHP version in "major.minor.edition[extra]" notation.
PHP::majorversion() Retrieves the current "major version" of PHP as an integer (e.g., int(5) in version "5.2.7-extra").
PHP::minorVersion() Retrieves the current "minor version" of PHP as an integer (e.g., int(2) in version "5.2.7-extra").
PHP::releaseVersion() Retrieves the PHP release version.
PHP::versionId() Retrieves the PHP version id.
PHP::extraVersion() Retrieves the PHP "extra" version as a string (e.g., '-extra' in version "5.2.7-extra"). Often used by distributors to indicate the package version.
PHP::maxpathlen() Retrieves the maximum length of file (including directories) names supported by the PHP build.
PHP::os() Retrieves the operating system for which PHP was built.
PHP::osFamily() Retrieves the family of operating systems for which PHP was built. Can be 'Windows', 'BSD', 'OSX', 'Solaris', 'Linux', or 'Unknown'. Available since PHP 7.2.0.
PHP::intMax() Retrieves the largest integer supported in this PHP build. Normally int(2147483647) on 32-bit systems and int(9223372036854775807) on 64-bit systems.
PHP::intMin() Retrieves the smallest integer supported in this PHP build. Normally int(-2147483648) on 32-bit systems and int(-9223372036854775808) on 64-bit systems. Typically, PHP_INT_MIN === ~PHP_INT_MAX.
PHP::intSize() Retrieves the size of an integer in bytes in this PHP build.
PHP::floatDig() Retrieves the number of decimal digits that can be rounded and reversed in a floating-point number without loss of precision. Available since PHP 7.2.0.
PHP::floatEpsilon() Retrieves the smallest positive floating-point number x such that x + 1.0 != 1.0. Available since PHP 7.2.0.
PHP::floatMin() Retrieves the smallest positive floating-point number that can be represented. To get the smallest representable negative floating-point number, use -PHP_FLOAT_MAX. Available since PHP 7.2.0.
PHP::floatMax() Retrieves the largest floating-point number that can be represented. Available since PHP 7.2.0.
PHP::getIniSettings() Retrieves the complete information of PHP configuration (php.ini settings). Returns an associative array with configuration settings or null if there is an error.
PHP::getActiveExtensions() Retrieves the list of active PHP extensions. Returns an array with the names of active extensions or null if there is an error.

Usage Examples

use Rmunate\InfoServer\Wrappers\PHP;

PHP::floatMin(); 
//2.2250738585072E-308

PHP::intMax(); 
//9223372036854775807

PHP::version()
//"8.1.21"

Environment Variables

Retrieve any available value in the environment variables and validate if the variable exists.

Method Description and Return
Environment::has($key) Determines if the given configuration value exists.
Environment::get($key, $default = null) Gets the environment variable with the given key. If not found, returns the default value (if provided).
Environment::all() Gets all environment variables.

Usage Examples

use Rmunate\InfoServer\Wrappers\Environment;

Environment::has("APP_NAME"); 
//true

Environment::get("APP_NAME","UNDEFINED"); 
//CODE MAESTRO

Environment::all()
// {#401 ▼ // routes/web.php:45
//   +"APP_NAME": "CODE MAESTRO"
//   +"APP_KEY": "base64:c3FCNjkhomKMSHgE5gxF5gy7qrswb77iFXUA1YvGvJE="
//   +"APP_DEBUG": "true"
//   +"APP_URL": "http://localhost"
//   ...

Server Information

Finally, you have a range of methods to know server values.

Method Description
Server::has($variable) Verifies if a specific server variable is defined.
Server::get($variable) Gets the value of a specific server variable.
Server::all() All data variable $_SERVER.
Server::user() Gets the user running the PHP script, if available.
Server::home() Gets the home directory of the user, if available.
Server::scriptName() Gets the current script's path and name. Useful for self-referencing pages.
Server::requestUri() Gets the URI used to access the page.
Server::queryString() Gets the query string of the current request, if available.
Server::requestMethod() Gets the request method used to access the page.
Server::protocol() Gets the name and revision number of the information protocol through which the page was requested.
Server::gatewayInterface() Gets the CGI specification revision used by the server.
Server::redirectUrl() Gets the URL after the redirection, if available.
Server::remotePort() Gets the port used by the user's machine to communicate with the web server.
Server::scriptFilename() Gets the absolute path and name of the currently running script.
Server::admin() Gets the value of the SERVER_ADMIN directive (from Apache) in the server's configuration file. If the script is running on a virtual host, the value will be the one defined for that virtual host.
Server::contextDocumentRoot() Gets the document root of the current script without a trailing slash.
Server::contextPrefix() Method without documentation for newer Apache versions.
Server::requestScheme() Gets the scheme used in the request, either "HTTP" or "HTTPS".
Server::documentRoot() Gets the server's root directory as defined in the server's configuration file.
Server::remoteAddr() Gets the IP address from which the current user is viewing the page.
Server::port() Gets the server's port used for communication. By default, the value will be '80'. If SSL is used, for example, this value will change to the one defined for the secure HTTP port.
Server::addr() Gets the IP address of the server where the script is currently running.
Server::name() Gets the name of the server where the script is currently running. If the script is running on a virtual host, the value will be the one defined for that virtual host.
Server::software() Gets the server software identification string provided in the response headers to requests.
Server::signature() Gets the server signature string containing the server's version and virtual host name. It is added to pages generated by the server if this feature is enabled.
Server::path() Gets the value of the PATH environment variable. Returns the raw value of the 'Cookie' header sent by the user agent.
Server::httpCookie() Gets the 'Cookie' header sent by the user agent.
Server::httpAcceptLanguage() Gets the 'Accept-Language' header of the current request, if available.
Server::httpAcceptEncoding() Gets the 'Accept-Encoding' header of the current request, if available.
Server::httpSecFetchDest() Gets the 'Sec-Fetch-Dest' header of the current request, if available.
Server::httpSecFetchUser() Gets the 'Sec-Fetch-User' header of the current request, if available.
Server::httpSecFetchMode() Gets the 'Sec-Fetch-Mode' header of the current request, if available.
Server::httpSecFetchSite() Gets the 'Sec-Fetch-Site' header of the current request, if available.
Server::httpAccept() Gets the 'Accept' header of the current request, if available.
Server::httpUserAgent() Gets the 'User-Agent' header of the current request, if available. This is a string indicating the user agent used to access the page.
Server::httpUpgradeInsecureRequests() Gets the value of the 'Upgrade-Insecure-Requests' header of the current request, if available.
Server::httpSecChUaPlatform() Gets the platform of the user's connection, if available.
Server::httpSecChUaMobile() Gets the mobile connection platform, if available.
Server::httpHost() Gets the 'Host' header of the current request, if available.
Server::requestTimeFloat() Gets the timestamp of the request start with microsecond precision. Available since PHP 5.4.0.
Server::requestTime() Gets the Unix timestamp of the request start. Available since PHP 5.1.0.

Usage Examples

use Rmunate\InfoServer\Wrappers\Server;

Server::software();
//"PHP 8.1.21 Development Server"

Server::httpAccept();
//"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"

Server::has("AWS_ACCESS_KEY_ID");
//true - false

Creator

License

This project is under the MIT License.

🌟 Support My Projects! 🚀

Make any contributions you see fit; the code is entirely yours. Together, we can do amazing things and improve the world of development. Your support is invaluable. ✨

If you have ideas, suggestions, or just want to collaborate, we are open to everything! Join our community and be part of our journey to success! 🌐👩‍💻👨‍💻