Skip to content

Commit 91a7062

Browse files
committed
init
0 parents  commit 91a7062

File tree

8 files changed

+120
-0
lines changed

8 files changed

+120
-0
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/.phpunit.cache
2+
.env
3+
.env.backup
4+
.env.production
5+
.phpunit.result.cache
6+
/.fleet
7+
/.idea
8+
/.vscode
9+
/.php-cs-fixer.cache
10+
vendor
11+
composer.lock
12+
.rr.yaml
13+
rr
14+

app/Controller/Index.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
namespace App\Controller;
5+
use Simple\Framework\Controller;
6+
use Simple\Framework\Http\Response;
7+
use Simple\Framework\Http\ServerRequest;
8+
9+
class Index extends Controller
10+
{
11+
public function index(ServerRequest $request): Response
12+
{
13+
return $this->json('Hello World');
14+
}
15+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Middleware;
6+
7+
use Psr\Http\Message\ResponseInterface;
8+
use Psr\Http\Message\ServerRequestInterface;
9+
use Psr\Http\Server\MiddlewareInterface;
10+
use Psr\Http\Server\RequestHandlerInterface;
11+
12+
class NothingMiddleware implements MiddlewareInterface
13+
{
14+
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
15+
{
16+
return $handler->handle($request);
17+
}
18+
}

composer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "simple/simple",
3+
"type": "project",
4+
"autoload": {
5+
"psr-4": {
6+
"App\\": "app/"
7+
}
8+
},
9+
"authors": [
10+
{
11+
"name": "liutao",
12+
"email": "gg.cn.lt@gmail.com"
13+
}
14+
],
15+
"require": {
16+
"php": ">=8.0",
17+
"simple/framework": "dev-main"
18+
},
19+
"minimum-stability": "dev",
20+
"prefer-stable": true
21+
}

config/app.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
return [];

config/database.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
return [
6+
'default' => [
7+
'driver' => 'mysql',
8+
'host' => '127.0.0.1',
9+
'database' => 'test',
10+
'username' => 'root',
11+
'password' => 'root',
12+
'charset' => 'utf8mb4',
13+
'collation' => 'utf8mb4_unicode_ci',
14+
'prefix' => '',
15+
]
16+
];

config/routes.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use App\Controller\Index;
6+
use App\Middleware\NothingMiddleware;
7+
use League\Route\Router;
8+
use Nyholm\Psr7\Response;
9+
10+
$router = new Router();
11+
12+
$router->get('/', [Index::class, 'index'])->middleware(new NothingMiddleware());
13+
14+
$router->get('/favicon.ico', function () {
15+
return new Response(200, [], '');
16+
});
17+
return $router;

index.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Simple\Framework\Application;
6+
7+
require __DIR__.'/vendor/autoload.php';
8+
9+
date_default_timezone_set('Asia/Shanghai');
10+
11+
! defined('BASE_PATH') && define('BASE_PATH', __DIR__);
12+
13+
/** @noinspection PhpUnhandledExceptionInspection */
14+
Application::boot();

0 commit comments

Comments
 (0)