1. Go to this page and download the library: Download dconco/php_slides library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dconco / php_slides example snippets
(slides)
e;
use PhpSlides\view;
Route::config();
Route::view("/login", "::Login");
(slides)
namespace PhpSlides\Controller;
final class UserController extends Controller
{
public function __invoke(int $id) {
return "<h2>Get User with ID = {$id}</h2>";
}
}
(slides)
use PhpSlides\Route;
use PhpSlides\Controller\UserController;
Route::config();
Route::get("/user/{id}", [ UserController::class ]);
(slides)
final class UserController extends Controller
{
public function __invoke() {
return "<h2>Invoked User Successful. Receieved all users successfully.</h2>";
}
public function User($id) {
return "<h2>Received an ID - $id for a user.</h2>";
}
}
(slides)
use PhpSlides\Api;
Api::get();
Api::post();
Api::put();
Api::patch();
Api::update();
Api::delete();
(slides)
use PhpSlides\Api;
Api::post("/api/users");
Api::post("/api/users/{id}", @user);
(slides)
namespace PhpSlides\Controller;
final class UserController extends Controller
{
function __invoke() {
$response = ['data' => 'We have gotten all users id successful'];
return json_encode($response);
}
function user(int $id) {
$response = ['data' => 'The particular user id = $id'];
return json_encode($response);
}
}