<?php define('APPLICATION_PATH', __DIR__ . '/../'); define('CONFIG', APPLICATION_PATH . '/configs/config.json'); require_once APPLICATION_PATH . "vendor/autoload.php"; $config = new \Noodlehaus\Config(CONFIG); $app = new Silex\Application(); $app['debug'] = $config->get('debug'); $dbOptions = $config->get('db'); define('APP_KEY', $config->get('app_key')); $app->register(new Silex\Provider\DoctrineServiceProvider(), ['db.options' => $dbOptions]); \Sasik\Db\DbSingleton::setDb($app['db']); $app->mount('/', new Sasik\Controllers\IndexControllerProvider()); $app->run();
/** * logging * * @param array $input_array * @param string $file_name * @param string $type */ public function logging($input_array = array(), $type = "up", $file_name = 'bim.log') { $conf = new \Noodlehaus\Config(__DIR__ . "/../config/bim.json"); $logging_path = $conf->get("logging_path"); $return_message = " >> php bim " . $type . " \n"; $return_message .= date('d.m.Y H:i:s') . "\n"; $return_message .= print_r($input_array, true) . "\n"; $return_message .= "\n----------\n\n"; $file_name = empty($file_name) ? 'bim.log' : $file_name; $log_path = $_SERVER['DOCUMENT_ROOT'] . '/' . $logging_path . '/' . date("Y") . "/" . date("m") . "/" . date("d"); if (!file_exists($log_path)) { mkdir($log_path, 0777, true); } file_put_contents($log_path . '/' . $file_name, $return_message, FILE_APPEND); $this->writeln("Put info to log file > " . Colors::colorize($log_path . '/' . $file_name, Colors::GREEN)); }
<?php use Illuminate\Database\Capsule\Manager as Capsule; // create a new capsule to hold database connection $capsule = new Capsule(); $config = new \Noodlehaus\Config(dirname(__FILE__) . '/../config/app.php'); $capsule->addConnection(['driver' => $config->get('db.driver'), 'host' => $config->get('db.hostname'), 'database' => $config->get('db.dbname'), 'username' => $config->get('db.username'), 'password' => $config->get('db.password'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '']); $capsule->setAsGlobal(); $capsule->bootEloquent();
<?php /** * User: sasik * Date: 7/17/15 * Time: 8:28 PM */ define('APPLICATION_PATH', __DIR__ . '/../'); define('CONFIG', APPLICATION_PATH . '/configs/config.json'); require_once APPLICATION_PATH . "vendor/autoload.php"; use Sasik\Google\CloudMessaging; $config = new \Noodlehaus\Config(CONFIG); define('APP_KEY', $config->get('app_key')); $token = 'APA91bGi5JhZbR5DebXc5HzpcCHHk4Ct_3RBhQwwpxEntOG_nIHNgHvVNUO-SelCsY5s8f638uukDCYC3bxuPeXky0WeHWB8pXUFLB2E7Q5eLEvBp4vwPTU3lEknni9M6mv4VUP1W9iY'; //$token = 'APA91bGgAA6lIMDfReRkB1mEuCmVajg2rcMNWYndf1If3JyTObaTr-dy7rjkHlI1CJL6no_60cV5rMeuVZr_J9OVIkA6XC3kJmEvlroKgf1q2vTVszRzqhP1RlFRwdMPQBe5lDhJp-4W'; //$token = 'APA91bG95sMzVadM-ZOk9o8akiXPG4JthPudKI_u0EgoDjigV_cZL4iKlD5rVGaT6izsztckY4W7nTfcmZpux9vGTVNvE0fBT3_CBoGEVsgce2UfX0t21URkfZT6CYMeWKYp5t_mGMIU'; //$token = 'APA91bG15iDpwV60IQy7LlSCVBBL4dzeL7qeNpfdtIy_K2zfNEhqmT2bHfAJ_NA-ktE2fASzwp-m434w61V8gbzZJILyAT0RjeEkHMIiLoC719vPmCuy4zFW0yudOd7Eojz_jKTJ59ZM'; $resp = CloudMessaging::send($token, ['message' => 'hi mother f****r', 'timestamp' => time(), 'type' => rand(0, 1)]); dump($resp->getBody()->getContents()); dump($resp->getStatusCode()); dump($resp->getHeaders()); //dump(\Sasik\Google\Request::send('abc', ['hi message'])); //dump($resp);
/** * для Создания тестовых сущносей в базе данных * User: sasik * Date: 7/17/15 * Time: 3:05 PM */ define('APPLICATION_PATH', __DIR__ . '/../'); define('CONFIG', APPLICATION_PATH . '/configs/config.json'); require_once APPLICATION_PATH . "vendor/autoload.php"; use Sasik\Models\Children; use Sasik\Models\Parents; use Sasik\Models\Tokens; $config = new \Noodlehaus\Config(CONFIG); $app = new Silex\Application(); $app['debug'] = true; $app->register(new Silex\Provider\DoctrineServiceProvider(), ['db.options' => $config->get('db')]); \Sasik\Db\DbSingleton::setDb($app['db']); $db = \Sasik\Db\DbSingleton::getDb(); /** * ОСТОРОЖНО */ foreach (['children', 'parents', 'tokens', 'children_to_parents'] as $table) { $query = $db->createQueryBuilder(); $query->delete($table)->execute(); // $db->fetchAll('DELETE FROM ' . $table ); } //$db->delete('children', []); //$db->delete('parents', []); //$db->delete('tokens', []); //$db->delete('children_to_parents', []); $childrens = [Children::createObj(['name' => 'Children' . uniqid()]), Children::createObj(['name' => 'TestChildren']), Children::createObj(['name' => 'Children' . uniqid()]), Children::createObj(['name' => 'Children' . uniqid()]), Children::createObj(['name' => 'Children' . uniqid()])];
/** * getTableName * @return string */ public static function getTableName() { $conf = new \Noodlehaus\Config(__DIR__ . "/../../config/bim.json"); return $conf->get("migration_table"); }