jevets/kirby-phpdotenv
Composer 安装命令:
composer require jevets/kirby-phpdotenv
包简介
PHPDotenv for Kirby CMS
关键字:
README 文档
README
A simple wrapper around vlucas' PHP dotenv library for Kirby CMS.
Why?
I've been using .env in my Kirby projects for a while, but I got tired of pasting in the env() function for every new site. So, I created this package instead.
Quick Example
# .env
APP_DEBUG=true
# site/config/config.php c::set('debug', env('APP_DEBUG', false));
# elsewhere c::get('debug'); // true
Install
Install via composer
composer require jevets/kirby-phpdotenv
Usage
1. Instantiate
In your site's index.php file (or in site.php file), load Composer's autoloader.
require_once 'path/to/vendor/autoload.php';
Then instantiate with:
- The path where dotenv can find your
.envfile - A file name other than
.env
new Jevets\Kirby\Dotenv\Dotenv(__DIR__ . DS, '.env');
Note: Jevets\Kirby\Dotenv\Dotenv will instantiate and run [dotenv]->load() for you.
2. Create your .env file
KIRBY_LICENSE=1234-12345-123456 APP_MODE=production APP_DEBUG=true
3. Use in config.php file(s)
c::set('license', env('KIRBY_LICENSE', 'put your license in .env')); c::set('debug', env('APP_DEBUG', false)); c::get('license'); // "1234-12345-123456" c::get('debug'); // true
This library loads a global helper function:
function env($key, $default = '') {...}
Note function env() declaration is wrapped in if (!function_exists('env')) so you can override it or use your own method.
Customized folder setup
In my Kirby projects, I usually keep this folder structure:
project/
.env
.env.example
.gitignore
package.json
composer.json
site/
accounts/
blueprints/
cache/
config/
snippets/
templates/
public/
kirby/
toolkit/
panel/
content/
assets/
thumbs/
index.php
site.php
src/
vendor/
And here's my typical site.php
# Composer autoload require __DIR__ . DS . '..' . DS . 'vendor' . DS . 'autoload.php'; # DotEnv new Jevets\Kirby\Dotenv\Dotenv(__DIR__ . DS . '..'); # Setup Kirby $kirby = kirby(); $kirby->roots()->site = __DIR__ . DS . '..' . DS . 'site';
ChangeLog
0.0.3
- Rename class alias in helpers.php from
StringtoStrfor PHP7 compatibility
0.0.2
- Initial release
Collaborating
Pull requests and suggestions are quite welcome!
Credits
- All credit for dotenv goes to vlucas for his great work on PHP dotenv. I just wrapped it up in a package to speed up development of Kirby-based sites.
- I stole Taylor Otwell's
env()function from Laravel 5.1, with a couple tweaks to get it working with Kirby.
Bugs/Issues
Please use the issue tracker on the GitHub repo.
jevets/kirby-phpdotenv 适用场景与选型建议
jevets/kirby-phpdotenv 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.89k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2015 年 12 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「environment」 「dotenv」 「kirby」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jevets/kirby-phpdotenv 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jevets/kirby-phpdotenv 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jevets/kirby-phpdotenv 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Environment processor and contexts autoloader
The tenancy/tenancy identification driver using environment variables
Multiple cascading environmental configuration files support for Laravel 5
An environment variable convenience library extension for vlucas/phpdotenv
Zero-dependency global `kirbylog()` helper for any content
Courier offers a convenient and painless solution for creating emails tailored for your Kirby website.
统计信息
- 总下载量: 10.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD
- 更新时间: 2015-12-23