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.8k↓60.7%MITPHPPHP ^8.2CI passing

Since Jun 25Pushed 4mo ago1 watchersCompare

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

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

41

—

FairBetter than 87% of packages

Maintenance62

Regular maintenance activity

Popularity22

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

390d 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.5k1.5M88](/packages/mcp-sdk)[psr7-sessions/storageless

Storageless PSR-7 Session support

652405.7k8](/packages/psr7-sessions-storageless)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[jaxon-php/jaxon-core

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

74149.4k30](/packages/jaxon-php-jaxon-core)[tomasnorre/crawler

Crawler extension for TYPO3

57428.7k1](/packages/tomasnorre-crawler)[xima/xima-typo3-frontend-edit

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

1414.3k](/packages/xima-xima-typo3-frontend-edit)

PHPackages © 2026

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