當前位置: 首頁>>代碼示例>>PHP>>正文


PHP App::Environment方法代碼示例

本文整理匯總了PHP中App\Http\Controllers\App::Environment方法的典型用法代碼示例。如果您正苦於以下問題:PHP App::Environment方法的具體用法?PHP App::Environment怎麽用?PHP App::Environment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在App\Http\Controllers\App的用法示例。


在下文中一共展示了App::Environment方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getSetupIndex

 /**
  * Checks to see whether or not the database has a migrations table
  * and a user, otherwise display the setup view.
  *
  * @author [A. Gianotto] [<snipe@snipe.net>]
  * @since [v3.0]
  * @return View
  */
 public function getSetupIndex()
 {
     try {
         $conn = DB::select('select 2 + 2');
         $start_settings['db_conn'] = true;
         $start_settings['db_name'] = DB::connection()->getDatabaseName();
         $start_settings['db_error'] = null;
     } catch (\PDOException $e) {
         $start_settings['db_conn'] = false;
         $start_settings['db_name'] = config('database.connections.mysql.database');
         $start_settings['db_error'] = $e->getMessage();
     }
     $protocol = array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == "on" ? 'https://' : 'http://';
     $pageURL = $protocol;
     if ($_SERVER["SERVER_PORT"] != "80") {
         $main_page = $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"];
         $pageURL .= $main_page . $_SERVER["REQUEST_URI"];
     } else {
         $main_page = $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
         $pageURL .= $main_page;
     }
     $start_settings['env_location'] = $pageURL . '../.env';
     if (config('app.url') . '/setup' != $pageURL) {
         $start_settings['url_valid'] = false;
     } else {
         $start_settings['url_valid'] = true;
     }
     $start_settings['url_config'] = config('app.url');
     $start_settings['real_url'] = $pageURL;
     $exposed_env = @file_get_contents($main_page . '/.env');
     if ($exposed_env) {
         $start_settings['env_exposed'] = true;
     } else {
         $start_settings['env_exposed'] = false;
     }
     if (\App::Environment('production') && config('app.debug') == true) {
         $start_settings['debug_exposed'] = true;
     } else {
         $start_settings['debug_exposed'] = false;
     }
     $environment = app()->environment();
     if ($environment != 'production') {
         $start_settings['env'] = $environment;
         $start_settings['prod'] = false;
     } else {
         $start_settings['env'] = $environment;
         $start_settings['prod'] = true;
     }
     if (function_exists('posix_getpwuid')) {
         // Probably Linux
         $owner = posix_getpwuid(fileowner($_SERVER["SCRIPT_FILENAME"]));
         $start_settings['owner'] = $owner['name'];
     } else {
         // Windows
         // TODO: Is there a way of knowing if a windows user has elevated permissions
         // This just gets the user name, which likely isn't 'root'
         // $start_settings['owner'] = getenv('USERNAME');
         $start_settings['owner'] = '';
     }
     if ($start_settings['owner'] === 'root' || $start_settings['owner'] === '0') {
         $start_settings['owner_is_admin'] = true;
     } else {
         $start_settings['owner_is_admin'] = false;
     }
     if (is_writable(storage_path()) && is_writable(storage_path() . '/framework') && is_writable(storage_path() . '/framework/cache') && is_writable(storage_path() . '/framework/sessions') && is_writable(storage_path() . '/framework/views') && is_writable(storage_path() . '/logs')) {
         $start_settings['writable'] = true;
     } else {
         $start_settings['writable'] = false;
     }
     $start_settings['gd'] = extension_loaded('gd');
     return View::make('setup/index')->with('step', 1)->with('start_settings', $start_settings)->with('section', 'Pre-Flight Check');
 }
開發者ID:stijni,項目名稱:snipe-it,代碼行數:80,代碼來源:SettingsController.php


注:本文中的App\Http\Controllers\App::Environment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。