Last active
November 7, 2018 22:08
-
-
Save andyvanee/4370835500e7534e669df8779483ab83 to your computer and use it in GitHub Desktop.
Using PHP-PM to run PHP code without a framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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