Page MenuHomePhabricator

D555.id1752.diff
No OneTemporary

D555.id1752.diff

diff --git a/SpitFire.php b/SpitFire.php
--- a/SpitFire.php
+++ b/SpitFire.php
@@ -69,6 +69,35 @@
file_exists($file) && include($file);
}
+ /*
+ * Load the appropriate kernel for the user's intent. This is the main 'fork'
+ * in spitfire's logic.
+ */
+ if (php_sapi_name() === 'cli') {
+ $kernel = $this->provider->get(\spitfire\core\kernel\ConsoleKernel::class);
+ $kernel->boot();
+
+ /*
+ * The kernel needs to know which command to execute, the command will
+ * be written to argv[1]. From there on, the kernel can take over, arrange
+ * the arguments so they make sense to the command, and pass over control
+ * to the director that executes the script.
+ */
+ $_ret = $kernel->exec($argv[1], array_slice($argv, 2));
+ if (is_int($_ret)) { exit($_ret); }
+ }
+ else {
+ $kernel = $this->provider->get(\spitfire\core\kernel\WebKernel::class);
+ $kernel->boot();
+
+ /*
+ * Generate a request object that allows the kernel to work with an
+ * abstraction of the real request.
+ */
+ $response = $kernel->process(Request::fromServer());
+ $response->send();
+ }
+
#Check if there is a defualt app to receive calls to /
if (!collect($this->apps)->filter(function (App$e) { return !$e->url(); })->rewind()) {
$this->apps[] = new UnnamedApp('');

File Metadata

Mime Type
text/plain
Expires
Apr 12 2021, 1:10 PM (9 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5675
Default Alt Text
D555.id1752.diff (1 KB)

Event Timeline