imponeer/symfony-translations-constants-loader
Composer 安装命令:
composer require imponeer/symfony-translations-constants-loader
包简介
symfony/translation extension to load PHP files that are defined all translations as constants
README 文档
README
Symfony Translations Constants Loader
Extension for symfony/translation package to load translations defined as constants list in PHP file.
Installation
To install and use this package, we recommend to use Composer:
composer require imponeer/symfony-translations-constants-loader
Otherwise you need to include manualy files from src/ directory.
Usage Example
1. Create a file with define() constants:
// translations/en/messages.php define('HELLO', 'Hello!'); define('GOODBYE', 'Goodbye!');
💡 You can create separate files for other locales, such as
translations/fr/messages.php.
2. Load the constants using the PHPFileLoader:
use Symfony\Component\Translation\Translator; use Imponeer\SymfonyTranslationsConstantsLoader\PHPFileLoader; $translator = new Translator('en'); // Register the loader for the 'php_consts' format $translator->addLoader('php_consts', new PHPFileLoader()); // Add your translation resource $translator->addResource('php_consts', __DIR__ . '/translations/en/messages.php', 'en'); // Use translations echo $translator->trans('HELLO'); // Outputs: Hello! echo $translator->trans('GOODBYE'); // Outputs: Goodbye!
Development
Code Style
This project follows the PSR-12 coding standard. To check your code for style issues:
composer phpcs
To automatically fix most coding standards issues:
composer phpcbf
Testing
To run the test suite, execute:
vendor/bin/phpunit
This will run all tests in the tests/ directory.
Static Analysis
This project uses PHPStan for static code analysis at level 5. PHPStan helps detect bugs and potential issues without running the code.
To run the static analysis:
composer phpstan
The analysis checks both the src/ and tests/ directories. Configuration can be found in the phpstan.neon file.
How to contribute?
If you want to add some functionality or fix bugs, you can fork, change and create pull request. If you not sure how this works, try read GitHub documentation about git.
Please make sure your code follows the PSR-12 coding standard by running the code style checks before submitting a pull request.
If you found any bug or have some questions, use issues tab and write there your questions.
imponeer/symfony-translations-constants-loader 适用场景与选型建议
imponeer/symfony-translations-constants-loader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24.3k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 11 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「translation」 「loader」 「constants」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 imponeer/symfony-translations-constants-loader 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 imponeer/symfony-translations-constants-loader 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 imponeer/symfony-translations-constants-loader 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony2 bundle that provides features to load assets
A custom URL rule class for Yii 2 which allows to create translated URL rules
The bundle for easy using json-rpc api on your project
A Laravel Eloquent model trait for translatable resource
An environment variable convenience library extension for vlucas/phpdotenv
PhpStratum SQLite: A stored procedure loader and wrapper generator for SQLite
统计信息
- 总下载量: 24.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-11