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

vite-php-asset-callers

v0.2.6

Published

A Vite 6+ plugin that scans PHP code and emits asset files from PHP callers/functions.

Downloads

8

Readme

Features

  • The plugin scans PHP code for asset references, such as images or external files, and identifies them for bundling.
  • Allows customization of file extensions, asset paths, and parser options.
  • Prevents emitting duplicate assets by keeping track of previously emitted files.
  • It supports partial matching of file paths, ensuring assets are correctly identified within PHP .

Installation

Install it via npm:

npm install vite-php-asset-callers --save-dev

Or with yarn:

yarn add -D vite-php-asset-callers

Usage

Add the plugin to your vite.config.js file:

import { defineConfig } from 'vite';
import VitePhpAssetCallers from 'vite-php-asset-callers';

export default defineConfig({
  plugins: [VitePhpAssetCallers()],
});

or with plugin options (optional)

import { defineConfig } from 'vite';
import VitePhpAssetCallers from 'vite-php-asset-callers';

export default defineConfig({
  plugins: [
    VitePhpAssetCallers({
      assetPath: 'src/images',
      extensions: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'woff', 'woff2', 'svg'],
      phpFiles: ['my-absolute-path/my-class.php', 'my-absolute-path/other-classes/**/*.php'],
    }),
  ],
});

Options

| Option | Type | Description | | --------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------- | | assetPath | string | Relative path from the root where assets are located to match in PHP files, by default it will use Vite's root path. | | phpFiles | string[] | An array of PHP files or glob patterns to scan in addition to PHP entries. These files will also be watched in HMR and watch mode. | | extensions | string[] | Asset extensions to search for in PHP code (default: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'woff', 'woff2', 'svg']). | | parserOptions | Object | Options passed directly to the php-parser. |

How It Works

  1. The plugin automatically scans PHP entries and the specified PHP files in phpFiles.
  2. It resolves paths to asset files based on the arguments in PHP function calls.
  3. Matches assets based in Vite's root or on the provided assetPath and extensions.
  4. Emits the matched assets into the Vite output directory for compilation.

Example

Given the following folder structure for source files.

src/
└── assets/
    ├── svg/
    │   └── coffee.svg
    ├── images/
    │   └── logo.png
    └── fonts/
        └── arial.woff

Given the following PHP code with different type of callers:

<?php
echo getImage('logo.png');
echo Utils::getSvg('coffee.svg');
echo $fonts->getFont($someValue, 'arial.woff')

The plugin will:

  1. Locate all asset files in the root (src) folder based on given extensions.
  2. Match asset with the string arguments provided in the PHP caller.
  3. Emit matched asset file for compilation if it hasn't been emitted before.