npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

php-tag

v0.0.1

Published

Write your backend PHP code in a JavaScript tagged template literal

Readme

php-tag

Write your PHP backend code right inside your frontend JavaScript code using tagged template literals:

import { php } from "php-tag";

async function run() {
  // The return value is serialized to JSON and sent back
  const hello = await php`return "Hello world!";`;
  console.assert(hello === "Hello world!");

  // Interpolated values are serialized to JSON and sent to the backend
  const sum = await php`return ${12} + ${30};`;
  console.assert(sum === 42);
}

Anticipated questions

  • Oh the horror! Why? Just why?

    Because I can.

  • Is this a good idea?

    Colocation is good, isn't it?. Like Next.js's getServerSideProps but for PHP backends. Is it really that different? With some IDE support it could be pretty useful, methinks.

    Still not buying it? OK, neither am I.

How does it work?

php-tag comes in the form of a Vite plugin (php-tag/vite-plugin). If you want to use with other tools, the underlying Babel transform (php-tag/babel-plugin) is also available.

For the production build, the Babel transform extracts each piece of PHP code into its own PHP file with a unique name. The client sends this name along with the interpolated arguments as a POST request with a JSON body to the /php-tag and point. The backend is supposed to provide a dispatcher at that endpoint that loads the requested PHP file and executes it with the arguments sent.

During development, the client sends the code itself instead of a file name and the backend just evals it.

Getting started

# Clone the example
npx degit cyco130/php-tag/examples/basic php-tag-example
# Install dependencies
npm install
# Run the example in development mode
npm run dev

# Build the example
npm run build
# Preview the example
npm run preview

Future ideas

  • [ ] IDE support
  • [ ] python-tag, go-tag, java-tag etc.
  • [ ] Customization options
  • [ ] More integration examples (Laravel, Symfony, etc.)

What about node-tag?

It already exists in a much more useful form and type-safe form. It will be available with the next version of Rakkas in early August 2022.

License

MIT