Vind een opleiding

How To Create MVC For PHP &PHP 7 Using ( Router Technique ) - Udemy

Doelgroep: Alle niveaus
Duur: 34 colleges - 3 uur
Richtprijs: € 199,99
Taal: Engels
Aanbieder: Udemy

>> proefles

In the context of a server-side web application, a routing system is the part of the web application that maps an HTTP request to a request handler (function/method). An HTTP request consists of a header and optionally a body. The header contains information about the request for example the method, path and host. Some methods like GET, HEAD, and OPTIONS do not make use of the request body while others like POST, PUT, and PATCH use it to pass data from a client to a server.

Using a routing system allows us to structure our application in a better way instead of designating each request to a file.

A routing system works by mapping an HTTP request to a request handler based on the request method and path specified in the URL of the request. This is exactly what we are going to build in this tutorial.


equirements.

  • You need PHP version 5 or higher running on your development machine.

  • Basic PHP knowledge including familiarity with PHP global variables.

  • An understanding of object oriented PHP.

Disclaimer.

  • This router will only handle GET and POST requests.

  • I am not going to use fancy tools and libraries. No composer, no autoloading. I want to keep focus on the concept.

  • Unit testing is great but I am not going to do it, for the purpose of keeping this tutorial short. (Sorry good developers)

  • The code I am going to write is not production ready code.


Router Features

  • HTTP methods

  • Dynamic routing with (named) route parameters

  • Flexible regular expression routing, inspired by Sinatra

  • Reversed routing

  • Custom regexes


Using Router

To use AltoRouter in your project you need a web server running PHP 5.3 or newer.


>> Meer info