Recently to use the thinkphp3.2 version of the CLI mode, manual is not a problem, such as php/www/index.php home/article/get, such as no problem, but the general use of the CLI mode is more scheduled tasks, this time to write to the timing of the task , such as 0 * * * * * php/www/index.php Home/article/get This will lead to the introduction of thinkphp.php failure, this problem is relatively easy to solve, but then there are various other errors, after looking at the relevant core code, finally found no need to modify the code, you can easily use the CLI mode method.
The steps are as follows:
1, the official download of the framework file inside the index.php file to introduce other files using a relative path, which led to the timing of the implementation of the introduction of the thinkphp.php file does not exist, modified to the absolute path.
Define (' App_path ', DirName (__file__). ' /application/');
Require DirName (__file__). ' /thinkphp/thinkphp.php ';
2, thinking to go back to the first half step, Just said the relative path of the index.php file with the absolute path problem, but the implementation of the CLI mode, our portal file to be different from the Web service access to the index.php file, such as adding the CLI mode of the entry file cli.php, the content is the same as index.php, and add a word
Define (' App_mode ', ' CLI ');
Defines the execution mode of the app. At this point, we have two portal files, one is the index.php of the Web service access, and the other is the CLI mode access cli.php
3, in the path/thinkphp/mode below a file, the name is called common.php, copy it out, named Cli.php, and then put inside the log class code comments or delete
' Think\log ' = Core_path. ' Log '. EXT,
4. Delete all caches under cache--Remember that all
5, another long-winded, after the CLI mode call, use cli.php entry file, such as scheduled task 0 * * * * php/www/cli.php home/article/get, if it is a Web service access, still use index.php file
The correct use of the CLI mode (command line mode) from the excited piglet http://www.xingfenxiaozhu.com/2015/11/14/thinkphp-3-2/reprint please indicate the source
If the article can help you, please give me a cup OF coffee and coffee!
thinkphp3.2 How to use CLI mode correctly