PHP Classes

File: routes/cli.php

Recommend this page to a friend!
  Classes of Ujah Chigozie peter   Luminova REST API Example   routes/cli.php   Download  
File: routes/cli.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Luminova REST API Example
Implements an example of a REST API
Author: By
Last change:
Date: 17 days ago
Size: 1,023 bytes
 

Contents

Class file image Download
<?php
use \Luminova\Routing\Router;
/**
 * This file handles all CLI commands (e.g, `php index.php demo hello'`).
 *
 * The following global variables are available in the current file:
 *
 * @var \Luminova\Routing\Router $router The routing instance.
 * @var \App\Application $app The application instance that provides access to the overall application context.
 * @var string $context The name of the current routing context (this file's context).
 */

$router->group('posts', function (Router $router) {
  
$router->before('posts', 'PostsCommand::auth');
  
  
// CRUD routes for posts
  
$router->command('/list', 'PostsCommand::list'); // Retrieve all posts
  
$router->command('/get', 'PostsCommand::show'); // Retrieve a specific post by ID
  
$router->command('/create', 'PostsCommand::create'); // Create a new post
  
$router->command('/update', 'PostsCommand::update'); // Update an existing post
  
$router->command('/delete', 'PostsCommand::delete'); // Delete a post by ID
});