/** * @return \Core\Database */ protected static function getClearDatabase() { $db = new \Core\Database('mysql:host=' . TEST_DB_HOST . ';dbname=' . TEST_DB_NAME . ';charset=utf8', TEST_DB_USER, TEST_DB_PASSWORD, 'appointments', '\\Utility\\DatabaseCreateScript'); $clearScript = new \Helpers\TablesClearScript(); foreach ($clearScript as $statement) { $db->exec($statement, array()); } return $db; }
public function testProducerFirst() { $app = new Core\App(); $app->link('database', Core\Database::connect()); $app->link('cachemanager', Core\Cache::init()); $app->link('success', true); Core\Sharer::share('app', $app); $test = Core\Sharer::get(); if ($test['app']->success == true) { $this->assertTrue(true); } else { $this->assertTrue(false); } $this->assertTrue(true); return 'first'; }
* Use HTTPS connection when necessary, needs to config apache/nginx manually */ define('HTTPS_SUPPORT', true); /** * Enable debug mode: * Disable debug mode will hide backtrace information, which is helpful for developer */ define('DEBUG_ENABLE', true); /** * Real time mode: * This option will disable i18n / router / template cache, development only. * DO NOT TURN ON THIS OPTION IN PRODUCTION!!! */ define('REAL_TIME_MODE', false); /** * Base URL: * To manually config this, uncomment the following line and change the URL * To use auto detect, keep this commented */ // define('BASE_URL', 'http://www.kookxiang.com'); Core\Request::autoDetectBaseURL(); /** * Set i18n translation file * If you don't need this, simply comment out the following line */ Core\I18N::setTranslationFile(LIBRARY_PATH . 'Language/en-US.yml'); /** * Database Connection: */ Core\Database::initialize('mysql:dbname=test;host=localhost;charset=UTF8', 'root', '');
* Rewrite setting: * remove "index.php" from url, needs to config apache/nginx manually */ define('USE_REWRITE', true); /** * HTTPS support: * Use HTTPS connection when necessary, needs to config apache/nginx manually */ define('HTTPS_SUPPORT', false); /** * Enable debug mode: * Disable debug mode will hide backtrace information, which is helpful for developer */ define('DEBUG_ENABLE', true); /** * Check template and resource file update automatically * You can turn off this on production environment. */ define('TEMPLATE_UPDATE', true); /** * Base URL: * To manually config this, uncomment the following line and change the URL * To use auto detect, keep this commented */ // define('BASE_URL', 'http://www.kookxiang.com'); Core\Request::autoDetectBaseURL(); /** * Database Connection: */ Core\Database::register('mysql:dbname=sspanel;host=localhost;charset=UTF8', 'user', 'password');
<?php require_once "vendor/autoload.php"; $config = json_decode(file_get_contents(__DIR__ . "/config.json")); # Declaration des objets qui vont nous servir if (isset($config) && !empty($config)) { $databaseChecker = new Core\DatabaseChecker($config->database_host, $config->database_name, $config->database_user, $config->database_password); $database = new Core\Database($config->database_host, $config->database_name, $config->database_user, $config->database_password); } else { $databaseChecker = new Core\DatabaseChecker("127.0.0.1", "test_orm", "root", "root"); $database = new Core\Database("127.0.0.1", "test_orm", "root", "root"); } if (!isset($argv[1]) && empty($argv[1])) { $argv[1] = "default"; } # Un switch pour gerer les differents cas d'argument switch ($argv[1]) { # Generer un ficher de configuration case "--config": if (!empty($argv[2]) && isset($argv[2], $argv[3], $argv[4], $argv[5])) { if (\Core\Generator::createConfigFile($argv[2], $argv[3], $argv[4], $argv[5])) { echo "[0;34m" . "Le fichier de configuration a bien été créé, il est disponible ici :\n" . __DIR__ . "/config.json"; } else { echo "[1;31m" . "Le fichier de configuration n'a pas pu être créer"; } } else { echo "[1;31m" . "Pour generer un fichier de configuration, merci d'utiliser la commande suivante :\nphp suporm --config DATABASE_HOST DATABASE_NAME DATABASE_USER DATABASE_PASSWORD"; } break; # Retourne l'etat de la connexion a la base de donnee # Retourne l'etat de la connexion a la base de donnee
|-------------------------------------------------------------------------- | | Damn Stupid Simple uses the Singleton to simplify coordinations, while | maintaining only one instantiation of a class. | */ $app = new Core\App(); /* |-------------------------------------------------------------------------- | Linking to the Database Connector |-------------------------------------------------------------------------- | | Connect the database for only once. Save the planet. | */ $app->link('database', Core\Database::connect()); /* |-------------------------------------------------------------------------- | Starting the Caching Engine |-------------------------------------------------------------------------- | | This is our favourite part. Minimize the resource usage, maximize our | capabilities. | */ $app->link('cachemanager', Core\Cache::init()); /* |-------------------------------------------------------------------------- | Share the Singleton $app with the Template Files |-------------------------------------------------------------------------- |
<head> <title>Conference Scheduler</title> </head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"> <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <body> <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); require_once "Autoloader/Autoloader.php"; require 'kint/Kint.class.php'; use Autoloader\Autoloader; use IdentitySystem\IdentityUser; Autoloader::init(); $dbName = "SoftUniProject"; \IdentitySystem\codeFirstModelBuilder\system::databaseBuilder($dbName); Core\Database::setInstance(\Config\DatabaseConfig::DB_INSTANCE, \Config\DatabaseConfig::DB_DRIVER, \Config\DatabaseConfig::DB_USER, \Config\DatabaseConfig::DB_PASS, $dbName, \Config\DatabaseConfig::DB_HOST); \IdentitySystem\codeFirstModelBuilder\system::createIdentityTables(); $dbFirstModelBuilder = new dbFirstModelBuilder\dbFirstModelBuilder(); $dbFirstModelBuilder->createdbFirstModels(); include_once "app.php"; $app = new app($_GET['uri']); $app->run(); ?> </body> </html>
* Use HTTPS connection when necessary, needs to config apache/nginx manually */ define('HTTPS_SUPPORT', true); /** * Enable debug mode: * Disable debug mode will hide backtrace information, which is helpful for developer */ define('DEBUG_ENABLE', false); /** * Logger: */ define('LOG_LEVEL', 4); /** * Base URL: * To manually config this, uncomment the following line and change the URL * To use auto detect, keep this commented */ // define('BASE_URL', 'http://www.kookxiang.com'); Core\Request::autoDetectBaseURL(); /** * Database Connection: * 请修改此处配置: * dbname 数据库名称 * host 数据库连接IP地址 * 最后两项 root password 替换成你的数据库 用户 与 密码 */ Core\Database::initialize('mysql:dbname=sspanel;host=localhost;port=3306;charset=UTF8', 'root', 'password'); /** * Session */ @session_start();
/** * Create compressed CSS / JS file automatically * You should turn on this on production environment. */ define('OPTIMIZE_RES', true); /** * Use Uglify-JS 2 to compress javascript file. * You must install Uglify-JS 2 on your server to use this feature. * * For more information, please refer to https://github.com/mishoo/UglifyJS2 */ define('ENABLE_UGLIFYJS', false); /** * Use Clean-CSS to compress CSS StyleSheet. * You must install Clean-CSS on your server to use this feature. * * For more information, please refer to https://github.com/jakubpawlowicz/clean-css */ define('ENABLE_CLEANCSS', false); /** * Base URL: * To manually config this, uncomment the following line and change the URL * To use auto detect, keep this commented */ // define('BASE_URL', 'http://www.kookxiang.com'); Core\Request::autoDetectBaseURL(); /** * Database Connection: */ Core\Database::register('mysql:dbname=test;host=localhost;charset=UTF8', 'root', '');