Skip to content

Instantly share code, notes, and snippets.

@takaya030
Last active June 26, 2016 04:30
Show Gist options
  • Save takaya030/42c9a9347200044f00cdd00c79301181 to your computer and use it in GitHub Desktop.
Save takaya030/42c9a9347200044f00cdd00c79301181 to your computer and use it in GitHub Desktop.
Welcome Page for Lumen 5.2
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
/*
$app->get('/', function () use ($app) {
return $app->version();
});
*/
$app->get('/', [
// namespace App\Http\Controllers
'uses' => 'WelcomeController@index',
]);
<!DOCTYPE html>
<html>
<head>
<title>Lumen</title>
<link href='//fonts.googleapis.com/css?family=Lato:100' rel='stylesheet' type='text/css'>
<style>
body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
color: #B0BEC5;
display: table;
font-weight: 100;
font-family: 'Lato';
}
.container {
text-align: center;
display: table-cell;
vertical-align: middle;
}
.content {
text-align: center;
display: inline-block;
}
.title {
font-size: 96px;
margin-bottom: 40px;
}
.quote {
font-size: 24px;
}
.info {
font-size: 48px;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<div class="title">Lumen.</div>
<div class="info">Hostname: {{ gethostname() }}</div>
<div class="info">Server IP: {{ $server['SERVER_ADDR'] }}</div>
<div class="info">Client IP: {{ $client_ip }}</div>
@if ( array_key_exists('X-Forwarded-For', $server) )
<div class="info">X-Forwarded-For: {{ $server['X-Forwarded-For'] }}</div>
@elseif ( array_key_exists('HTTP_X_FORWARDED_FOR', $server) )
<div class="info">HTTP_X_FORWARDED_FOR: {{ $server['HTTP_X_FORWARDED_FOR'] }}</div>
@elseif ( array_key_exists('REMOTE_ADDR', $server) )
<div class="info">REMOTE_ADDR: {{ $server['REMOTE_ADDR'] }}</div>
@endif
</div>
</div>
</body>
</html>
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class WelcomeController extends Controller
{
public function index( Request $request )
{
$client_ip = $request->ip();
$server = $request->server(); // $_SERVER
return view('welcome', ['server' => $server, 'client_ip' => $client_ip]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment