PHPackages                             rudak/js-injector - 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. rudak/js-injector

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

rudak/js-injector
=================

Injection de constantes PHP dans un JS - TEST

v1.6.6.4(7y ago)121Apache-2.0JavaScriptPHP &gt;=5.6CI failing

Since Jan 1Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/rudak/JsInjector)[ Packagist](https://packagist.org/packages/rudak/js-injector)[ RSS](/packages/rudak-js-injector/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)DependenciesVersions (6)Used By (0)

JsInjector
==========

[](#jsinjector)

Bundle Symfony pour injecter des constantes PHP dans un fichier JavaScript.

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

[](#installation)

### PHP (Composer)

[](#php-composer)

```
composer require rudak/js-injector
```

### JavaScript (npm)

[](#javascript-npm)

```
npm install js-injector
```

Utilisation rapide
------------------

[](#utilisation-rapide)

### 1. Créer un provider de valeurs

[](#1-créer-un-provider-de-valeurs)

Créez un service qui implémente `HarvesterInterface` :

```
use Rudak\JsInjector\Harvester\HarvesterInterface;

class MyValuesProvider implements HarvesterInterface
{
    public function getValues(): array
    {
        return [
            'API_URL' => 'https://api.example.com',
            'DEBUG' => true,
        ];
    }
}
```

### 2. Taguer le service

[](#2-taguer-le-service)

```
services:
    App\Service\MyValuesProvider:
        tags: ['rudak.injector']
```

### 3. Générer le fichier JS

[](#3-générer-le-fichier-js)

```
php bin/console rudak:generate:js
```

Le fichier `injection.js` sera créé dans `/public/bundles/rudakInjection/`.

### 4. Inclure le script dans vos templates

[](#4-inclure-le-script-dans-vos-templates)

```

    console.log(API_URL); // 'https://api.example.com'
    console.log(DEBUG);   // true

```

API JavaScript
--------------

[](#api-javascript)

```
import { inject, injectFromJson, generateInjectionCode } from 'js-injector';

// Injection directe
inject({ API_URL: 'https://api.example.com', DEBUG: true });

// Avec namespace
inject({ timeout: 5000 }, { namespace: 'MyApp' });
console.log(window.MyApp.timeout); // 5000

// Depuis JSON
injectFromJson('{"foo": 1, "bar": "hello"}');
```

Scripts npm
-----------

[](#scripts-npm)

```
npm test           # Lancer les tests
npm run lint       # Vérifier le code
npm run format     # Formater le code
```

Licence
-------

[](#licence)

Apache License 2.0

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance46

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 72.2% 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 ~1 days

Total

5

Last Release

2733d ago

Major Versions

v0.1 → v1.02019-01-01

PHP version history (2 changes)v0.1PHP ^5.6

v1.1PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c53497f169359bdf8ab67f3690af61bd04257cdf7ad6302bd78534978115e7b?d=identicon)[rudak](/maintainers/rudak)

---

Top Contributors

[![rudak](https://avatars.githubusercontent.com/u/604478?v=4)](https://github.com/rudak "rudak (13 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (5 commits)")

### Embed Badge

![Health badge](/badges/rudak-js-injector/health.svg)

```
[![Health](https://phpackages.com/badges/rudak-js-injector/health.svg)](https://phpackages.com/packages/rudak-js-injector)
```

###  Alternatives

[j0k3r/graby-site-config

Graby site config files

22380.8k3](/packages/j0k3r-graby-site-config)[ikkez/f3-flash

Add simple Flash Messages and Flash Keys to PHP Fat-Free Framework

2026.9k5](/packages/ikkez-f3-flash)

PHPackages © 2026

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