Skip to content

Instantly share code, notes, and snippets.

@andyvanee
Last active November 7, 2018 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andyvanee/4370835500e7534e669df8779483ab83 to your computer and use it in GitHub Desktop.
Save andyvanee/4370835500e7534e669df8779483ab83 to your computer and use it in GitHub Desktop.
Using PHP-PM to run PHP code without a framework
<?php
namespace MyApp;
use PHPPM\Bootstraps\ApplicationEnvironmentAwareInterface;
use Psr\Http\Message\ServerRequestInterface;
use RingCentral\Psr7\Response;
class MyHandler implements ApplicationEnvironmentAwareInterface {
public function __construct() {
// Application bootstrapping code goes here
}
public function initialize($appenv, $debug) {
// Environment-aware bootstrapping happens here.
// $appenv and $debug will match what is passed from the
// config file or command-line arguments
}
public function __invoke(ServerRequestInterface $request) {
$response = new Response(200, [], 'Hello World');
return $response;
}
}
{
"bridge": "PHPPM\\Bridges\\InvokableMiddleware",
"bootstrap": "MyApp\\MyHandler",
"host": "..."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment