Comments (4)
是的,可以在拉取到配置后把配置内容放进.env中。给出一个思路以供参考:
- 创建一个
.env
的模板文件.env.tpl
:
// .env.tpl
return "
APP_ENV={$apollo['app.env']}
APP_DEBUG={$apollo['app.debug']}
APP_KEY={$apollo['app.key']}
APP_TIMEZONE={$apollo['app.timezone']}
APP_LOCALE={$apollo['app.language']}
APP_HOST={$apollo['app.host']}
AUTH_URL={$apollo['auth.url']}
DB_CONNECTION=mysql
DB_HOST={$apollo['mysql.url']}
DB_PORT={$apollo['mysql.port']}
DB_DATABASE=YOUR DB
DB_USERNAME={$apollo['mysql.user']}
DB_PASSWORD={$apollo['mysql.password']}
";
- 在拉取到配置后,执行以下代码将模板文件生成
.env
文件:
$env_tpl = '.env.tpl';
$env_file = '.env';
// 获取拉取到的apollo config
$apollo = get_apollo_config();
// 渲染模板文件并生成新的 .env
$env_tpl = file_get_contents($env_tpl);
$env_config = (eval($env_tpl));
file_put_contents($env_file, $env_config);
from apollo-php-client.
好的 多谢 我试下,感觉这种比较多的情况,弄出来应该放到 example或者文档里
from apollo-php-client.
可以,你的意见确实我们也考虑到了,之后会出一些对接laravel等框架的方式。
from apollo-php-client.
@yunnian
接入 laravel 的例子已经在 exmaple/laravel 中,参考→ #13
from apollo-php-client.
Related Issues (13)
- 怎么使用这个客户端呢? HOT 8
- 你把数据库帐号密码弄到.env 了 HOT 1
- 请求notifications/v2? 接口卡住 HOT 3
- 你们这个项目投产了吗?
- 需要开启额外配置吗
- 对于swoole这种不是php-fpm形式的应用,应该如何更新配置? HOT 3
- 执行php start.php时过一段时间就报错,请问怎么处理 HOT 3
- 更新配置文件的时候如果有访问进来不会出现文件加载失败或者配置不完整的情况吗?
- php-fpm docker容器中如何启动客户端? HOT 2
- 有个问题 一直在while中 执行curl 不是阻塞的形式, 那cpu会很高吗? HOT 2
- 各位大佬们,我想请教一下添加了密钥后如何获取配置 HOT 1
- 我这边实现了新的阿波罗php库,欢迎围观 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-php-client.