From 0fd8f1df5405e43251f59b12393dee3b905e14c1 Mon Sep 17 00:00:00 2001 From: Gabriel Oliveira Date: Fri, 26 Jul 2024 10:50:32 -0300 Subject: [PATCH] Updates to v1.6.1 --- .env.example | 3 +- app/config/Config.php | 294 ++++++++++++++++++++------------------- app/config/Routes.php | 23 ++- app/controllers/Main.php | 40 +++--- app/public/index.php | 39 +++--- composer.json | 1 + firefly | 42 +++--- nginx.conf | 2 +- 8 files changed, 225 insertions(+), 219 deletions(-) diff --git a/.env.example b/.env.example index a2d9bf0..a881a41 100644 --- a/.env.example +++ b/.env.example @@ -8,8 +8,9 @@ # WARNING: This file should not be commited to your application source control as it may contain sensitive data. # --------------------------------------------------------------------------------------------------------------- -# Current environment name +# Current environment name and URL APP_ENV=development +APP_URL=http://localhost # Application debug APP_DEBUG=true diff --git a/app/config/Config.php b/app/config/Config.php index d8a97e2..8a63b5e 100644 --- a/app/config/Config.php +++ b/app/config/Config.php @@ -1,129 +1,133 @@ Env::get('APP_ENV', 'development'), + // Current environment name + 'env' => Env::get('APP_ENV', 'development'), - // Application maintenance mode - 'maintenance' => [ + // Application maintenance mode + 'maintenance' => [ - // Enable maintenance mode - 'enabled' => filter_var( - Env::get('APP_MAINTENANCE', false), - FILTER_VALIDATE_BOOLEAN), + // Enable maintenance mode + 'enabled' => filter_var( + Env::get('APP_MAINTENANCE', false), + FILTER_VALIDATE_BOOLEAN + ), - // Maintenance mode bypass key - 'bypass_key' => Env::get('MAINTENANCE_KEY') + // Maintenance mode bypass key + 'bypass_key' => Env::get('MAINTENANCE_KEY') - ], + ], - // Skeltch templating engine - 'skeltch' => [ + // Skeltch templating engine + 'skeltch' => [ - // Enable Skeltch compiler - 'enabled' => true, + // Enable Skeltch compiler + 'enabled' => true, - // Enable views caching - 'cache' => true, + // Enable views caching + 'cache' => true, - // Cache files location - 'path' => sys_get_temp_dir() + // Cache files location + 'path' => sys_get_temp_dir() - ], + ], - // Application error reporting - 'error_reporting' => [ + // Application error reporting + 'error_reporting' => [ - // Error reporting level - 'level' => filter_var( - Env::get('APP_DEBUG', true), - FILTER_VALIDATE_BOOLEAN) ? E_ALL : 0, + // Error reporting level + 'level' => filter_var( + Env::get('APP_DEBUG', true), + FILTER_VALIDATE_BOOLEAN + ) ? E_ALL : 0, - // Enable error logging - 'logging' => true, + // Enable error logging + 'logging' => true, - // Error log file location - 'file' => Util::location('../error.log') + // Error log file location + 'file' => Util::location('../error.log') - ], + ], - // Application session management - 'session' => [ + // Application session management + 'session' => [ - // Session cookie name - 'name' => 'app_session', + // Session cookie name + 'name' => 'app_session', - // Unused session lifetime - 'lifetime' => 120, + // Unused session lifetime + 'lifetime' => 120, - // Number of requests when to run the garbage collector - 'gc_cleaning' => 50, + // Number of requests when to run the garbage collector + 'gc_cleaning' => 50, - // Session files location - 'path' => sys_get_temp_dir(), + // Session files location + 'path' => sys_get_temp_dir(), - // Allow session usage only in secure connections (https) - 'secure' => false, + // Allow session usage only in secure connections (https) + 'secure' => false, - // Restrict session access to the HTTP protocol only - 'restrict' => true + // Restrict session access to the HTTP protocol only + 'restrict' => true - ], + ], - // Application cookies management - 'cookies' => [ + // Application cookies management + 'cookies' => [ - // Allow cookies usage only through secure connections (https) - 'secure' => false, + // Allow cookies usage only through secure connections (https) + 'secure' => false, - // Restrict cookies access to the HTTP protocol only - 'restrict' => true + // Restrict cookies access to the HTTP protocol only + 'restrict' => true - ], + ], - // Application secret keys - 'secret' => [ + // Application secret keys + 'secret' => [ - // Key used in encrypting functions - 'app_key' => Env::get('APP_KEY'), + // Key used in encrypting functions + 'app_key' => Env::get('APP_KEY'), - // Token used in encrypting functions - 'app_token' => Env::get('APP_TOKEN') + // Token used in encrypting functions + 'app_token' => Env::get('APP_TOKEN') - ], + ], - // Application database connection settings - 'database' => [ + // Application database connection settings + 'database' => [ - // Default connection - 'default' => [ - 'host' => Env::get('DB_HOST', 'localhost'), - 'username' => Env::get('DB_USERNAME', 'root'), - 'password' => Env::get('DB_PASSWORD', ''), - 'db' => Env::get('DB_DATABASE', 'glowie'), - 'port' => Env::get('DB_PORT', 3306), - 'charset' => 'utf8', - 'strict' => false - ] + // Default connection + 'default' => [ + 'host' => Env::get('DB_HOST', 'localhost'), + 'username' => Env::get('DB_USERNAME', 'root'), + 'password' => Env::get('DB_PASSWORD', ''), + 'db' => Env::get('DB_DATABASE', 'glowie'), + 'port' => Env::get('DB_PORT', 3306), + 'charset' => 'utf8', + 'strict' => false + ] - ], + ], - // Authentication settings - 'auth' => [ + // Authentication settings + 'auth' => [ + // Default auth guard + 'default' => [ // Users model 'model' => null, @@ -132,88 +136,88 @@ // Password field name 'password_field' => 'password' + ] - ], - - // Migrations settings - 'migrations' => [ + ], - // Migrations history table name - 'table' => 'migrations' + // Migrations settings + 'migrations' => [ - ], + // Migrations history table name + 'table' => 'migrations' - // Cache settings - 'cache' => [ + ], - // Cache file path - 'path' => sys_get_temp_dir() . '/' . md5(Util::location()) . '.tmp' + // Cache settings + 'cache' => [ - ], + // Cache file path + 'path' => sys_get_temp_dir() . '/' . md5(Util::location()) . '.tmp' - // Cross-Origin Resource Sharing (CORS) settings - 'cors' => [ + ], - // Enable CORS headers - 'enabled' => true, + // Cross-Origin Resource Sharing (CORS) settings + 'cors' => [ - // List of allowed methods (use * for all) - 'allowed_methods' => ['*'], + // Enable CORS headers + 'enabled' => true, - // List of allowed origins (use * for all) - 'allowed_origins' => ['*'], + // List of allowed methods (use * for all) + 'allowed_methods' => ['*'], - // List of allowed headers (use * for all) - 'allowed_headers' => ['*'], + // List of allowed origins (use * for all) + 'allowed_origins' => ['*'], - // List of exposed headers - 'exposed_headers' => [], + // List of allowed headers (use * for all) + 'allowed_headers' => ['*'], - // Preflight request cache time - 'max_age' => 0, + // List of exposed headers + 'exposed_headers' => [], - // Allow credentials to be exposed - 'allow_credentials' => false + // Preflight request cache time + 'max_age' => 0, - ], + // Allow credentials to be exposed + 'allow_credentials' => false - // Application plugins - 'plugins' => [], + ], - // Firefly Sandbox settings - 'sandbox' => [ + // Application plugins + 'plugins' => [], - // Sandbox class alias list - 'alias' => [ - 'Factory' => \Glowie\Core\Database\Factory::class, - 'Kraken' => \Glowie\Core\Database\Kraken::class, - 'Model' => \Glowie\Core\Database\Model::class, - 'Skeleton' => \Glowie\Core\Database\Skeleton::class, - 'Rails' => \Glowie\Core\Http\Rails::class, - 'Cache' => \Glowie\Core\Tools\Cache::class, - 'Crawler' => \Glowie\Core\Tools\Crawler::class, - 'Mailer' => \Glowie\Core\Tools\Mailer::class, - 'Validator' => \Glowie\Core\Tools\Validator::class, - 'Collection' => \Glowie\Core\Collection::class, - 'Element' => \Glowie\Core\Element::class - ] + // Firefly Sandbox settings + 'sandbox' => [ - ], + // Sandbox class alias list + 'alias' => [ + 'Factory' => \Glowie\Core\Database\Factory::class, + 'Kraken' => \Glowie\Core\Database\Kraken::class, + 'Model' => \Glowie\Core\Database\Model::class, + 'Skeleton' => \Glowie\Core\Database\Skeleton::class, + 'Rails' => \Glowie\Core\Http\Rails::class, + 'Queue' => \Glowie\Core\Queue\Queue::class, + 'Cache' => \Glowie\Core\Tools\Cache::class, + 'Crawler' => \Glowie\Core\Tools\Crawler::class, + 'Mailer' => \Glowie\Core\Tools\Mailer::class, + 'Validator' => \Glowie\Core\Tools\Validator::class, + 'Collection' => \Glowie\Core\Collection::class, + 'Element' => \Glowie\Core\Element::class + ] - // Application miscellaneous settings - 'other' => [ + ], - // Application URL (for CLI route mocking only) - 'url' => 'http://localhost', + // Application miscellaneous settings + 'other' => [ - // Default language - 'language' => 'en', + // Application URL (for CLI route mocking only) + 'url' => Env::get('APP_URL', 'http://localhost'), - // Default timezone - 'timezone' => 'America/Sao_Paulo' + // Default language + 'language' => 'en', - ] + // Default timezone + 'timezone' => 'America/Sao_Paulo' - ]; + ] -?> \ No newline at end of file +]; diff --git a/app/config/Routes.php b/app/config/Routes.php index 7093d0c..2267a61 100644 --- a/app/config/Routes.php +++ b/app/config/Routes.php @@ -1,16 +1,15 @@ \ No newline at end of file +// Home +Rails::addRoute('/', Main::class, 'index'); diff --git a/app/controllers/Main.php b/app/controllers/Main.php index 182e252..51f94ac 100644 --- a/app/controllers/Main.php +++ b/app/controllers/Main.php @@ -1,26 +1,26 @@ response->setBody('Glowie is awesome!'); - } +/** + * Main controller for Glowie application. + * @category Controller + * @package glowieframework/glowie + * @author Glowie + * @copyright Copyright (c) Glowie + * @license MIT + * @link https://gabrielsilva.dev.br/glowie + */ +class Main extends Controller +{ + /** + * Index action. + */ + public function index() + { + $this->response->setBody('Glowie is awesome!'); } - -?> \ No newline at end of file +} diff --git a/app/public/index.php b/app/public/index.php index 2856a26..1065824 100644 --- a/app/public/index.php +++ b/app/public/index.php @@ -1,27 +1,26 @@ Composer packages were not found!
+ --------------------------------------------- + We do not recommend editing below this line. + --------------------------------------------- +*/ + +// Check Composer files +if (!file_exists('../../vendor/autoload.php')) { + die('Composer packages were not found!
Have you tried running composer install?'); - } +} - // Load Composer packages - require('../../vendor/autoload.php'); +// Load Composer packages +require('../../vendor/autoload.php'); - // Run Glowie bootstrapper - Application::run(); - -?> \ No newline at end of file +// Run Glowie bootstrapper +Application::run(); diff --git a/composer.json b/composer.json index 50aac86..9431bcc 100644 --- a/composer.json +++ b/composer.json @@ -28,6 +28,7 @@ "psr-4": { "Glowie\\Commands\\": "app/commands/", "Glowie\\Controllers\\": "app/controllers/", + "Glowie\\Jobs\\": "app/jobs/", "Glowie\\Middlewares\\": "app/middlewares/", "Glowie\\Migrations\\": "app/migrations/", "Glowie\\Models\\": "app/models/", diff --git a/firefly b/firefly index f70af73..8f26123 100644 --- a/firefly +++ b/firefly @@ -1,27 +1,29 @@ \ No newline at end of file +// Run Firefly +Firefly::run(); diff --git a/nginx.conf b/nginx.conf index 26f6a1e..558863a 100644 --- a/nginx.conf +++ b/nginx.conf @@ -40,4 +40,4 @@ server { include snippets/fastcgi-php.conf; fastcgi_pass php_upstream; } -} +} \ No newline at end of file