在 PHP 中使用 Heroku 配置变量? [英] Use Heroku config vars with PHP?

查看:31
本文介绍了在 PHP 中使用 Heroku 配置变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经能够找到有关如何在 Heroku 中为 Python、node.js 和其他一些语言使用配置变量的信息,但对于 PHP 则不然.可以和 PHP 一起使用,还是不支持?

I've been able to find information on how to use config vars in Heroku for Python, node.js, and some other languages, but not for PHP. Can you use them with PHP, or is it not supported?

这篇文章 展示了如何为 Python、Java 和 Ruby 执行此操作,但是不是 PHP.

This article shows how to do it for Python, Java, and Ruby, but not PHP.

推荐答案

heroku 上的配置变量表现为环境变量,因此您应该能够像访问任何其他环境变量一样从 php 访问它们,例如.使用 getenv.

Config vars on heroku manifest themselves as environment variables, so you should be able to access them from php like you would any other environment variable, eg. using getenv.

首先,从您的控制台设置变量:

First, set the variable from your console:

heroku config:set MY_VAR=somevalue

然后,从您的代码访问它:

Then, access it from your code:

$my_env_var = getenv('MY_VAR');

这篇关于在 PHP 中使用 Heroku 配置变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