Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
46726b3
Correcting doc-block declarations
Sep 8, 2021
d32bdac
Config class enhancements and more doc-block correction
Sep 8, 2021
06c2bfb
Asset library improvement
Oct 12, 2021
9fd6fab
Logic enhancement of Hooks
Oct 12, 2021
2d5128f
Debugger additional functionality
Oct 12, 2021
36ee4ca
Directory helper and structure changes
Oct 13, 2021
1aa1cca
Logic improvement of Database, Model and DBAL
Oct 13, 2021
0118492
Make Storage FileSystem library more flexible
Oct 13, 2021
efbe87f
Config class enhancements
Oct 13, 2021
f34460b
Adding ConfigException
Oct 13, 2021
1ad64df
Adding DatabaseException
Oct 13, 2021
a10d2fc
Updating the Environment class according to new setup
Oct 13, 2021
a51fd18
Minor updates on Di and StorageInterface
Oct 13, 2021
ed0e0a1
Adding DiException
Oct 13, 2021
d9e0ea4
Changing the term env to pathPrefex
Oct 13, 2021
3489e37
Improvement of getFilePath() method of Loader class
Oct 13, 2021
8b4202f
Template renderer improvements
Oct 13, 2021
7a01394
Improvement of Lang library
Oct 13, 2021
4cf4fe8
Logger cleanup
Oct 13, 2021
c2e200a
Console lib code cleanup and doc-block updates
Oct 13, 2021
071e934
VersionCommand
Oct 13, 2021
94c6e78
CommandInterface doc-bloc update
Oct 13, 2021
20ce76b
Enhancing the RouteController and update the hooks usage in Router
Oct 13, 2021
30377d7
Updating the Session library according to Database changes
Oct 13, 2021
f020498
Cleanup, doc-block update, and adding types for parameters/returns
Oct 13, 2021
ec4f127
Adding setBaseDir() and getBaseDir() methods
Oct 13, 2021
addd0cd
Updating the Bootstrap according to new Setup
Oct 13, 2021
c17c1c0
Unit tests according to new changes
Oct 13, 2021
b101c1d
Adding method declaration annotations
Oct 13, 2021
40bf2c4
Checking session table existence
Oct 13, 2021
46a257e
Checking template engine config existence
Oct 13, 2021
c1197aa
Removing @ sign as per recommendation
Oct 13, 2021
1b3fd90
Correcting doc-blocks and adding default values
Oct 13, 2021
e46dd8b
Adding special checks for MultiCurl
Oct 13, 2021
6977298
Adding new registerAsset() method to force parameter type hinting
Oct 13, 2021
2cfa0c8
Removing non existence reference
Oct 13, 2021
997e23d
Adding new exception methods
Oct 13, 2021
a53c51d
Checking the filename against null
Oct 13, 2021
ea1c34f
Syntax error fix
Oct 13, 2021
4983518
Correcting the statement check
Oct 13, 2021
a2f5d88
Correcting the end of line symbol linux vs windows
Oct 14, 2021
6f219c1
Doc-block update
Oct 14, 2021
6274d65
Adding $csrfVerification property to QtController
Oct 14, 2021
e3c8138
Correcting the variable name
Oct 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 43 additions & 9 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,52 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.5.0
* @since 2.6.0
*/

namespace Quantum;

use Quantum\Tracer\ErrorHandler;
use Quantum\Debugger\Debugger;
use Quantum\Di\Di;

if (!defined('DS')) define('DS', DIRECTORY_SEPARATOR);

