PHPackages                             sunmant/phpconst2js - 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. sunmant/phpconst2js

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

sunmant/phpconst2js
===================

A small library for converting PHP class constants to JSON array. You can use it when you new constants values from PHP backend in JavaScript code

v1.0(8y ago)018Apache-2.0PHPPHP &gt;=5.4

Since Dec 26Pushed 5y ago1 watchersCompare

[ Source](https://github.com/lebedevsergey/phpconst2js)[ Packagist](https://packagist.org/packages/sunmant/phpconst2js)[ RSS](/packages/sunmant-phpconst2js/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

PHPconst2JS
===========

[](#phpconst2js)

### What is it?

[](#what-is-it)

- A small library that outputs PHP class constants as JSON array for transfering constants values from PHP backend to JavaScript code

### How to use it?

[](#how-to-use-it)

- Add PHPConst2JScode to your project `composer require sunmant/phpconst2jscode`
- create PHPConst2JScode object: `$c = new PHPConst2JScode()`
- add class with constants you need in your JS code: `$c->addClassConstants(ClassWithConstants::class);`
- get constants JSON and add it to your JS code, for example like this: `echo 'var PHPConstants = ' . $c->getJSON();` (It is better to use fully qualified class names here than aliases)
- now you can use PHP constants values in yourJS code: `var someConstantValue = PHPConstants['ClassWithConstants::SOME_CONSTANT'];`

### What else?

[](#what-else)

- PHP 5 or higher is required

### Author?

[](#author)

- (c) 2017 Sergey Lebedev, licensed under the Apache License, Version 2.0
- Feel free to contact me at:
    -
    -
    -

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

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

Unknown

Total

1

Last Release

3155d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7325764?v=4)[lebedevsergey](/maintainers/lebedevsergey)[@lebedevsergey](https://github.com/lebedevsergey)

---

Top Contributors

[![diacomltd](https://avatars.githubusercontent.com/u/6900793?v=4)](https://github.com/diacomltd "diacomltd (22 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sunmant-phpconst2js/health.svg)

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

###  Alternatives

[bitgrave/barcode-bundle

provide barcode rendering service into your Symfony2 application.

24448.2k1](/packages/bitgrave-barcode-bundle)[dachcom-digital/news

Pimcore News

1729.8k](/packages/dachcom-digital-news)

PHPackages © 2026

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