rbdwllr/atlantic-city
Composer 安装命令:
composer require rbdwllr/atlantic-city
包简介
A replica of the default WordPress plugin Hello Dolly, but for composer powered WordPress and for the song Atlantic City.
README 文档
README
A Composer based WordPress plugin which displays lyrics from the song Atlantic City in the WordPress admin.
This plugin was created to show developers how to create WordPress plugins which are hosted on Packagist and work with Composer friendly WordPress frameworks like Dusty.
It also highlights how to write unit tests for WordPress plugins using WP_Mock and how to integrate with static analysis tools like PHPStan.
Composer Setup
There is only one difference between a WordPress plugin built with Composer compared to a standard PHP package, which is the package type. With WordPress plugins you set the type to wordpress-plugin in the Composer.json file.
"type": "wordpress-plugin",
This simply tells Composer friendly WordPress frameworks how to handle the package, instead of putting the package in the vendor folder it will put the package in the WordPress plugins directory. See WPackagist for more details on this.
Unit Tests with WP_Mock
To write unit tests for WordPress you need to use a package called WP_Mock. It is an extension of PHP Unit which allows you to mock WordPress custom function calls.
For instance this library's unit tests mock the is_rtl() function which tells WordPress if the site's text runs from right to left or left to right.
WP_Mock::userFunction('is_rtl', [ 'times' => 1, 'return' => false ]);
To use WP_Mock you need to create a custom bootstrap file and extend the WP_Mock test case class rather than the PHP Unit one.
namespace Tests; use App\MyWordPressCode; use WP_Mock\Tools\TestCase; use WP_Mock; class MyWordPressTests extends TestCase { ... }
WP_Mock also comes with some nice features which allow you to check whether WordPress actions or filters have been called.
WP_Mock::expectActionAdded('action', 'parameters');
Other Code Analysis Tools
This plugin integrates with a number of static analysis tools, including PHP Code Sniffer and PHP Mess Detection, which will help improve the code quality of the WordPress plugins you produce.
It also shows you how to integrate with PHPStan to add some type safety to your code. This requires a small amount of customisation to handle WordPress so there is a configuration file and an integration with the szepeviktor/phpstan-wordpress package which extends PHPStan for WordPress.
rbdwllr/atlantic-city 适用场景与选型建议
rbdwllr/atlantic-city 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 339 次下载、GitHub Stars 达 5, 最近一次更新时间为 2019 年 05 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 rbdwllr/atlantic-city 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rbdwllr/atlantic-city 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 339
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 6
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-24