<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## 環境配置 MixPHP 骨架代碼中默認采用 [symfony/dotenv](https://packagist.org/packages/symfony/dotenv) 庫完成環境配置處理,框架根目錄的 `.env` 文件為環境配置文件,環境配置通常配置一些在不同環境中參數值不同的配置信息,如:數據庫賬號密碼等。 >[success] 正確的使用方式:環境配置應該只在 manifest.php 文件中使用,而程序代碼中只使用應用清單配置 可配置多個環境配置文件,如:`.env.dev` 、`.env.test` 、`.env.pro`,然后在入口文件中切換使用,以適應不同的環境,修改入口文件中 `$dotenv->load('***')` 方法傳入的文件路徑即可切換。 ~~~php $dotenv->load(__DIR__ . '/../.env'); ~~~ >[info] .env 文件,需要 ls -a 才能在服務器上顯示出來。 ## 應用清單配置 (manifest.php) MixPHP 的 App 類實例化時需要傳入一些配置信息,配置信息是一個數組,這些信息就是應用清單配置,通常單獨存放在一個文件中,這個文件就叫應用清單配置文件。 下面是 `bin/mix.php` 入口文件的部分源碼,能看到配置信息是如何導入 App 類的: ~~~ // Run application $app = new Mix\Console\Application(require __DIR__ . '/../manifest/manifest.php'); $app->run(); ~~~ ### 配置詳情 一個典型的應用配置文件內容如下: [>> 到 GitHub 查看 manifest.php <<](https://github.com/mix-php/mix-skeleton/tree/v2.1/manifest/manifest.php) - `commands` 字段內是命令配置信息,詳情請查看 "命令行" 章節。 - `beans` 字段內是依賴配置信息,詳情請查看 "依賴注入" 章節,最新版本增加了 `beanPath` 字段取代該功能從目錄中讀取依賴配置。 - `commandPath` 指定命令配置的路徑,可以是單個配置文件,也可以是一個配置目錄,指定該字段時,`commands` 字段將被覆蓋。 - `beanPath` 指定依賴配置的路徑,可以是單個配置文件,也可以是一個配置目錄,指定該字段時,`beans` 字段將被覆蓋。 ## 自定義配置 MixPHP 骨架代碼中默認采用 [hassankhan/config](https://packagist.org/packages/hassankhan/config) 庫完成用戶自定義配置處理,該庫支持多種配置文件類型:PHP, INI, XML, JSON, and YAML ### [Mix-Skeleton](https://github.com/mix-php/mix-skeleton) 中使用 在 Web 開發骨架中我們建議將自定義配置通過 manifest.php 將配置注入到對應 class 中使用,因此為了能在 manifest.php 中也能獲取到配置,我們做了以下處理: - [bin/mix.php#L10](https://github.com/mix-php/mix-skeleton/tree/v2.1/bin/mix.php#L10) 在入口文件中實例化了全局變量 $config - [app/functions.php](https://github.com/mix-php/mix-skeleton/tree/v2.1/app/functions.php) 定義了 config() 全局方法,方便快速獲取 因此可在任意位置調用: ~~~ // 獲取全部配置 config()->all(); // 獲取指定配置 config()->get('foo'); // 指定默認值 config()->get('bar', 0); ~~~ ### [Mix-Phar-Skeleton](https://github.com/mix-php/mix-phar-skeleton) 中使用 在開發 Phar 單文件命令行時,由于單文件的特殊性,配置文件都在程序代碼之外,所以需要啟動程序后再加載配置因此框架骨架中配置了 [hassankhan/config](https://packagist.org/packages/hassankhan/config) 庫的依賴注入: - [manifest.php#L109](https://github.com/mix-php/mix-phar-skeleton/blob/master/manifest.php#L109) 可直接在代碼中通過依賴注入實例化,再獲取配置: ~~~ /** @var \Noodlehaus\Config $config */ $config = context()->get('config'); // 獲取全部配置 $config->all()); // 獲取指定配置 $config->get('foo'); // 指定默認值 $config->get('bar', 0); ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看