first version
This commit is contained in:
parent
c30aa60694
commit
9b48a1a73f
9 changed files with 2777 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
.DS_Store
|
||||
vendor
|
||||
1
configure_and_start_colima.sh
Normal file
1
configure_and_start_colima.sh
Normal file
|
|
@ -0,0 +1 @@
|
|||
colima start --vm-type=vz --vz-rosetta --cpu 2 --memory 4
|
||||
14
prompts/libraries_to_include.txt
Normal file
14
prompts/libraries_to_include.txt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
composer require illuminate/database
|
||||
composer require slim/slim
|
||||
composer require tuupola/slim-jwt-auth
|
||||
composer require respect/validation
|
||||
composer require php-di/php-di
|
||||
composer require --dev phpstan/phpstan
|
||||
|
||||
Descriptions:
|
||||
- illuminate/database: The database component of the Laravel framework, providing an expressive Query Builder and Eloquent ORM. https://github.com/illuminate/database
|
||||
- slim/slim: A PHP micro framework that helps you quickly write simple yet powerful web applications and APIs. https://www.slimframework.com/
|
||||
- tuupola/slim-jwt-auth: PSR-7 and PSR-15 JWT Authentication Middleware for Slim framework. https://github.com/tuupola/slim-jwt-auth
|
||||
- respect/validation: The most engine-powered validation engine ever created for PHP. https://respect-validation.readthedocs.io/
|
||||
- php-di/php-di: The dependency injection container for humans. https://php-di.org/
|
||||
- phpstan/phpstan: PHP Static Analysis Tool - discover bugs in your code without writing tests. https://phpstan.org/
|
||||
42
tippspiel2/bootstrap/app.php
Normal file
42
tippspiel2/bootstrap/app.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
use DI\ContainerBuilder;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use Slim\App;
|
||||
use Slim\Factory\AppFactory;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
require __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
$containerBuilder = new ContainerBuilder();
|
||||
|
||||
// Load settings
|
||||
$settings = require __DIR__ . "/../config/settings.php";
|
||||
|
||||
$containerBuilder->addDefinitions([
|
||||
"settings" => $settings,
|
||||
Capsule::class => function (ContainerInterface $c) {
|
||||
$capsule = new Capsule;
|
||||
$capsule->addConnection($c->get("settings")["db"]);
|
||||
$capsule->setAsGlobal();
|
||||
$capsule->bootEloquent();
|
||||
return $capsule;
|
||||
},
|
||||
]);
|
||||
|
||||
$container = $containerBuilder->build();
|
||||
|
||||
// Trigger Eloquent initialization
|
||||
$container->get(Capsule::class);
|
||||
|
||||
AppFactory::setContainer($container);
|
||||
$app = AppFactory::create();
|
||||
|
||||
$app->addRoutingMiddleware();
|
||||
$app->addErrorMiddleware(
|
||||
$settings["settings"]["displayErrorDetails"],
|
||||
$settings["settings"]["logErrors"],
|
||||
$settings["settings"]["logErrorDetails"]
|
||||
);
|
||||
|
||||
return $app;
|
||||
23
tippspiel2/composer.json
Normal file
23
tippspiel2/composer.json
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "tippspiel2/tippspiel2",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "src/"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"illuminate/database": "^13.3",
|
||||
"slim/slim": "^4.15",
|
||||
"respect/validation": "^2.4",
|
||||
"php-di/php-di": "^7.1",
|
||||
"jimtools/jwt-auth": "^3.0",
|
||||
"slim/psr7": "^1.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "^2.1"
|
||||
},
|
||||
"config": {
|
||||
"audit": {
|
||||
}
|
||||
}
|
||||
}
|
||||
2650
tippspiel2/composer.lock
generated
Normal file
2650
tippspiel2/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
19
tippspiel2/config/settings.php
Normal file
19
tippspiel2/config/settings.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'db' => [
|
||||
'driver' => 'mysql',
|
||||
'host' => 'db',
|
||||
'database' => 'pf2_db',
|
||||
'username' => 'pf2_user',
|
||||
'password' => 'pf2_password',
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => '',
|
||||
],
|
||||
'settings' => [
|
||||
'displayErrorDetails' => true,
|
||||
'logErrorDetails' => true,
|
||||
'logErrors' => true,
|
||||
]
|
||||
];
|
||||
|
|
@ -1 +1,27 @@
|
|||
<?php phpinfo();
|
||||
<?php
|
||||
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
use Illuminate\Database\Capsule\Manager as Capsule;
|
||||
|
||||
/** @var \Slim\App $app */
|
||||
$app = require __DIR__ . "/../bootstrap/app.php";
|
||||
|
||||
$app->get("/", function (Request $request, Response $response) {
|
||||
$response->getBody()->write("Tippspiel 2 API is running with PHP-DI and Eloquent!");
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->get("/test-db", function (Request $request, Response $response) {
|
||||
try {
|
||||
/** @var Capsule $capsule */
|
||||
$capsule = $this->get(Capsule::class);
|
||||
$tables = $capsule->getConnection()->select("SHOW TABLES");
|
||||
$response->getBody()->write("Database Connection Successful! Tables found: " . count($tables));
|
||||
} catch (\Exception $e) {
|
||||
$response->getBody()->write("Database Connection Failed: " . $e->getMessage());
|
||||
}
|
||||
return $response;
|
||||
});
|
||||
|
||||
$app->run();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue