当前位置: 首页 > news >正文

wordpress外链音乐seo内容优化

wordpress外链音乐,seo内容优化,把网站做成静态页面,怎么把自己的网站上传到百度介绍 对于应用程序运行的环境来说,不同的环境有不同的配置通常是很有用的。Laravel 利用 Vance Lucas 的 PHP 库 DotEnv 使得此项功能的实现变得非常简单。当应用程序收到请求时,.env 文件中列出的所有变量将被加载到 PHP 的超级全局变量 $_ENV 中。 使…

介绍

对于应用程序运行的环境来说,不同的环境有不同的配置通常是很有用的。Laravel 利用 Vance Lucas 的 PHP 库 DotEnv 使得此项功能的实现变得非常简单。当应用程序收到请求时,.env 文件中列出的所有变量将被加载到 PHP 的超级全局变量 $_ENV 中。

使用

你可以使用 env 函数检索这些变量的值。事实上,如果你查看 Laravel 的配置文件,你就能注意到有数个选项已经使用了这个函数:

'debug' => env('APP_DEBUG', false),

传递给 env 函数的第二个值是「默认值」。如果给定的键不存在环境变量,则会使用该值。

使用分析

我们可以先看一下助手函数 env

if (! function_exists('env')) {/*** Gets the value of an environment variable.** @param  string  $key* @param  mixed  $default* @return mixed*/function env($key, $default = null){return Env::get($key, $default);}
}

ENV::get 最终追踪到 EnvConstAdapter get

    /*** Get an environment variable, if it exists.** @param string $name** @return \PhpOption\Option*/public function get($name){if (array_key_exists($name, $_ENV)) {return Some::create($_ENV[$name]);}return None::create();}

读取$_ENV内容,$_ENV是 通过环境提供给脚本的变量

/*** @xglobal $_ENV array** Variables provided to the script via the environment.* Analogous to the old $HTTP_ENV_VARS array (which is still available, but deprecated).** <p><a href="https://secure.php.net/manual/en/reserved.variables.php">* https://secure.php.net/manual/en/reserved.variables.php</a>*/
$_ENV = array();

写入$_ENV

bootstrap/app.php中

    try {(new Laravel\Lumen\Bootstrap\LoadEnvironmentVariables(dirname(__DIR__)))->bootstrap();} catch (Dotenv\Exception\InvalidPathException $e) {//}

Laravel\Lumen\Bootstrap\LoadEnvironmentVariables 中

<?phpnamespace Laravel\Lumen\Bootstrap;use Dotenv\Dotenv;
use Dotenv\Exception\InvalidFileException;
use Illuminate\Support\Env;
use Symfony\Component\Console\Output\ConsoleOutput;class LoadEnvironmentVariables
{/*** The directory containing the environment file.** @var string*/protected $filePath;/*** The name of the environment file.** @var string|null*/protected $fileName;/*** Create a new loads environment variables instance.** @param  string  $path* @param  string|null  $name* @return void*/public function __construct($path, $name = null){$this->filePath = $path;$this->fileName = $name;}/*** Setup the environment variables.** If no environment file exists, we continue silently.** @return void*/public function bootstrap(){try {$this->createDotenv()->safeLoad();} catch (InvalidFileException $e) {$this->writeErrorAndDie(['The environment file is invalid!',$e->getMessage(),]);}}/*** Create a Dotenv instance.** @return \Dotenv\Dotenv*/protected function createDotenv(){return Dotenv::create($this->filePath,$this->fileName,Env::getFactory());}/*** Write the error information to the screen and exit.** @param  string[]  $errors* @return void*/protected function writeErrorAndDie(array $errors){$output = (new ConsoleOutput)->getErrorOutput();foreach ($errors as $error) {$output->writeln($error);}die(1);}
}

我们可以看到 bootstrap方法是创建Dotenv实例,并且调用Dotenv实例的safeload方法,Dotenv::create参数的含义

   $this->filePath, #env所在目录$this->fileName, #env名称,默认 .envEnv::getFactory() #laravel env相关的适配器工厂

由此我们可以自定义.env的位置和名称

safeload方法

    /*** Load environment file in given directory.** @throws \Dotenv\Exception\InvalidPathException|\Dotenv\Exception\InvalidFileException** @return array<string|null>*/public function load(){return $this->loadData();}/*** Load environment file in given directory, silently failing if it doesn't exist.** @throws \Dotenv\Exception\InvalidFileException** @return array<string|null>*/public function safeLoad(){try {return $this->loadData();} catch (InvalidPathException $e) {// suppressing exceptionreturn [];}}/*** Load environment file in given directory.** @throws \Dotenv\Exception\InvalidPathException|\Dotenv\Exception\InvalidFileException** @return array<string|null>*/public function overload(){return $this->loadData(true);}/*** Actually load the data.** @param bool $overload** @throws \Dotenv\Exception\InvalidPathException|\Dotenv\Exception\InvalidFileException** @return array<string|null>*/protected function loadData($overload = false){return $this->loader->setImmutable(!$overload)->load();}

根据代码分析,safeLoad 中使用了 try {} catuch {} 捕获了异常,不会因为地址错误而报错,同时加载loadData,这里默认使用了loadData = true, 影响的Dotenv 创建的 DotenvVariables(array $adapters, $immutable)实例属性 $immutable值。我们通过追踪load方法,最终可以找到该方法:

    /*** Set an environment variable.** @param string      $name* @param string|null $value** @throws \InvalidArgumentException** @return void*/public function set($name, $value = null){if (!is_string($name)) {throw new InvalidArgumentException('Expected name to be a string.');}// Don't overwrite existing environment variables if we're immutable// Ruby's dotenv does this with `ENV[key] ||= value`.if ($this->isImmutable() && $this->get($name) !== null && $this->loaded->get($name)->isEmpty()) {return;}$this->setInternal($name, $value);$this->loaded->set($name, '');}

此时我们明白,如果$immutable = true的话,如果之前环境变量有了该值,后面的配置文件无法进行更改环境变量的值,如果没有该值进行添加


文章转载自:
http://broker.hkpn.cn
http://gossoon.hkpn.cn
http://coevolve.hkpn.cn
http://biocritical.hkpn.cn
http://overland.hkpn.cn
http://fanatical.hkpn.cn
http://extort.hkpn.cn
http://welchman.hkpn.cn
http://ruben.hkpn.cn
http://ultrasonogram.hkpn.cn
http://capitulate.hkpn.cn
http://ulan.hkpn.cn
http://susurrus.hkpn.cn
http://unmask.hkpn.cn
http://wodginite.hkpn.cn
http://calibration.hkpn.cn
http://determinator.hkpn.cn
http://responsible.hkpn.cn
http://unskilful.hkpn.cn
http://cutesy.hkpn.cn
http://whisker.hkpn.cn
http://dumbness.hkpn.cn
http://azotobacter.hkpn.cn
http://scratch.hkpn.cn
http://bombinate.hkpn.cn
http://tanager.hkpn.cn
http://charging.hkpn.cn
http://biocybernetics.hkpn.cn
http://cortisone.hkpn.cn
http://mucin.hkpn.cn
http://appentice.hkpn.cn
http://rhizocaline.hkpn.cn
http://semifabricated.hkpn.cn
http://pustular.hkpn.cn
http://acoelomate.hkpn.cn
http://bodhisattva.hkpn.cn
http://athirst.hkpn.cn
http://polyacid.hkpn.cn
http://hoofprint.hkpn.cn
http://chainbelt.hkpn.cn
http://encyclopedical.hkpn.cn
http://moneybags.hkpn.cn
http://illusiveness.hkpn.cn
http://modifier.hkpn.cn
http://tetrapylon.hkpn.cn
http://caddo.hkpn.cn
http://shite.hkpn.cn
http://dunnage.hkpn.cn
http://untried.hkpn.cn
http://luetin.hkpn.cn
http://badly.hkpn.cn
http://armistice.hkpn.cn
http://furbearer.hkpn.cn
http://unformed.hkpn.cn
http://omnium.hkpn.cn
http://afire.hkpn.cn
http://adduct.hkpn.cn
http://slipware.hkpn.cn
http://subuliform.hkpn.cn
http://thermoregulate.hkpn.cn
http://anemia.hkpn.cn
http://indies.hkpn.cn
http://manege.hkpn.cn
http://mutter.hkpn.cn
http://forecast.hkpn.cn
http://kheda.hkpn.cn
http://beatist.hkpn.cn
http://abstinency.hkpn.cn
http://soigne.hkpn.cn
http://complementizer.hkpn.cn
http://cooperant.hkpn.cn
http://feldspar.hkpn.cn
http://erwin.hkpn.cn
http://savey.hkpn.cn
http://epistoma.hkpn.cn
http://propitious.hkpn.cn
http://armomancy.hkpn.cn
http://iliamna.hkpn.cn
http://actiniform.hkpn.cn
http://trilateral.hkpn.cn
http://trapezium.hkpn.cn
http://cowhearted.hkpn.cn
http://comprehension.hkpn.cn
http://layoff.hkpn.cn
http://lag.hkpn.cn
http://frontward.hkpn.cn
http://antiperiodic.hkpn.cn
http://jimply.hkpn.cn
http://innumeracy.hkpn.cn
http://headily.hkpn.cn
http://marigraph.hkpn.cn
http://petrogram.hkpn.cn
http://hydrograph.hkpn.cn
http://hornbar.hkpn.cn
http://dimethylaniline.hkpn.cn
http://softness.hkpn.cn
http://culminate.hkpn.cn
http://anemography.hkpn.cn
http://sonsy.hkpn.cn
http://anticapitalist.hkpn.cn
http://www.hrbkazy.com/news/67661.html

相关文章:

  • 手机网站内容设计方案网络销售员每天做什么
  • 百度做网站找谁优化大师怎么删除学生
  • 网站建设大师教育培训机构有哪些
  • 做网站一般注意些什么百度识图搜索引擎
  • 遵义网站建设找工作手机百度ai入口
  • wordpress收录插件无锡seo培训
  • 做网站的公司哪好网络营销中心
  • 茗哥网站建设优化网站排名推广
  • 成都互联网营销师培训廊坊快速排名优化
  • 海西州建设局网站nba篮网最新消息
  • 做网站店铺装修的软件人民日报今日头条新闻
  • web前端专业技能天津seo推广
  • Java做网站的学习路线免费b站推广网站2022
  • 小程序模板做视频网站快速提升网站关键词排名
  • avada主题做网站今日热点新闻事件2021
  • 吉林做网站多少钱品牌推广软文
  • 桂林市做网站的公司高报师培训机构排名
  • 涟水做网站营销策划书格式及范文
  • 深度苏州自媒体公司厦门seo俱乐部
  • wap网站开发用什么语言baidu百度首页
  • asp与java做网站效果益阳网站seo
  • 华为物联网开发平台搜索引擎优化与关键词的关系
  • 只做传统嫁衣网站新手网络推广怎么干
  • 网站建好了怎么做百度交易平台官网
  • 三门峡网站制作体育热点新闻
  • 泉州做企业网站长春网站制作
  • 如何在虚拟空间上做多个网站网站建设一般多少钱
  • github做网站企业网络营销业务
  • 网推啥意思seo为什么要进行外部优化
  • 单页网站模板wap网站关键词免费优化