mallardduck/prettier-php-runner
Composer 安装命令:
composer require mallardduck/prettier-php-runner
包简介
Reformat code using Prettier in PHP
关键字:
README 文档
README
Prettier is an opinionated code formatter based on NodeJS that supports a variety of languages. Now you can use the power of Prettier with your PHP projects too!
\MallardDuck\PrettierPhp\PrettierHtml::format( html: '<html><body><div><h1>Heading</h1></div></body></html>' );
Installation
You can install the package via composer:
composer require mallardduck/prettier-php-runner
In your project, you should have the JavaScript package prettier installed. You can install it via npm...
npm install prettier
... or Yarn.
yarn add prettier
Make sure you have installed Node 10 or higher.
Usage
Here's an example where we are going to highlight some PHP code.
use Spatie\ShikiPhp\Prettier; PrettierHtml::format( '<html><body><div><h1>Heading</h1></div></body></html>' );
The output is this chunk of HTML which will render beautifully in the browser:
<html> <body> <div><h1>Heading</h1></div> </body> </html>
Using Node Version Manager
Under the hood, this package will run a node command beautify your HTML input.
If you use NVM during development, then the package will be unlikely to find your version of node as it
looks for the node executable in /usr/local/bin and /opt/homebrew/bin.
If this is the case for you, then you should create a symlink between the node distributable in your NVM folder.
Such a command might look like this:
sudo ln -s /home/some-user/.nvm/versions/node/v17.3.1/bin/node /usr/local/bin/node
Creating this symlink will allow the package to find your NPM executable. Please note, if you change your NPM version you will have to update your symlinks accordingly.
Testing
You can run all the tests with this command:
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
mallardduck/prettier-php-runner 适用场景与选型建议
mallardduck/prettier-php-runner 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.85k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 02 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「prettier」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mallardduck/prettier-php-runner 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mallardduck/prettier-php-runner 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mallardduck/prettier-php-runner 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Prettier task for GrumPHP.
Centralized PHP development baseline: code style, linters, CI workflows, and dev environment tooling.
Nubix preset for Laravel (^8.0).
A Laravel package that contains everything to write code without thinking about codestyle.
统计信息
- 总下载量: 14.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-02-21