maplesnow / laravel-apollo
Apollo agent for laravel.
v1.0.0
2019-03-21 12:43 UTC
Requires
- illuminate/console: 5.1.x|5.2.x|5.3.x|5.4.x|5.5.x|5.6.x|5.7.x|5.8.x
- illuminate/filesystem: 5.4.*|5.5.*|5.6.*|5.7.*
- illuminate/support: 5.1.x|5.2.x|5.3.x|5.4.x|5.5.x|5.6.x|5.7.x|5.8.x
- illuminate/translation: 5.4.*|5.5.*|5.6.*|5.7.*
- symfony/yaml: 3.*
This package is auto-updated.
Last update: 2025-03-22 03:42:17 UTC
README
用apollo实现配置和语言包的统一的管理和下发
安装
composer require maplesnow/laravel-apollo
添加 serviceProvider
MapleSnow\Apollo\Providers\ApolloServiceProvider::class
添加 facade
'Apollo' => MapleSnow\Apollo\Facades\Apollo::class
发布 ServiceProvider
php artisan vendor:publish --provider="MapleSnow\Apollo\Providers\ApolloServiceProvider"
配置.env
参数
APP_ID=your app id CLUSTER=default APOLLO_NAMESPACES="application, common_ns, others" APOLLO_CONFIG_SERVER=http://apollometa:8090
开启Apolloagent
php artisan apollo.start-agent
发布配置
在apollo配置中心修改配置,点击发布,项目内的.env文件将被重写。
发布语言包
1.添加laravel支持
将 app/config/app.php 中 Illuminate\Translation\TranslationServiceProvider
替换成 Kaishiyoku\Core\Translation\TranslationServiceProvider
2. 在apollo配置中心添加前缀为Lang
的namespace,默认是en
,若需其他语言需加上后缀,多国语言参考
3. 使用yaml
格式编写语言包
# 用户自定义 message: hello: '你好 :name' # Auth 认证 auth: failed: '认证失败'
- 修改完成后,点击发布
- 项目中的用法
dd(trans("lang.message.hello",['name','mapleSnow']),trans("lang.auth.failed"));
License
laravel-apollo is free software distributed under the terms of the MIT license.