/** * Init Core * * @uses Stativo\Helpers\Language * @uses Stativo\Helpers\File * @return \Core Returns instance of Stativo\Core\Core */ public function init() { // Load env files $dotenv = new \Dotenv\Dotenv(DOCROOT, '.env'); $dotenv->overload(); // Load config (after \Dotenv) $config = self::config('app'); // Init DB if is set true if ($config->get('database')['enabled']) { $capsule = new \Illuminate\Database\Capsule\Manager(); foreach ($config->get('database')['connections'] as $name => $conn) { $capsule->addConnection($conn, $name); } $capsule->setAsGlobal(); $capsule->bootEloquent(); } // Init translation if set true if ($config->get('language')['enabled']) { \Stativo\Helpers\Language::instance(); } if (class_exists(\Stativo\Helpers\File::class)) { \Stativo\Helpers\File::instance(); } return $this; }
/** * Importer constructor. */ public function __construct() { $dotenv = new \Dotenv\Dotenv(__DIR__ . "/../../"); $dotenv->overload(); $dotenv->required(['URI', 'USERNAME', 'PASSWORD']); $this->uri = getenv("URI"); $this->username = getenv("USERNAME"); $this->password = getenv("PASSWORD"); $this->client = new \GuzzleHttp\Client(); if (!file_exists(getcwd() . "/log_output")) { mkdir(getcwd() . "/log_output"); } }
<?php namespace Nyaan; use Nyaan\Application; require __DIR__ . '/../vendor/autoload.php'; error_reporting(0); ini_set('session.use_strict_mode', true); try { call_user_func(function () { mb_internal_encoding("UTF-8"); $dotenv = new \Dotenv\Dotenv(dirname(__DIR__)); $dotenv->overload(); $dotenv->required('DB_DSN')->notEmpty(); $routing_map = ['logout' => ['GET', '/logout', 'logout'], 'login' => ['GET', '/login', 'login'], ['POST', '/login', 'login'], 'register' => ['GET', '/register', 'register'], ['POST', '/register', 'register'], 'room' => ['GET', '/rooms/:slug', 'room', ['slug' => '/[-a-zA-Z0-9]+/']], ['POST', '/rooms/:slug', 'room', ['slug' => '/[-a-zA-Z0-9]+/']], 'add_romm' => ['POST', '/add_room', 'add_room'], 'user' => ['GET', '/:user', 'user', ['user' => '/@[-a-zA-Z0-9]+/']], 'index' => ['GET', '/', 'top'], '#404' => 'fileloader']; $now = new \DateTimeImmutable(); $app = new Application($_SERVER, $_COOKIE, $_GET, $_POST, $now); $basedir = dirname(__DIR__); $twig_option = ['cache' => $basedir . '/cache/twig', 'debug' => true]; $loader = new \Twig_Loader_Filesystem($basedir . '/src/View/twig'); \Nyaan\Response\TemplateResponse::setTwigEnvironment(new \Twig_Environment($loader, $twig_option)); ini_set('session.save_path', $basedir . '/cache/session'); $session = new \Baguette\Session\PhpSession(); $app->setSession($session); $session->start(); $app->isVerified = $app; $app->isTokenVerified = isset($app->post['token']) && $app->post['token'] === $session->get('token', ['default' => false]); $path = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : $_SERVER['PHP_SELF']; $path = $path === '/index.php' ? '/' : $path; $router = new \Teto\Routing\Router($routing_map); $action = $router->match($_SERVER['REQUEST_METHOD'], $path);
<?php #date_default_timezone_set('Europe/Moscow'); require __DIR__ . '/vendor/autoload.php'; if (file_exists(__DIR__ . '/.env')) { $de = new Dotenv\Dotenv(__DIR__); $de->overload(); } if (file_exists(__DIR__ . '/../.env')) { $de = new Dotenv\Dotenv(__DIR__ . '/../'); $de->overload(); } $de->required(['YII_ENV', 'MYSQL_HOST', 'MYSQL_USER', 'MYSQL_PASSWORD', 'MYSQL_DATABASE', 'COOKIE_KEY']); if ($_SERVER['YII_ENV'] == 'dev') { define('YII_ENV', 'dev'); define('YII_DEBUG', true); } else { define('YII_ENV', 'prod'); define('YII_DEBUG', false); }
writeln('working with env files'); $tmp_dir = dirname(__DIR__) . '/../.tmp/'; $local_env = '.local.env'; $remote_env = '.remote.env'; runLocally('mkdir -p ' . $tmp_dir); runLocally('cp .env ' . $tmp_dir . $local_env); download($tmp_dir . $remote_env, $config['shared_dir'] . '/.env'); $dotenvremote = new Dotenv\Dotenv($tmp_dir, $remote_env); if (file_exists($tmp_dir . $remote_env)) { $dotenvremote->overload(); $dotenvremote->required(['WP_HOME']); set('remote_url', getenv('WP_HOME')); } $dotenvlocal = new Dotenv\Dotenv($tmp_dir, $local_env); if (file_exists($tmp_dir . $local_env)) { $dotenvlocal->overload(); $dotenvlocal->required(['WP_HOME']); set('local_url', getenv('WP_HOME')); } runLocally('rm -rf .tmp'); } else { writeln('working with config'); set('local_url', $config['local_wp_url']); set('remote_url', $config['remote_wp_url']); } })->desc('Download backup database'); /* --------------------- */ /* DB TASKS */ /* --------------------- */ task('db:push', ['db:local:backup', 'db:cmd:push']); task('db:pull', ['db:remote:backup', 'db:cmd:pull']);
| Detect The Application Environment |-------------------------------------------------------------------------- | | Laravel takes a dead simple approach to your application environments | so you can just specify a machine name for the host that matches a | given environment, then we will automatically detect it for you. | */ $env = $app->detectEnvironment(function () { // if run in console then include this file to load env from .htaccess file if (php_sapi_name() === 'cli') { require_once 'parseEnv.php'; } $env = isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : getenv('APP_ENV'); $dot = new Dotenv\Dotenv(__DIR__ . '/..', '.env.' . $env); $dot->overload(); return $_ENV['APP_ENV']; }); /* |-------------------------------------------------------------------------- | Bind Paths |-------------------------------------------------------------------------- | | Here we are binding the paths configured in paths.php to the app. You | should not be changing these here. If you need to change these you | may do so within the paths.php file and they will be bound here. | */ $app->bindInstallPaths(require __DIR__ . '/paths.php'); /* |--------------------------------------------------------------------------