PHP code example of yii1tech / web

1. Go to this page and download the library: Download yii1tech/web 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/ */

    

yii1tech / web example snippets




return [
    'components' => [
        'request' => [
            'class' => yii1tech\web\HttpRequest::class,
            'trustedHosts' => [
                '192.168.0.0/24', // trust "forwarded" headers coming from IP addresses in range `192.168.0.0-192.168.0.254`
            ],
        ],
    ],
    // ...
];



var_dump(Yii::app()->request->getRemoteIP()); // returns IP of current HTTP connection, e.g. load balancer, outputs '192.168.0.1'
var_dump(Yii::app()->request->getUserIp()); // returns user IP address, considering "forwarded" headers, outputs '162.55.123.243'
var_dump(Yii::app()->request->getUserHostAddress()); // alias of `getUserIp()`

php composer.phar