Download the PHP package robert430404/rc-router without Composer

On this page you can find all versions of the php package robert430404/rc-router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package rc-router

Latest Stable Version Build Status codecov

What Is This?

This is RC Router. This is a simple regex based router that allows you to pass variables by using place holders in your route.

Why Write This?

I did it to flex my brain, and get a full understanding of how routing works in the PHP space. Rather than just reading about it and assuming I knew what did what, I wrote this to solidify my knowledge.

Installing The Package

Simply use composer:

composer require robert430404/rc-router

How Does It Work?

This is a composer package so it relies on composer for the autoloading of the classes. You then create a new instance of the Router() object and start assigning your routes to the instance. Once you have your routes defined, you then pass the Router() into the Resolver() and it handles your routes.

What Are Some Of The Features?

The router supports both string and integer url variables, and passes them back to you in an array. You can extend this further in any way you want. The router is very flexible in how you can use it.

You can either pass in a closure, or a named handler function to each route to control what happens when a route is matched.

When a route is not found, a RouteNotFoundException is thrown from the resolver and allows you to catch and then create your 404 handler.

You can also now write in your own custom parsers and pass them into the resolver to make things like Controller@Action calling a lot easier and cleaner to implement.

If you don't pass a cusom parser, it defaults to the built in parser.

How Do The Placeholders Work?

When there are placeholders in your route they are returned to you as an array that you can access in your handler.

You have access to string placeholders. When you define your routes, you use {} to define string placeholders like this:

You also have access to integer placeholders. When you define your route, you use {:i} to define integer placeholders like this:

Some Examples

Simple closure based route:

Simple route with a named handler:

Regex closure based route with variables:

Regex route with variables and external handler:

What Is In The Returned Values?

The "$mapped" variable returns a structure like this:


All versions of rc-router with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package robert430404/rc-router contains the following files

Loading the files please wait ....