Flatten structure to better match current PHP practice.
This commit is contained in:
parent
51595c13eb
commit
f9aa2c7cb7
@ -19,7 +19,7 @@ server {
|
|||||||
|
|
||||||
# PHP routing - everything under /tkr goes through index.php
|
# PHP routing - everything under /tkr goes through index.php
|
||||||
location /tkr {
|
location /tkr {
|
||||||
alias /var/www/html/public;
|
alias /var/www/html/tkr/public;
|
||||||
index index.php;
|
index index.php;
|
||||||
|
|
||||||
# Cache static files
|
# Cache static files
|
||||||
@ -37,7 +37,7 @@ server {
|
|||||||
# so bots and scanners can't tell this is a php app
|
# so bots and scanners can't tell this is a php app
|
||||||
location = /tkr/index.php {
|
location = /tkr/index.php {
|
||||||
fastcgi_pass php:9000;
|
fastcgi_pass php:9000;
|
||||||
fastcgi_param SCRIPT_FILENAME /var/www/html/public/index.php;
|
fastcgi_param SCRIPT_FILENAME /var/www/html/tkr/public/index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
|
|
||||||
# Additional FastCGI params
|
# Additional FastCGI params
|
||||||
@ -60,7 +60,7 @@ server {
|
|||||||
# Fallback for /tkr routing - all non-file requests go to index.php
|
# Fallback for /tkr routing - all non-file requests go to index.php
|
||||||
location @tkr_fallback {
|
location @tkr_fallback {
|
||||||
fastcgi_pass php:9000;
|
fastcgi_pass php:9000;
|
||||||
fastcgi_param SCRIPT_FILENAME /var/www/html/public/index.php;
|
fastcgi_param SCRIPT_FILENAME /var/www/html/tkr/public/index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
|
|
||||||
# Additional FastCGI params
|
# Additional FastCGI params
|
||||||
|
@ -5,7 +5,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
volumes:
|
volumes:
|
||||||
- ./src:/var/www/html
|
- ./public:/var/www/html/tkr/public
|
||||||
- ./configs/nginx/folder.conf:/etc/nginx/conf.d/default.conf
|
- ./configs/nginx/folder.conf:/etc/nginx/conf.d/default.conf
|
||||||
depends_on:
|
depends_on:
|
||||||
- php
|
- php
|
||||||
@ -15,11 +15,14 @@ services:
|
|||||||
image: php:8.2-fpm-alpine
|
image: php:8.2-fpm-alpine
|
||||||
container_name: php-fpm
|
container_name: php-fpm
|
||||||
volumes:
|
volumes:
|
||||||
- ./src:/var/www/html
|
- ./public:/var/www/html/tkr/public
|
||||||
|
- ./src:/var/www/html/tkr/src
|
||||||
|
- ./storage:/var/www/html/tkr/storage
|
||||||
|
- ./templates:/var/www/html/tkr/templates
|
||||||
command: >
|
command: >
|
||||||
sh -c "
|
sh -c "
|
||||||
chown -R www-data:www-data /var/www/html/storage &&
|
chown -R www-data:www-data /var/www/html/tkr/storage &&
|
||||||
chmod -R 775 /var/www/html/storage &&
|
chmod -R 775 /var/www/html/tkr/storage &&
|
||||||
php-fpm
|
php-fpm
|
||||||
"
|
"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
define('APP_ROOT', dirname(dirname(__FILE__)));
|
define('APP_ROOT', dirname(dirname(__FILE__)));
|
||||||
|
|
||||||
define('CLASSES_DIR', APP_ROOT . '/classes');
|
define('CLASSES_DIR', APP_ROOT . '/src/classes');
|
||||||
define('LIB_DIR', APP_ROOT . '/lib');
|
define('LIB_DIR', APP_ROOT . '/src/lib');
|
||||||
define('STORAGE_DIR', APP_ROOT . '/storage');
|
define('STORAGE_DIR', APP_ROOT . '/storage');
|
||||||
define('TEMPLATES_DIR', APP_ROOT . '/templates');
|
define('TEMPLATES_DIR', APP_ROOT . '/templates');
|
||||||
|
|
||||||
@ -29,15 +29,9 @@ $isLoggedIn = isset($_SESSION['user_id']);
|
|||||||
$config = Config::load();
|
$config = Config::load();
|
||||||
$user = User::load();
|
$user = User::load();
|
||||||
|
|
||||||
// Define your base path (subdirectory)
|
// Get request data
|
||||||
#$basePath = '/tkr';
|
|
||||||
|
|
||||||
// Get HTTP data
|
|
||||||
$method = $_SERVER['REQUEST_METHOD'];
|
$method = $_SERVER['REQUEST_METHOD'];
|
||||||
$request = $_SERVER['REQUEST_URI'];
|
$request = $_SERVER['REQUEST_URI'];
|
||||||
|
|
||||||
// Remove the base path from the URL
|
|
||||||
// and strip the trailing slash from the resulting route
|
|
||||||
$path = parse_url($request, PHP_URL_PATH);
|
$path = parse_url($request, PHP_URL_PATH);
|
||||||
|
|
||||||
// return a 404 if s request for a .php file gets this far.
|
// return a 404 if s request for a .php file gets this far.
|
||||||
@ -47,6 +41,8 @@ if (preg_match('/\.php$/', $path)) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove the base path from the URL
|
||||||
|
// and strip the trailing slash from the resulting route
|
||||||
if (strpos($path, $config->basePath) === 0) {
|
if (strpos($path, $config->basePath) === 0) {
|
||||||
$path = substr($path, strlen($config->basePath));
|
$path = substr($path, strlen($config->basePath));
|
||||||
}
|
}
|
||||||
@ -77,10 +73,8 @@ function route($pattern, $callback, $methods = ['GET']) {
|
|||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
echo "Path: " . $path;
|
echo "Path: " . $path;
|
||||||
|
|
||||||
// Define your routes
|
// routes
|
||||||
route('', function() use ($isLoggedIn, $config, $user) {
|
route('', function() use ($isLoggedIn, $config, $user) {
|
||||||
#include TEMPLATES_DIR . "/home.php";
|
|
||||||
#echo render_home_page($isLoggedIn, $config, $user);
|
|
||||||
$page = isset($_GET['page']) ? max(1, (int)$_GET['page']) : 1;
|
$page = isset($_GET['page']) ? max(1, (int)$_GET['page']) : 1;
|
||||||
$limit = $config->itemsPerPage;
|
$limit = $config->itemsPerPage;
|
||||||
$offset = ($page - 1) * $limit;
|
$offset = ($page - 1) * $limit;
|
||||||
@ -95,4 +89,3 @@ route('', function() use ($isLoggedIn, $config, $user) {
|
|||||||
|
|
||||||
echo render_template(TEMPLATES_DIR . "/home.php", $vars);
|
echo render_template(TEMPLATES_DIR . "/home.php", $vars);
|
||||||
});
|
});
|
||||||
//isset($_SESSION['user_id'])
|
|
Loading…
x
Reference in New Issue
Block a user