Basic Framework
This commit is contained in:
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
Allow from 127.0.0.1
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
spl_autoload_register(function ($name) {
|
||||
$_name = lcfirst($name);
|
||||
|
||||
require_once __DIR__ . "/$_name/$_name.php";
|
||||
});
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
class Config
|
||||
{
|
||||
private static $instances = [];
|
||||
|
||||
private array $app;
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
$this->app = require_once __DIR__ . "/../../config/app.php";
|
||||
}
|
||||
|
||||
protected function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
public function __wakeup()
|
||||
{
|
||||
throw new \Exception("Cannot unserialize a singleton.");
|
||||
}
|
||||
|
||||
private static function getInstance(): Config
|
||||
{
|
||||
$cls = static::class;
|
||||
if (!isset(self::$instances[$cls])) {
|
||||
self::$instances[$cls] = new static();
|
||||
}
|
||||
|
||||
return self::$instances[$cls];
|
||||
}
|
||||
|
||||
public static function getBasePath()
|
||||
{
|
||||
return Config::getInstance()->app["basePath"];
|
||||
}
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
class Headers
|
||||
{
|
||||
static function json()
|
||||
{
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
header("Content-Type: text/json");
|
||||
}
|
||||
|
||||
static function html()
|
||||
{
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
}
|
||||
|
||||
static function redirect(string $newUrl, bool $permanent = FALSE)
|
||||
{
|
||||
header('Location: ' . $newUrl, true, $permanent ? 301 : 303);
|
||||
|
||||
exit();
|
||||
}
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
class Response
|
||||
{
|
||||
public static function api($content, int $code = 200)
|
||||
{
|
||||
Headers::json();
|
||||
http_response_code($code);
|
||||
echo json_encode($content);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user