/**
* Class App
* @package Quantum
*/
class App
{

/**
* @var string
*/
public static $baseDir = __DIR__;

/**
* Starts the app
* @param string $baseDir
* @throws \ErrorException
* @throws \Quantum\Exceptions\ConfigException
* @throws \Quantum\Exceptions\ControllerException
* @throws \Quantum\Exceptions\CsrfException
* @throws \Quantum\Exceptions\DatabaseException
* @throws \Quantum\Exceptions\DiException
* @throws \Quantum\Exceptions\EnvException
* @throws \Quantum\Exceptions\HookException
* @throws \Quantum\Exceptions\LangException
* @throws \Quantum\Exceptions\LoaderException
* @throws \Quantum\Exceptions\MiddlewareException
* @throws \Quantum\Exceptions\ModuleLoaderException
* @throws \Quantum\Exceptions\RouteException
* @throws \Quantum\Exceptions\SessionException
* @throws \Quantum\Exceptions\ViewException
* @throws \ReflectionException
* @throws \ErrorException
*/
public static function start()
public static function start(string $baseDir)
{
self::loadCoreFunctions();
self::loadCoreFunctions($baseDir . DS . 'vendor' . DS . 'quantum' . DS . 'framework' . DS . 'src' . DS . 'Helpers');

self::setBaseDir($baseDir);

Di::loadDefinitions();

Expand All @@ -52,11 +63,34 @@ public static function start()
Bootstrap::run();
}

public static function loadCoreFunctions()
/**
* Loads the core functions
* @param string $path
*/
public static function loadCoreFunctions(string $path)
{
foreach (glob(HELPERS_DIR . DS . 'functions' . DS . '*.php') as $filename) {
foreach (glob($path . DS . '*.php') as $filename) {
require_once $filename;
}
}

}
/**
* Sets the app base directory
* @param string $baseDir
*/
public static function setBaseDir(string $baseDir)
{
self::$baseDir = $baseDir;
}

/**
* Gets the app base directory
* @return string
*/
public static function getBaseDir(): string
{
return self::$baseDir;
}

}

24 changes: 15 additions & 9 deletions src/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.5.0
* @since 2.6.0
*/

namespace Quantum;

use Quantum\Exceptions\StopExecutionException;
use Quantum\Libraries\Database\Database;
use Quantum\Libraries\Storage\FileSystem;
use Quantum\Environment\Environment;
use Quantum\Libraries\Config\Config;
Expand All @@ -27,6 +28,7 @@
use Quantum\Loader\Loader;
use Quantum\Http\Response;
use Quantum\Http\Request;
use Quantum\Loader\Setup;
use Quantum\Di\Di;

/**
Expand All @@ -37,17 +39,18 @@ class Bootstrap
{

/**
* Boots the app
* @throws \Quantum\Exceptions\ConfigException
* @throws \Quantum\Exceptions\ControllerException
* @throws \Quantum\Exceptions\CsrfException
* @throws \Quantum\Exceptions\DatabaseException
* @throws \Quantum\Exceptions\DiException
* @throws \Quantum\Exceptions\EnvException
* @throws \Quantum\Exceptions\HookException
* @throws \Quantum\Exceptions\LangException
* @throws \Quantum\Exceptions\LoaderException
* @throws \Quantum\Exceptions\MiddlewareException
* @throws \Quantum\Exceptions\ModelException
* @throws \Quantum\Exceptions\ModuleLoaderException
* @throws \Quantum\Exceptions\RouteException
* @throws \Quantum\Exceptions\SessionException
* @throws \ReflectionException
*/
public static function run()
Expand All @@ -60,8 +63,9 @@ public static function run()

Debugger::initStore();

Environment::getInstance()->load($loader);
Config::getInstance()->load($loader);
Environment::getInstance()->load(new Setup('config', 'env'));

Config::getInstance()->load(new Setup('config', 'config'));

$request = Di::get(Request::class);
$response = Di::get(Response::class);
Expand All @@ -78,9 +82,11 @@ public static function run()
$loader->loadDir(base_dir() . DS . 'helpers');
$loader->loadDir(base_dir() . DS . 'libraries');

