PHPackages                             nojimage/phpvjs - 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. nojimage/phpvjs

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

nojimage/phpvjs
===============

PSR-15 Middleware for passing PHP variables to JavaScript

v1.1.0(1y ago)11.9k↓59.4%MITPHPPHP ^8.2CI passing

Since Jun 25Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/nojimage/phpvjs)[ Packagist](https://packagist.org/packages/nojimage/phpvjs)[ RSS](/packages/nojimage-phpvjs/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

PHPvJS Middleware
=================

[](#phpvjs-middleware)

[![License](https://camo.githubusercontent.com/22c817ca0e1242f6d3b9613954f57d3d2659bf418f83b7ff6a02d146215cb5c5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e6f6a696d6167652f706870766a73)](https://camo.githubusercontent.com/22c817ca0e1242f6d3b9613954f57d3d2659bf418f83b7ff6a02d146215cb5c5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e6f6a696d6167652f706870766a73)[![Packagist Version (custom server)](https://camo.githubusercontent.com/7618e7c700cfcdb975a95af463db74e3040daefc106eed6d5634dd743d46dbf0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f6a696d6167652f706870766a73)](https://camo.githubusercontent.com/7618e7c700cfcdb975a95af463db74e3040daefc106eed6d5634dd743d46dbf0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6f6a696d6167652f706870766a73)[![Build Status](https://github.com/nojimage/phpvjs/actions/workflows/ci.yml/badge.svg)](https://github.com/nojimage/phpvjs/actions/workflows/ci.yml)

Overview
--------

[](#overview)

This library aims to facilitate passing values to JavaScript frameworks like Vue without the need to create an API. It is particularly useful for rapidly developing Web applications in a Multi-Page Application (MPA).

This project provides a middleware that allows passing PHP variables to JavaScript. It is designed to be used with frameworks that have a PSR-15 middleware stack.

Requirements
------------

[](#requirements)

- PHP 8.2 or above
- Framework with PSR-15 compliant middleware stack

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

[](#installation)

```
composer require nojimage/phpvjs
```

Add it to your PSR-15 middleware stack. Here's an example for CakePHP 5.x:

```
// src/Application.php
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
{
    // ...
    $middlewareQueue->add(new \Nojimage\PHPvJS\PHPvJSMiddleware());
    // ...
}
```

Usage
-----

[](#usage)

You can pass PHP variables to JavaScript using an instance of `\Nojimage\PHPvJS\VariableCarry`, which can be obtained from the request object attribute.

```
/*
 * @var \Psr\Http\Message\ServerRequestInterface $request
 */

/** @var \Nojimage\PHPvJS\VariableCarry $carry */
$carry = $request->getAttribute(\Nojimage\PHPvJS\VariableCarry::class);
$carry->toJs('foo', $somevalue);
```

On the JavaScript side, you can access the PHP variables through the `window.__phpvjs__` object.

```
console.log(window.__phpvjs__);
// or
const phpvjs = window.__phpvjs__ ?? {};
```

### Integration with Vue.js

[](#integration-with-vuejs)

In the entry point script file:

```
import { createApp } from 'vue';

const app = createApp({
    data() {
        // Pass PHP variables to Vue.js using PHPvJS
        return window.__phpvjs__ ?? {};
    },
    // ... other options
});

// ...other setups

app.mount("#app");
```

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

[](#contributing)

If you find any bugs or have suggestions for new features, please create an issue or submit a pull request.

License
-------

[](#license)

This project is released under the MIT License.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance57

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Every ~714 days

Total

2

Last Release

435d ago

PHP version history (2 changes)v1.0.0PHP ^7.2 || ^8.0

v1.1.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/a3fe494e51e33958f5c8079669fd036dfee4c2e6b11f85f2249ba36c371986e3?d=identicon)[nojimage](/maintainers/nojimage)

---

Top Contributors

[![nojimage](https://avatars.githubusercontent.com/u/100564?v=4)](https://github.com/nojimage "nojimage (15 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nojimage-phpvjs/health.svg)

```
[![Health](https://phpackages.com/badges/nojimage-phpvjs/health.svg)](https://phpackages.com/packages/nojimage-phpvjs)
```

###  Alternatives

[mcp/sdk

Model Context Protocol SDK for Client and Server applications in PHP

1.6k2.2M144](/packages/mcp-sdk)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

73151.3k35](/packages/jaxon-php-jaxon-core)[flarum/core

Delightfully simple forum software.

211.5M2.5k](/packages/flarum-core)[xima/xima-typo3-frontend-edit

Frontend Edit - This extension provides an edit button for editors within frontend content elements.

1615.6k](/packages/xima-xima-typo3-frontend-edit)[eliashaeussler/typo3-solver

Solver - Extends TYPO3's exception handling with AI generated solutions. Problems can also be solved from command line. Several OpenAI parameters are configurable and prompts and solution providers can be customized as desired.

302.1k](/packages/eliashaeussler-typo3-solver)

PHPackages © 2026

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