PHP
-
December 20, 2022
With a routing system, you can split the different pages and handle these pages individually. Let’s find out what this URL is before we start to code.
URL consists of three parts:
- Scheme
- Domain
- Request URI.
To implement simple routing, we need to match the request URI and implement a logic responsible for processing this request URI. So, we can build as many pages as we need to, and each page will proceed by a separate PHP function or a road. Finding the right road for the request, URI is called a road, also known as dispatching a road.
Learn more in the video.
-
September 22, 2022
With routing system, you can split the different pages and handle these pages individually. Let’s find out what this URL is before we start to code.
URL consists of three parts:
- Scheme
- Domain
- Request URI.
To implement simple routing, we need to match the request URI and implement a logic that will be responsible for processing this request URI. So, we can build as many pages as we need to, and each page will proceed by a separate PHP function or a road. Finding the right road for the request, URI is called a road, also known as dispatching a road.
Learn more in the video.
-
September 03, 2022
Ever wondered how to create PHP routing to handle different requests? Let’s create custom php function that is going to find the route and process a HTTP GET request in its own callback function. We are going to have an exercise where you can practice your skill creating routes.
Creating Routes
In the routes.php file let’s create an array of routes. A key will be a route, and a value is a callback function that will be triggered to process the route.
The routes.php file:
<?php return [ '/' => function () { echo '<h1>Home Page</h1>'; }, '/login' => function (array $params) { echo '<h1>Login Page</h1>'; }, ];