Skip to content

Commit

Permalink
优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
chengyao committed Oct 17, 2024
1 parent 8e3b450 commit f52fc3c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 35 deletions.
34 changes: 0 additions & 34 deletions app/App.php

This file was deleted.

12 changes: 12 additions & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,25 @@
* @license https://github.com/next-laboratory/next/blob/master/LICENSE
*/

use Dotenv\Dotenv;

date_default_timezone_set('PRC');

if (function_exists('base_path') === false) {
function base_path(string $path = ''): string
{
return BASE_PATH . ltrim($path, '/');
}
}

if (file_exists($envFile = base_path('.env'))) {
if (method_exists('Dotenv\Dotenv', 'createUnsafeImmutable')) {
Dotenv::createUnsafeImmutable(base_path())->load();
} else {
Dotenv::createMutable(base_path())->load();
}
}

if (function_exists('public_path') === false) {
function public_path(string $path = ''): string
{
Expand Down
3 changes: 2 additions & 1 deletion public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
use App\ServerRequest;
use Next\Http\Server\RequestHandler;

require_once '../app/bootstrap.php';
define('BASE_PATH', dirname(__DIR__) . '/');
require_once BASE_PATH . 'vendor/autoload.php';

(new RequestHandler())
->withMiddleware(
Expand Down

0 comments on commit f52fc3c

Please sign in to comment.