Lang::getInstance()
->setLang($request->getSegment(config()->get('lang_segment')))
->load($loader, $fs);
if (config()->has('langs')) {
Lang::getInstance()
->setLang($request->getSegment(config()->get('lang_segment')))
->load();
}

MvcManager::handle($request, $response);

Expand Down
3 changes: 1 addition & 2 deletions src/Console/CommandInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 1.7.0
* @since 2.6.0
*/

namespace Quantum\Console;
Expand All @@ -22,7 +22,6 @@ interface CommandInterface
{
/**
* Executes the current command.
* @return mixed
*/
public function exec();

Expand Down
3 changes: 1 addition & 2 deletions src/Console/Commands/DebugBarAssetsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class DebugBarAssetsCommand extends QtCommand

/**
* Executes the command and publishes the debug bar assets
* @return mixed|void
*/
public function exec()
{
Expand All @@ -71,7 +70,7 @@ public function exec()
* @param string $dst
* @throws \RuntimeException
*/
private function recursive_copy($src, $dst)
private function recursive_copy(string $src, string $dst)
{
$dir = opendir($src);

Expand Down
1 change: 0 additions & 1 deletion src/Console/Commands/EnvCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class EnvCommand extends QtCommand

/**
* Executes the command and creates new .env file
* @return mixed|void
*/
public function exec()
{
Expand Down
15 changes: 7 additions & 8 deletions src/Console/Commands/KeyGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.0.0
* @since 2.6.0
*/

namespace Quantum\Console\Commands;

use Quantum\Environment\Environment;
use Quantum\Console\QtCommand;
use Quantum\Loader\Loader;
use Quantum\Di\Di;
use Quantum\Loader\Setup;

/**
* Class KeyGenerateCommand
Expand Down Expand Up @@ -54,17 +53,17 @@ class KeyGenerateCommand extends QtCommand

/**
* Executes the command and stores the generated key to .env file
* @return mixed|void
* @throws \Quantum\Exceptions\DiException
* @throws \Quantum\Exceptions\EnvException
* @throws \ReflectionException
* @throws \Exception
*/
public function exec()
{
$key = $this->generateRandomKey();

$loader = Di::get(Loader::class);

if ($key) {
Environment::getInstance()->load($loader)->updateRow('APP_KEY', $key);
Environment::getInstance()->load(new Setup('config', 'env'))->updateRow('APP_KEY', $key);
}

$this->info('Application key successfully generated and stored.');
Expand All @@ -75,7 +74,7 @@ public function exec()
* @return string
* @throws \Exception
*/
private function generateRandomKey()
private function generateRandomKey(): string
{
return base64_encode(random_bytes((int) $this->getOption('length')));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,50 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.0.0
* @since 2.6.0
*/

namespace Quantum\Console\Commands;

use Quantum\Environment\Environment;
use Quantum\Console\QtCommand;
use Quantum\Loader\Loader;
use Quantum\Loader\Setup;
use Figlet\Figlet;
use Quantum\Di\Di;

/**
* Class WelcomeCommand
* Class VersionCommand
* @package Quantum\Console\Commands
*/
class WelcomeCommand extends QtCommand
class VersionCommand extends QtCommand
{

/**
* Command name
* @var string
*/
protected $name = 'core:welcome';
protected $name = 'core:version';

/**
* Command description
* @var string
*/
protected $description = 'Installation greetings';
protected $description = 'Core version';

/**
* Command help text
* @var string
*/
protected $help = 'Printing greetings into the terminal';
protected $help = 'Printing the current version of the framework into the terminal';

/**
* Executes the command and prints greetings into the terminal
* @return void
* @throws \Quantum\Exceptions\DiException
* @throws \Quantum\Exceptions\EnvException
* @throws \ReflectionException
*/
public function exec()
{
$loader = Di::get(Loader::class);

Environment::getInstance()->load($loader);
Environment::getInstance()->load(new Setup('config', 'env'));

$figlet = new Figlet();

Expand Down
Loading