Coder Social home page Coder Social logo

sirknightdragoon / jsrouting-provider Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lucasmilin/jsrouting-provider

0.0 0.0 0.0 33 KB

javascript routing provider for the silex framework

License: GNU General Public License v3.0

JavaScript 24.18% PHP 75.82%

jsrouting-provider's Introduction

Silex JSRouting Provider

The JSRouting Provider is a silex routing provider for javascript, that exposes routes to a javascript file. Then you can generate routes for use with javascript frameworks like AngularJS.

Build Status Total Downloads Latest Stable Version Scrutinizer Code Quality

Installation

Add the provider to your composer.json

{
  "requires": {
    "rootlogin/jsrouting-provider": "~1.0"
  }
}

Register the provider in your silex application:

$app->register(new rootLogin\JSRoutingProvider\Provider\SilexJSRoutingServiceProvider(), array(
  "jsrouting.base_url" => "/",
  "jsrouting.exposed_routes" => array("routeA", "routeB")
  ));

Set the route option expose to true.

$controllers->get("/hello", function() {
    return "hello world"!
})->bind("hello")->getRoute()->setOption("expose",true);

Include and use it in your frontend like this.

<!-- Gets the full router with the routes -->
<script src="{{ path("jsrouting") }}"></script>

<!-- Or if you want only some parts you can get the router and the routes separately -->
<script src="{{ path("jsrouter") }}"></script><!-- Gets only the router -->
<script src="{{ path("jsroutes") }}"></script><!-- Gets only the routes -->

<!-- Get routes like this -->
<script>
  console.log(router.generate("routeA"));
  console.log(router.generate("routeB", {id: 3}));
</script>

Console

If you want to use the console commands please install at least saxulum/saxulum-console. It will be automatically activated after you registered the provider.

Available Commands

  • jsrouting:dump: This dumps the router with the known routes (buggy, ATM);
  • jsrouting:dump:router.js: This only dumps the router.js. You need to add the routes manually.

Run the tests

Go to the base directory of the jsrouting-provider. Do a composer install and enter vendor/bin/phpunit.

Run the javascript tests

Do a npm install and enter node_modules/.bin/gulp test. Or if you have installed gulp globally enter gulp test.

Contribution

Pull request are welcome. Or if you can't or want code you can also contribute by opening a ticket if you see something is wrong.

Warning

This project is in early development stages. No warranty if it kills your kittens or starts a nuclear war ;)

jsrouting-provider's People

Contributors

chrootlogin avatar m-idler avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.