PHP code example of m4rc / reut_cli

1. Go to this page and download the library: Download m4rc/reut_cli 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/ */

    

m4rc / reut_cli example snippets


    use Reut\Router\ReuteRoute;

    $routes = ReuteRoute::use($this->app);

    // Grouped endpoints
    $routes->group('/invoices', 'Invoices', function (ReuteRoute $group) {
        $group->get('/all', $listHandler, 'List invoices');
        $group->post('/pay/{id}', $payHandler, 'Pay invoice', true);
    });

    // Standalone route
    $routes->get('/health', $healthHandler, 'Service healthcheck');
    

  // Customize table name, field mappings, token expiry
  $authConfig = [
      'table' => 'Users',  // or your custom table
      'fields' => [
          'identifier' => 'email',  // 'email' or 'username'
          'password' => 'password',
      ],
      'token_expiry' => 3600,  // seconds
  ];
  

  class CustomAuthController extends AuthController {
      protected function validateLogin(array $credentials): ?array {
          // Add custom checks (e.g., check if user is active)
          $user = parent::validateLogin($credentials);
          if ($user && $user['is_active'] === false) {
              return null; // Reject inactive users
          }
          return $user;
      }
  }
  

    $this->addForeignKey('user_id', 'Users');
    

    parent::__construct(
        $config,
        [],
        'Users',
        false,
        [],
        [], // File fields
        ['add', 'delete'], // Disabled routes: 'all', 'find', 'add', 'update', 'delete'
        ['created_at', 'updated_at'], // Protected columns
        null, // strictRequiredValidation
        [], // File field types
        false // 

    parent::__construct(
        $config,
        [],
        'Users',
        false,
        [],
        [], // File fields
        [], // Disabled routes
        ['created_at', 'updated_at'], // Protected columns
        null, // strictRequiredValidation
        [], // File field types
        true // 
bash
composer global 
bash
Reut manage.php generate:model Users