2017 © Pedro Peláez
 

library javascript-constants

A simple tool for converting PHP constant classes into javascript constant objects

image

pamiris/javascript-constants

A simple tool for converting PHP constant classes into javascript constant objects

  • Tuesday, May 31, 2016
  • by bryanagee
  • Repository
  • 1 Watchers
  • 1 Stars
  • 83 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 12 % Grown

The README.md

php-javascript-constants

A simple tool for porting PHP constant classes to javascript constant objects, (*1)

Installation

As a dependency

Run composer require pamiris/javascript-constants, (*2)

-- or --, (*3)

Add the following line to your composer.json:, (*4)

{
  "require": {
    "pamiris/javascript-constants": "*"
  }
}

Usage

To get the executable javascript to define the object, pass the classname and an optional target name into the tool; then include the resulting js inside a script tag on your template:, (*5)

<?php
//src/myprocject/controller.php

...
use Pamiris\JavascriptConstants\Mapper as ConstantMapper;

...
function someAction()
{
  $jsConstants = ConstantMapper::getJavascriptObject('MyNamespace\MyClass');
  $this->renderTemplate('mypage',[
    ...
    'scriptContent' => $jsConstants
  ]);
{# /myproject/page.html.twig #}
{% extends base.html.twig %}
{% block javascripts %}


{% endblock %}

TODO

Add Twig extension and bundle to auto-configure., (*6)

Notes

This requires ES2015, which is supported in most broswers. Safari will let you overwrite the objects, Chrome and Firefox will not., (*7)

License

PHP JavascriptConstants is licensed under the MIT License - see the LICENSE file for details., (*8)

The Versions

31/05 2016

dev-master

9999999-dev

A simple tool for converting PHP constant classes into javascript constant objects

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Bryan J. Agee

javascript constants portability

31/05 2016

0.1.1

0.1.1.0

A simple tool for converting PHP constant classes into javascript constant objects

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Bryan J. Agee

javascript constants portability

31/05 2016

0.1.0

0.1.0.0

A simple tool for converting PHP constant classes into javascript constant objects

  Sources   Download

MIT

The Requires

  • php >=5.5

 

The Development Requires

by Bryan J. Agee

javascript constants portability