Universeorange.com/Docs/

R3m/framework Add cli

To add a cli program (Command Line Interface):

First add a route in <project_dir>/Host/<domain>/Data/route.php:

{                
    "<domain>-hello-world": {
        "path": "hello",         
        "controller" : "Host.<domain>.Controller.Hello.world",
        "method": [
            "CLI"            
        ]
    },
    ...
}

Then add the controller in <project_dir>/Host/<domain>/Controller/Hello.php:

<?php

namespace Host\<domain>\Controller;

use R3m\Io\App;
use R3m\Io\Module\View;

class Hello extends View {
    const DIR = __DIR__ . DIRECTORY_SEPARATOR;
    const NAME = 'hello';

    public static function world(App $object){
        $parameter = $object::parameter($object, Hello::NAME, 1);
        dd(Hello::NAME . ' ' . $parameter);
    }
}

you should see this when running command: <name> hello world;

<project_dir>/Host/<domain>/Controller/Hello.php:14
string(11) "hello world"

where <name> is the named binary created in the installation

Last modified: 2021-06-07

© 2021 universeorange.com