This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

chris10207
chris10207

Hi, how is it possible to call a command from a button in the backend ?

Tschallacka
Tschallacka

data-request="onWhateverHandler"

then have in your model/controller/component/whatever a function

public function onWhateverHandler() {
       Flash::error("DO NOT CLICK THIS BUTTON!");
       return "you clicked it";
}

read https://octobercms.com/docs/cms/ajax and https://octobercms.com/docs/backend/controllers-ajax

chris10207
chris10207

Thanks Tschallacka, actually im refering to Console Command Line that i develop for my plugin. here : http://octobercms.com/docs/console/development

i would need to run them manually on demand from the backend and not from the console which my client does not have access to and have no clue how to use it and does not want to learn how of course :)

chris10207
chris10207

ok i got it, in the AJAX Handler controller, you can use the Laravel Artisan Facade to call a console command.

public function onImport()
    {
      try {
            traceLog('init task...');
            Artisan::call('acme:import');
            traceLog('done ...');
        } catch (Exception $e) {
            Response::make($e->getMessage(), 500);
        }
    }

Last updated

1-4 of 4

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.