usage of ShellInterface in Magento 2
سؤال
I used exec() function to run the magento commands.
As exec() is not recommended used the below code .
class Test{
protected $_shell;
public function __construct(
\Magento\Framework\ShellInterface $shell
){
$this->_shell = $shell;
}
public function execute() {
$this->_shell->execute("php bin/magento cache:disable");
}
The above code not working as expected, can someone help me with the above requirement.
I am looking for running the cli commands without using SSH.
Thanks!!
المحلول
Replace your code like below
use Magento\Framework\Shell;
use Magento\Framework\Shell\CommandRenderer;
class Test{
protected $_shell;
public function __construct(
.....
.....
){
....
$this->_shell = new Shell(new CommandRenderer());
}
public function execute() {
$this->_shell->execute("php bin/magento cache:disable");
}
لا تنتمي إلى magento.stackexchange