douwu7563 2017-10-12 18:32
浏览 14
已采纳

你如何使用代码点火器进入交互式php控制台?

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?

  • 写回答

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 and MethodName with whatever the controller or method is.

    php index.php ControllerName MethodName
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?