使用Expression Engine的独立PHP脚本 [英] Standalone PHP script using Expression Engine

查看:33
本文介绍了使用Expression Engine的独立PHP脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以使我可以执行$this->EE->db之类的脚本(即使用Expression Engine的类,例如访问数据库),但是可以在命令行中运行?

Is there a way to make a script where I can do stuff like $this->EE->db (i.e. using Expression Engine's classes, for example to access the database), but that can be run in the command line?

我尝试搜索它,但是文档似乎未包含此信息(请请纠正我错误).我正在使用EE 2.4(上面的链接应指向2.4文档).

I tried searching for it, but the docs don't seem to contain this information (please correct me if I'm wrong). I'm using EE 2.4 (the link above should point to 2.4 docs).

推荐答案

以下文章似乎有一种可能的方法:

The following article seems to have a possible approach: Bootstrapping EE for CLI Access

  • 复制index.php文件并将其命名为cli.php.
  • 将index.php文件移动到DOCUMENT_ROOT之外.现在,从技术上讲,这不是必需的,但没有理由进行撬动 眼睛看到您的辛苦工作,所以为什么不保护它呢?
  • 在cli.php内部,更新第26行的$ system_path以指向您的系统文件夹.
  • 在cli.php内部将第96行的$ routing ['controller']更新为cli.
  • 在cli.php内部,将第96行的APPPATH更新为$ system_path.'cli/'.
  • 复制system/expressionengine目录并将其命名为system/cli.
  • 复制cli/controllers/ee.php文件并将其命名为cli/controllers/cli.php.
  • 最后,将cli/controllers/cli.php中的类名称更新为Cli并删除方法.
  • 默认情况下,EE会调用index方法,因此请添加index方法以执行所需的操作.
  • Duplicate your index.php file and name it cli.php.
  • Move the index.php file outside your DOCUMENT_ROOT. Now, technically, this isn’t required, but there’s no reason for prying eyes to see your hard work so why not protect it.
  • Inside cli.php update the $system_path on line 26 to point to your system folder.
  • Inside cli.php update the $routing['controller'] on line 96 to be cli.
  • Inside cli.php update the APPPATH on line 96 to be $system_path.'cli/'.
  • Duplicate the system/expressionengine directory and name it system/cli.
  • Duplicate the cli/controllers/ee.php file and name it cli/controllers/cli.php.
  • Finally, update the class name in cli/controllers/cli.php to be Cli and remove the methods.
  • By default EE calls the index method, so add in an index method to do what you need.

这篇关于使用Expression Engine的独立PHP脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