I have an existing code igniter app. If I try to enter a console with php -a
but none of my code igniter classes are loaded. How do can this be achieved?

你如何使用代码点火器进入交互式php控制台?
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- dongliao3450 2017-10-12 18:45关注
If you want to write PHP in the terminal with the CodeIgniter framework loaded, I'm not sure that'll be possible because CodeIgniter includes this line on every file.
defined('BASEPATH') OR exit('No direct script access allowed');
If you want to run some of the code of your project through the terminal, this page may be useful to you.
https://www.codeigniter.com/userguide3/general/cli.html
You'll go to your project root, and run something along the lines of the following, replacing
ControllerName
andMethodName
with whatever the controller or method is.php index.php ControllerName MethodName
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报