2017 © Pedro Peláez
 

library router

Millennium PHP Router

image

millennium/router

Millennium PHP Router

  • Tuesday, October 4, 2016
  • by desertknight
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Router

PHP Router is totally inspired by Gatakka/PGF-Router and does not use regular expressions too., (*1)

SensioLabs Insight Travis CI Scrutinizer CI
SensioLabsInsight Build Status Scrutinizer Code Quality Code Coverage Build Status

Dependency Status Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

Requirements:

  • "symfony/yaml": "*"

Suggest

  • "php": ">=5.4.0"
  • "ext-mbstring": "*"

Features:

  • Integrate Memcache or other cache systems
  • Maybe some refactoring and optimizing

Installation and configuration:

Install with Composer, run:, (*3)

composer require millennium/phpcache

, (*4)

Routers example

This is sample router configuration, (*5)

path: /                         # require
action:                         # Some action, we use Namespace:Controller:action
methods: []                     # any valid HTTP methods combination (GET, POST, PUT, DELETE) **ONLY UPPER STRING**
requires: []                    # requires url parameters
defaults: []                    # defaults parameters
security: []                    # this is future, for now is only validation ip request (eg. allow only from ips array)
import: path                    # you can import other yaml routing files, path, security and methods will be overriding

File look like this, (*6)

homepage:
    path: /
    action: Namespace:Controller:action
user_action:
    path: /user/:id/:action
    action: Namespace:Controller:action
    methods:
        - GET
    requires:
        id: digit
        action: [add, view, edit, delete]
admin_user:
    path: /admin
    import: ./config/routes_user_admin.yml
    security:
        - { ip: [127.0.0.1, ::1] }

Usage examples:

collectRouters("router.yml");

$router = new Router();

try {
    $route = $router->findRoute('/', $collections);
} catch (\Exception $e) {
    trigger_error($e->getMessage(), E_USER_ERROR);
}
```


### Server Configuration

#### Apache

You may need to add the following snippet in your Apache HTTP server virtual host configuration or **.htaccess** file.

```apacheconf
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]
```

Alternatively, if you’re lucky enough to be using a version of Apache greater than 2.2.15, then you can instead just use this one, single line:
```apacheconf
FallbackResource /index.php
```

#### IIS

For IIS you will need to install URL Rewrite for IIS and then add the following rule to your `web.config`:
```xml

<configuration>
    <system.webServer>
        <rewrite>
          <rule name="Toro" stopProcessing="true">
            <match url="^(.*)$" ignoreCase="false" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                <add input="{R:1}" pattern="^(index\.php)" ignoreCase="false" negate="true" />
              </conditions>
            <action type="Rewrite" url="/index.php/{R:1}" />
          </rule>
        </rewrite>
    </system.webServer>
</configuration>

Nginx

Under the server block of your virtual host configuration, you only need to add three lines., (*7)

location / {
  try_files $uri $uri/ /index.php?$args;
}

Contributions

Contributions to PHPRouter are welcome via pull requests., (*8)

License

PHPRouter was created by Zlatko Hristov and released under the MIT License., (*9)

The Versions

04/10 2016

dev-master

9999999-dev

Millennium PHP Router

  Sources   Download

MIT

The Requires

 

by Zlatko Hristov

php router routing system array tree

04/10 2016

dev-analysis-q207W9

dev-analysis-q207W9

Millennium PHP Router

  Sources   Download

MIT

The Requires

 

by Zlatko Hristov

php router routing system array tree

21/02 2016

v2.0.1

2.0.1.0

Millennium PHP Router

  Sources   Download

MIT

The Requires

 

by Zlatko Hristov

php router routing system array tree

22/09 2015

v1.0.4

1.0.4.0

Millennium PHP Router

  Sources   Download

MIT

The Requires

 

by Zlatko Hristov

php router routing system array tree

25/05 2015

v1.0.3

1.0.3.0

Millennium PHP Router

  Sources   Download

MIT

The Requires

 

The Development Requires

by Zlatko Hristov

php router routing system array tree

20/05 2015

v1.0.2

1.0.2.0

Millennium PHP Router

  Sources   Download

MIT

The Requires

 

The Development Requires

by Zlatko Hristov

php router routing system array tree

20/05 2015

v1.0.1

1.0.1.0

Millennium PHP Router

  Sources   Download

MIT

The Requires

 

The Development Requires

by Zlatko Hristov

php router routing system array tree