Ai
1 Star 0 Fork 0

wfdaj/custom-php-mvc-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.php 1.51 KB
一键复制 编辑 原始数据 按行查看 历史
<?php
/**
* Application execution begins here.
*/
use Core\Session;
use Core\Cookie;
use Core\Router;
use App\Models\Users;
use Dotenv\Dotenv;
// Boiler plate imports.
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__));
require_once('vendor/autoload.php');
$dotenv = Dotenv::createImmutable(__DIR__);
$dotenv->load();
// Load configuration and helper functions.
require_once(ROOT . DS . 'config' . DS . 'config.php');
/**
* Auto-loading of classes using PSR-4 Support.
*
* @param string $className Path to file we will used for auto-loading
* classes that are used by this application.
* @return void
*/
function autoload($className) {
$classArray = explode('\\', $className);
$class = array_pop($classArray);
$subPath = strtolower(implode(DS, $classArray));
$path = ROOT . DS . $subPath . DS . $class . '.php';
if(file_exists($path)) {
require_once($path);
}
}
spl_autoload_register('autoload');
session_start();
// Create an array from our URL.
switch (SERVER_TYPE) {
case "nginx":
$url = isset($_SERVER['REQUEST_URI']) ? explode('/', ltrim($_SERVER['REQUEST_URI'], '/')) : [];
break;
default:
$url = isset($_SERVER['PATH_INFO']) ? explode('/', ltrim($_SERVER['PATH_INFO'], '/')) : [];
}
// Determine session and cooking status. Log in user if appropriate cookie exists.
if(!Session::exists(CURRENT_USER_SESSION_NAME && Cookie::exists(REMEMBER_ME_COOKIE_NAME))) {
Users::loginUserFromCookie();
}
// Route the request
Router::route($url);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wfdaj/custom-php-mvc-framework.git
git@gitee.com:wfdaj/custom-php-mvc-framework.git
wfdaj
custom-php-mvc-framework
custom-php-mvc-framework
main

搜索帮助