| Server IP : 65.108.144.40 / Your IP : 216.73.217.165 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 User : dev ( 1000) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/project-slim/app/ |
Upload File : |
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use Slim\Factory\AppFactory;
use DI\ContainerBuilder;
use App\Bootstrap\EloquentBootstrap;
use App\Container\ServiceContainer;
// Load environment variables
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
$dotenv->load();
// Build DI container
$containerBuilder = new ContainerBuilder();
// Add service definitions
$containerBuilder->addDefinitions([
// Database settings
'db.settings' => [
'driver' => 'mysql',
'host' => $_ENV['DB_HOST'] ?? 'localhost',
'database' => $_ENV['DB_NAME'] ?? 'reporev',
'username' => $_ENV['DB_USER'] ?? 'root',
'password' => $_ENV['DB_PASS'] ?? '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
],
// JWT settings
'jwt.settings' => [
'secret' => $_ENV['JWT_SECRET'] ?? 'your-secret-key',
'algorithm' => $_ENV['JWT_ALGORITHM'] ?? 'HS256',
'expire_time' => (int)($_ENV['JWT_EXPIRE_TIME'] ?? 3600),
'refresh_expire_time' => (int)($_ENV['JWT_REFRESH_EXPIRE_TIME'] ?? 604800),
],
// App settings
'app.settings' => [
'displayErrorDetails' => $_ENV['APP_DEBUG'] ?? false,
'logErrors' => true,
'logErrorDetails' => true,
'name' => $_ENV['APP_NAME'] ?? 'RepoRev API',
'version' => $_ENV['APP_VERSION'] ?? '1.0.0',
'timezone' => $_ENV['APP_TIMEZONE'] ?? 'UTC',
],
// CORS settings
'cors.settings' => [
'origin' => $_ENV['CORS_ORIGIN'] ?? '*',
'methods' => ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
'headers' => ['X-Requested-With', 'Content-Type', 'Accept', 'Origin', 'Authorization'],
'credentials' => true,
],
// Email settings
'mail.settings' => [
'host' => $_ENV['MAIL_HOST'] ?? 'localhost',
'port' => (int)($_ENV['MAIL_PORT'] ?? 587),
'username' => $_ENV['MAIL_USERNAME'] ?? '',
'password' => $_ENV['MAIL_PASSWORD'] ?? '',
'encryption' => $_ENV['MAIL_ENCRYPTION'] ?? 'tls',
'from_address' => $_ENV['MAIL_FROM_ADDRESS'] ?? 'noreply@reporev.com',
'from_name' => $_ENV['MAIL_FROM_NAME'] ?? 'RepoRev',
],
// Cache settings
'cache.settings' => [
'driver' => $_ENV['CACHE_DRIVER'] ?? 'file',
'prefix' => $_ENV['CACHE_PREFIX'] ?? 'reporev_',
'ttl' => (int)($_ENV['CACHE_TTL'] ?? 3600),
],
// File upload settings
'upload.settings' => [
'max_size' => (int)($_ENV['UPLOAD_MAX_SIZE'] ?? 10485760), // 10MB
'allowed_types' => ['jpg', 'jpeg', 'png', 'gif', 'pdf', 'doc', 'docx'],
'upload_path' => $_ENV['UPLOAD_PATH'] ?? __DIR__ . '/../storage/uploads/',
],
]);
// Register services in container
ServiceContainer::registerServices($containerBuilder);
// Build container
$container = $containerBuilder->build();
// Initialize Eloquent ORM
EloquentBootstrap::boot($container->get('db.settings'));
// Create Slim app with container
AppFactory::setContainer($container);
$app = AppFactory::create();
// Set base path if needed
$basePath = $_ENV['APP_BASE_PATH'] ?? '';
if (!empty($basePath)) {
$app->setBasePath($basePath);
}
// Add error middleware
$errorMiddleware = $app->addErrorMiddleware(
$container->get('app.settings')['displayErrorDetails'],
$container->get('app.settings')['logErrors'],
$container->get('app.settings')['logErrorDetails']
);
// Add body parsing middleware
$app->addBodyParsingMiddleware();
// Add routing middleware
$app->addRoutingMiddleware();
return $app;