Compare commits
2 Commits
63dcfcdde5
...
5fb463598a
Author | SHA1 | Date | |
---|---|---|---|
5fb463598a | |||
4a44aef764 |
11
.gitignore
vendored
11
.gitignore
vendored
@ -1,8 +1,5 @@
|
|||||||
# ---> Composer
|
# Composer dependencies
|
||||||
composer.phar
|
vendor/
|
||||||
/vendor/
|
|
||||||
|
|
||||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
|
|
||||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
|
|
||||||
# composer.lock
|
|
||||||
|
|
||||||
|
# PHP CodeSniffer cache
|
||||||
|
.phpcs-cache
|
||||||
|
2
LICENSE
2
LICENSE
@ -1,4 +1,4 @@
|
|||||||
Copyright (c) <year> <owner>
|
Copyright (c) 2022 Bit Goblin
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
4
bin/run-php.sh
Executable file
4
bin/run-php.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# start a local instance of the app using PHP's built-in webserver
|
||||||
|
php -S localhost:8080 -t public/ public/index.php
|
25
composer.json
Normal file
25
composer.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "bitgoblin/goliath",
|
||||||
|
"description": "Open source internal ticketing system",
|
||||||
|
"type": "project",
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"BitGoblin\\Goliath\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Gregory Ballantine",
|
||||||
|
"email": "gballantine@bitgoblin.tech"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"minimum-stability": "stable",
|
||||||
|
"require": {
|
||||||
|
"slim/slim": "^4.11",
|
||||||
|
"slim/psr7": "^1.6",
|
||||||
|
"php-di/php-di": "^6.4",
|
||||||
|
"slim/twig-view": "^3.3",
|
||||||
|
"hassankhan/config": "^3.0"
|
||||||
|
}
|
||||||
|
}
|
1450
composer.lock
generated
Normal file
1450
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
6
conf/defaults.json
Normal file
6
conf/defaults.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"database": {
|
||||||
|
"driver": "sqlite",
|
||||||
|
"database": "./data/goliath.db"
|
||||||
|
}
|
||||||
|
}
|
5
public/.htaccess
Normal file
5
public/.htaccess
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# rewrite rules
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteRule ^ index.php [QSA,L]
|
24
public/index.php
Normal file
24
public/index.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// if we're looking for static files in dev, return false so they can be served.
|
||||||
|
if (PHP_SAPI == 'cli-server') {
|
||||||
|
$url = parse_url($_SERVER['REQUEST_URI']);
|
||||||
|
$file = __DIR__ . $url['path'];
|
||||||
|
|
||||||
|
// check the file types, only serve standard files
|
||||||
|
if (preg_match('/\.(?:png|js|jpg|jpeg|gif|css)$/', $file)) {
|
||||||
|
// does the file exist? If so, return it
|
||||||
|
if (is_file($file))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// file does not exist. return a 404
|
||||||
|
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
|
||||||
|
printf('"%s" does not exist', $_SERVER['REQUEST_URI']);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../src/app.php';
|
||||||
|
|
||||||
|
$app->run();
|
||||||
|
|
19
src/Controllers/Controller.php
Normal file
19
src/Controllers/Controller.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BitGoblin\Goliath\Controllers;
|
||||||
|
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
|
class Controller {
|
||||||
|
|
||||||
|
protected $container;
|
||||||
|
|
||||||
|
public function __construct(ContainerInterface $container) {
|
||||||
|
$this->container = $container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get(string $name) {
|
||||||
|
return $this->container->get($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
16
src/Controllers/HomeController.php
Normal file
16
src/Controllers/HomeController.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BitGoblin\Goliath\Controllers;
|
||||||
|
|
||||||
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
|
use Slim\Views\Twig;
|
||||||
|
|
||||||
|
class HomeController extends Controller {
|
||||||
|
|
||||||
|
public function getIndex(Request $request, Response $response): Response {
|
||||||
|
$view = Twig::fromRequest($request);
|
||||||
|
return $view->render($response, 'index.twig');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
35
src/app.php
Normal file
35
src/app.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use DI\Container;
|
||||||
|
use Noodlehaus\Config;
|
||||||
|
use Noodlehaus\Parser\Json;
|
||||||
|
use Slim\Factory\AppFactory;
|
||||||
|
use Slim\Views\Twig;
|
||||||
|
use Slim\Views\TwigMiddleware;
|
||||||
|
|
||||||
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
// Load app configuration
|
||||||
|
$config = Config::load(__DIR__ . '/../conf/defaults.json');
|
||||||
|
|
||||||
|
// Create new container object and add our config object to it
|
||||||
|
$container = new Container();
|
||||||
|
$container->set('config', function () use ($config) {
|
||||||
|
return $config;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set container to create App with on AppFactory
|
||||||
|
AppFactory::setContainer($container);
|
||||||
|
$app = AppFactory::create();
|
||||||
|
|
||||||
|
// Add Error Handling Middleware
|
||||||
|
$app->addErrorMiddleware(true, false, false);
|
||||||
|
|
||||||
|
// Create Twig
|
||||||
|
$twig = Twig::create(__DIR__ . '/../views', ['cache' => false]);
|
||||||
|
|
||||||
|
// Add Twig-View Middleware
|
||||||
|
$app->add(TwigMiddleware::create($app, $twig));
|
||||||
|
|
||||||
|
// load in route handlers
|
||||||
|
require_once __DIR__ . '/routes.php';
|
8
src/routes.php
Normal file
8
src/routes.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
|
use Slim\Views\Twig;
|
||||||
|
|
||||||
|
// index GET route - this page should welcome the user and direct them to the available actions
|
||||||
|
$app->get('/', '\\BitGoblin\\Goliath\\Controllers\\HomeController:getIndex')->setName('index');
|
7
views/index.twig
Normal file
7
views/index.twig
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{% extends 'layout.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Home{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<p>This is a test.</p>
|
||||||
|
{% endblock %}
|
14
views/layout.twig
Normal file
14
views/layout.twig
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{% block title %}{% endblock %} | Goliath</title>
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css">
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user