Skip to content

Instantly share code, notes, and snippets.

@indeyets
Created March 7, 2014 19:49
Show Gist options
  • Save indeyets/9418561 to your computer and use it in GitHub Desktop.
Save indeyets/9418561 to your computer and use it in GitHub Desktop.
Example of simple PHP application conversion to use https://github.com/indeyets/appserver-in-php
<?php
/**************************
* aip variant of php file
**************************/
class MyApp
{
public function __invoke($context)
{
$output = '<h1>Hello world</h1>';
if (isset($context['_GET']['name'])) {
$name = $context['_GET']['name'];
$output .= "<p>(hello to {$name} too</p>";
}
$headers = array(
'Content-type', 'text/html; charset=utf-8',
'Content-Length', strlen($output),
);
return array(200, $headers, $output);
}
}
<?php
/**********************
* usual php file
**********************/
header('Content-type: text/html; charset=utf-8');
echo "<h1>Hello world</h1>";
if (isset($_GET['name'])) {
$name = $_GET['name']
echo "<p>(hello to {$name} too</p>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment