Download the PHP package hypario/router without Composer

On this page you can find all versions of the php package hypario/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 router

A simple Router

Build Status Coverage Status

This Router is a project for people who want to understand how a router works, and it can be used to start a project really quickly without using any Framework such as Laravel or Symfony

Installation

You can install this package using composer

How to use it

basics

here we will talk about how to use the route for routes that doesn't need parameters

Like every other Router you have to initialize the Router, and write the routes you want like this :

There are other method you can choose such as the POST method

Careful ! those methods don't mean you can reach those pages, now you have to match your URL and the routes

How to match the URL and the route

To match the route you have to use the match method from the router, it will return the route or null if none matched

here $_SERVER['REQUEST_URI'] is used to get the URL, but you can use an object that implement the ServerRequestInterface from the PSR or a custom $_GET that give the URL

When you get the matched route, you can get the handler (here the function).

output : Hello World if the url is the main page of your website www.mydomain.com

The handler can be a string (like the name of a callable class) or a callable (like here, a function) as the router do not handle the way you're calling the handler.

Routes with parameters

A route with parameters is a classical route, but whenever you want to add parameter, it must be surrounded by {} and the name of the parameter and a pattern to match separated by : like below.

{name:[a-z]+} is one needed parameter of the route /hello, which name is the name of the parameter, and [a-z]+ is the pattern to match for the parameter.

Named routes

The name of a route is just one more parameter to the method you want to create

I can now generate an uri to my index which will return /

It also works for routes with parameters, you only need to add the array of parameters to the function

If two routes have the same name, it will generate the path of the LAST defined route


All versions of router with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
psr/http-message Version ^1.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 hypario/router contains the following files

Loading the files please wait ....