PHPackages                             mallardduck/prettier-php-runner - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mallardduck/prettier-php-runner

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mallardduck/prettier-php-runner
===============================

Reformat code using Prettier in PHP

1.0.0(4y ago)014.9k1MITPHPPHP ^8.0

Since Feb 21Pushed 4y ago1 watchersCompare

[ Source](https://github.com/mallardduck/prettier-php-runner)[ Packagist](https://packagist.org/packages/mallardduck/prettier-php-runner)[ Docs](https://github.com/mallardduck/prettier-php-runner)[ RSS](/packages/mallardduck-prettier-php-runner/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (6)Versions (2)Used By (1)

Code highlighting with Shiki in PHP
===================================

[](#code-highlighting-with-shiki-in-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ca9835757af91b5865c71f07c4f94006e714cd75755e5c2dbd222240861b4e95/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616c6c6172646475636b2f70726574746965722d7068702d72756e6e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mallardduck/prettier-php-runner)[![GitHub Tests Action Status](https://camo.githubusercontent.com/800e630f35d51634e42741fbbeb18e54d7b766aaf0eb9c14b7257ce13c8765a4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d616c6c6172646475636b2f70726574746965722d7068702d72756e6e65722f5465737473)](https://github.com/mallardduck/prettier-php-runner/actions?query=workflow%3ATests+branch%3Amaster)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/ca4c3490fa783889d9b5e888f34ce06e77fed576463c89d6d99061ff84e4fe99/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d616c6c6172646475636b2f70726574746965722d7068702d72756e6e65722f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/mallardduck/prettier-php-runner/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/10c9ed34111f13136acb29048d915cf4264257bf3e753e980ab8e8048d184cb0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d616c6c6172646475636b2f70726574746965722d7068702d72756e6e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mallardduck/prettier-php-runner)

[Prettier](https://github.com/prettier/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: 'Heading'
);
```

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require mallardduck/prettier-php-runner
```

In your project, you should have the JavaScript package [`prettier`](https://github.com/prettier/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
-----

[](#usage)

Here's an example where we are going to highlight some PHP code.

```
use Spatie\ShikiPhp\Prettier;

PrettierHtml::format(
    'Heading'
);
```

The output is this chunk of HTML which will render beautifully in the browser:

```

        Heading

```

Using Node Version Manager
--------------------------

[](#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
-------

[](#testing)

You can run all the tests with this command:

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1593d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/801be8ba9bfb0cb2629f51f9753a0392683c2680fe3e941a188495840d920333?d=identicon)[MallardDuck](/maintainers/MallardDuck)

---

Top Contributors

[![mallardduck](https://avatars.githubusercontent.com/u/619938?v=4)](https://github.com/mallardduck "mallardduck (2 commits)")

---

Tags

prettier

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mallardduck-prettier-php-runner/health.svg)

```
[![Health](https://phpackages.com/badges/mallardduck-prettier-php-runner/health.svg)](https://phpackages.com/packages/mallardduck-prettier-php-runner)
```

###  Alternatives

[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M25.2k](/packages/friendsofphp-php-cs-fixer)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[phpactor/phpactor

PHP refactoring and intellisense tool for text editors

1.9k17.1k1](/packages/phpactor-phpactor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
