use http\Env\Request;
use http\Env\Response;
+use http\Message\Body;
/**
* Request handler
$this->response->send();
}
+ /**
+ * Server a PHP stub
+ */
+ private function serveStub() {
+ $name = $this->request->getQuery("ref", "s");
+ $repo = $this->reference->getRepoForEntry($name);
+ if (!$repo->hasStub($stub)) {
+ throw new Exception(404, "Stub not found");
+ }
+ $this->response->setHeader("Content-Type", "application/x-php");
+ $this->response->setContentDisposition(["attachment" => ["filename" => "$name.stub.php"]]);
+ $this->response->setBody(new Body(fopen($stub, "r")));
+ $this->response->send();
+ }
+
/**
* Serve a preset
* @param \stdClass $pld
case "index.js":
$this->serveJavascript();
break;
+ case "stub":
+ $this->serveStub();
+ break;
default:
throw new Exception(404, "$pld->ref not found");
}