你如何使用代码点火器进入交互式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?

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