Giter VIP home page Giter VIP logo

Comments (4)

Sidfate avatar Sidfate commented on September 4, 2024

@yunnian

是的,可以在拉取到配置后把配置内容放进.env中。给出一个思路以供参考:

  1. 创建一个.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']}
";
  1. 在拉取到配置后,执行以下代码将模板文件生成.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.

yunnian avatar yunnian commented on September 4, 2024

好的 多谢 我试下,感觉这种比较多的情况,弄出来应该放到 example或者文档里

from apollo-php-client.

Sidfate avatar Sidfate commented on September 4, 2024

@yunnian

可以,你的意见确实我们也考虑到了,之后会出一些对接laravel等框架的方式。

from apollo-php-client.

Sidfate avatar Sidfate commented on September 4, 2024

@yunnian
接入 laravel 的例子已经在 exmaple/laravel 中,参考→ #13

from apollo-php-client.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.