Invoke methods via CLI

Hello, everyone,

I work with Windows and XAMPP. Now I want some methods to be callable via a CLI (terminal). I tried to read the information from the tutorial - unfortunately without success.

It would be great if you could give me a hint how to call some methods in my Flow application via CLI.

Many Thanks

LG mark

please give Command Line — Flow Framework 8.1.x documentation another shot :wink: everything you need to know is in there ^^

And if you need a real live example just dig into the source code and see how f.x ./flow package:create is integrated.

Its really simple - at what point are you stuck?

I built a testAction() method into my StandardController.php. I would like to be able to call this via CLI.

Thanks

The thing you need is a CommandController … those are callable from the cli.

See the example here: Custom Cli Commands

that basically means, that you have not setup psr-4 autoloading in your composer.json

    "autoload": {
        "psr-4": {
            "Acme\\Charity\\": [
                "Acme.Charity/Classes"
            ],
       }
  }

then do a composer install :wink:

Something seems to be weird with your namespaces …

error message: “Acme\Charity\Command …"
class: "Acme\Charity\Controller … "

One of those is wrong.

1 Like

Adjusted the composer.json, made a composer install. The namespace is probably correct because it works for my other classes. However, I always get the error:

Required class “Acme\Charity\Command\CoffeeCommandController” could not be loaded properly for reflection from “Acme\Charity\Command\CoffeeCommandController”.

Somehow the system can’t load the class :frowning:

Hello, everyone,

it works!!! My mistake was actually the namespace!

Error: namespace Acme\Charity\Controller;
Works: namespace Acme\Charity\Command;

Many thanks for your help

LG mark

1 Like

FYI: The category “Creating Neos & Flow” is meant for core development. I moved your topic to “Using Neos & Flow”. This also allows you to mark the issue resolved (I did this for you in this case)