关于magento2:怎么在magento中执行命令

我的项目中有需要须要执行完指定代码进行从新索引和刷新缓存,Google找了一堆文章,

最多的就是这个,我就用

 $command = ' php bin/magento indexer:reindex';
 shell_exec($command);

后果提醒谬误
Could not open input file: bin/magento
查了一下这个是因为目录不对,而后我就在这个根底上改良了如下就解决了

 $command = 'cd '.$this->rootPath.' && php bin/magento indexer:reindex';
 shell_exec($command);

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理