These days in the process of doing a project, just need to use the CLI in thinkphp to run a controller in the method, in the official manual to find, found, do not know how to use:
Confused, has been Baidu TP5 how to use the CLI implementation of the method under the controller, and even I want to run the PHP file directly, I need to execute the class file to instantiate the class and Invoke methods, and then in the cmd command to enter the directory of the file
It's just that if you execute a single PHP script, that's fine, but to run the files in the TP5 framework, various classes and usage methods are not found or undefined.
Then I thought, since I can't find the way to execute the controller, I'm going to say that the code executes directly in the command file Execute method,
Then create a new command folder in the index module and create a new test.php file in the folder with the following code:
The Execute method places the PHP code that needs to be run, and the left can output the result you want,
Then in the cmd command line, enter the project directory, enter
You can run the PHP code and output the results. Finally, the question now is how the thinkphp CLI command line operates in Linux.