New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

2max/improuter

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

2max/improuter

Router for PHP application

Source
Packagist
Version
1.0.5-alpha
Version published
Total downloads
29
Maintainers
1
Created
Source

ImpRouter

ImpRouter is a PHP library which allow to include simple routing system.

Installation

With Composer, to include this library into your dependencies, you need to require 2max/improuter:

$ composer require 2max/improuter

Then, you can install files automatically (recommanded with project from scratch). Add this lines in your composer.json

"scripts": {
  "imp:install": "M2Max\\ImpRouter\\ImpCli::install"
}

And execute this command :

$ composer imp:install

If you wont use this way, you should create JSON files. You can found example in src/route.default.json. You can named your files as you want.

Example: route.json

{
  "root_path": "/",
  "route": {}
}

Then, you should instanciate ImpRouter class in index.php :

<?php
require __DIR__.'/vendor/autoload.php';

try {
  new M2Max\ImpRouter\ImpRouter('route.json');
}
catch(Exception $e) {
  echo 'Error :: '.$e->getMessage();
}

Getting Started

You should set your json files (route.json) for add routes.

Example :

{
  "root_path": "/",
  "route": {
  	"/": {
  	  "get": {
        "target": "\\TestController::test2"
      }
    }
}

"root_path": directory where are your source code "controller": name of your class "action": name of your method

Then, think to create class and method and let's go !

FAQs

Package last updated on 18 Feb 2017

Related posts