I was following this article https://medium.com/@narendravaghela/cakephp-execute-shell-command-from-controller-90c8323558a and get stuck with ShellDispatcher that can't be found.
<?php
//namespace App\Controller;
//use App\Controller\AppController;
//use Cake\Console\ShellDispatcher;
class ExampleController extends AppController
{
public function index()
{
$shell = new ShellDispatcher();
$output = $shell->run(['cake', 'foo']);
if (0 === $output) {
$this->Flash->success('Success from shell command.');
} else {
$this->Flash->error('Failure from shell command.');
}
return $this->redirect('/');
}
}
Understand your question about committed first three lines:) But in that case each of them can be found as well.
My ShellDispatcher.php is in lib\Cake\Console\ShellDispatcher but this use lib\Cake\Console\ShellDispatcher; also gives me an error "not found".
What I am doing wrong?
I tried do like this App::uses('ShellDispatcher', 'Console'); as I have in my code, but got this error Fatal error: Cannot declare class App, because the name is already in use in /var/www/html/lib/Cake/Core/App.php on line 65