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

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

问题描述

我已经能够找到关于如何在Heroku for 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天全站免登陆