Download the PHP package nicollassilva/minasrouter without Composer

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

Router @MinasRouter

a

Maintainer Scrutinizer Code Quality Latest Version Build Status Code Intelligence Status

MinasRouter is simple, fast and extremely readable for routes. Create and manage your routes in just a few steps.

Simples, rápido e MUITO funcional. MinasRouter é um componente de rotas PHP para projetos MVC! Foi feito para abstrair os verbos RESTfull (GET, POST, PUT, PATCH, DELETE) e renderizar de forma simples e fácil no controller da aplicação.

MinasRouter trabalha e processa todas as informações de forma isolada, facilitando o processo para o desenvolvedor e acelerando o desenvolvimento/andamento do projeto.

Simple, fast and VERY functional. MinasRouter is a PHP routes component for MVC projects! It is designed to abstract the RESTfull (GET, POST, PUT, PATCH, DELETE) verbs and render them simply and easily in the application controller.

MinasRouter works and processes all information in isolation, facilitating the process for the developer and accelerating the development/progress of the project.

Highlights @MinasRouter

With two lines you start using routes!

Application example

Maybe you are a person who learns by watching, you can access the example folder, which contains an folders architecture example of how we use MinasRouter.

Tests

You can check all tests done here. Enjoy!

Installation

MinasRouter is available via Composer require:

or run in terminal:

Documentation

1. Configuration

3. Request Route

Introduction

Para começar a usar o MinasRouter, todo o gerenciamento da navegação deverá ser redirecionado para o arquivo padrão de rotas do seu sistema, que fará todo o processo de tratamento das rotas e retornará o que foi por padrão configurado. Configure conforme os exemplos abaixo e de acordo com seu servidor.

To start using MinasRouter, all navigation management must be redirected to your system's default route file, which will do the entire route handling process and return what was configured by default. Configure according to the examples below and according to your server.

Redirect to Public Folder

apache

nginx

The first Route

To start the components:

RESTfull Verbs

Methods:

Function Parameter Parameter Parameter
get String $uri $callback
post String $uri $callback
put String $uri $callback
patch String $uri $callback
delete String $uri $callback
match Array $httpVerbs String $uri $callback
any String $uri $callback

Example:

Named routes

Methods:

Function Parameter
name String $name
as String $name

Example:

Dynamic parameters (required and optional)

Validating a dynamic parameter

Methods:

Function Parameter Parameter
where Array $params
whereParam String $param String $regex
whereNumber String $param
whereAlpha String $param
whereAlphaNumeric String $param
whereUuid String $param

Example:

Middlewares

Working with middlewares around here is pretty easy, we just need to pass the full names of the classes or set them as global, and from there, we use their alias.

Set Global Middlewares

OBS: It is important that you place all routes below. Routes above this class will not have these middlewares as global.

Attach in a route

You may use the middleware method to assign middleware to a route.

You may assign multiple middleware to the route by passing an array of middleware names to the middleware method.

When assigning middleware, you may also pass the fully qualified class name:

Delete a middleware

Sometimes you create a group of routes with middleware, but you want only one or a few routes to be without a specific middleware, you can do that.

Route Groups

All methods:

Function Parameter ::function ->function
namespace String $namespace Yes Yes
prefix String $prefix Yes Yes
name String $name Yes Yes
middleware String $middlewares Yes Yes

Group methods can be called static way or normal, don't forget to call a function group to insert as routes inside the closure.

Examples:

Named group

Prefixed group

Default namespace group

Default Middleware group

Nested group methods

Others

Route with Individual Middleware in group

You can use routes with individual middlewares within a route group.

Route with Different name in group

Maybe you are wanting a route where you ignore the group name, you can use the second parameter of the name method for that.

Route redirect

Methods:

Function Parameter Parameter Parameter
redirect String $uri String $redirect Int $statusCode = 302
permanentRedirect String $uri String $redirect

Example:

Fallback Routes

The fallback route is responsible when there is no route registered with that url address. Whenever there is no route that was requested by the user, the fallback route will be called.

OBS: Tenha cuidado caso queira redirecionar para uma rota existente, se nela conter argumentos dinâmicos, ela retornará todo o regex e irá causar erro.

Be careful you redirect to an existing route, because if it has dynamic arguments, it will return the entire regex and error returned.

Request Route

Each time the route is called and the Closure or controller method is called, you will have as a parameter an instance of \MinasRouter\Http\Request. If the route has dynamic parameters (mandatory or optional), they need to be passed before receiving the Request instance.

Function Parameter Parameter
getParams
path
url
fullUrl
header String $header String $default
hasHeader String $header
ip
query ?String $query ?String $default
all ?String $except
getMethod
isMethod String $expectedMethod

The dynamic parameters of the route are directly passed in the method together with a instance of Request.

Example:

The Request method is the method that has all your form data, query parameters, dynamic route parameters, and the entire request header.

Request Methods

Retrieving The Request Path

The path method returns the request's path information. So, if the incoming request is targeted at http://localhost/foo/bar, the path method will return foo/bar:

Retrieving The Request URL

To retrieve the full URL for the incoming request you may use the url or fullUrl methods. The url method will return the URL without the query string, while the fullUrl method includes the query string:

Request Headers

You may retrieve a request header from the \MinasRouter\Http\Request instance using the header method. If the header is not present on the request, null will be returned. However, the header method accepts an optional second argument that will be returned if the header is not present on the request:

The hasHeader method may be used to determine if the request contains a given header:

The bearerToken method may be used to retrieve a bearer token from the Authorization header. If no such header is present, null will be returned.

Request IP Address

The ip method may be used to retrieve the IP address of the client that made the request to your website:

Retrieving Data

The query method will only retrieve values from the query string:

If the requested query string value data is not present, the second argument to this method will be returned:

You may call the query method without any arguments in order to retrieve all of the query string values.

You can access queryString's and input data directly, how properties of the Request class.

You may retrieve all of the incoming request's input data as an array using the all method. This method may be used regardless of whether the incoming request is from an HTML form or is an XHR request. If you want to nullify some data, you can pass it as a second parameter.

Retrieving The Request Method

The getMethod method will return the HTTP verb for the request. You may use the isMethod method to verify that the HTTP verb matches a given string:


All versions of minasrouter with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
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 nicollassilva/minasrouter contains the following files

Loading the files please wait ....