Cli 模式下的Thinkphp如何运行。
工作需要,要对在运行的代码进行整合成Cli 模式运行。
php -f /var/www/weibok/index_cli.php Action Funciton
项目是Thinkphp的2.1,然后看手册,说define('MODE_NAME','Cli')。结果没用。一看。2.1中根本没有MODE_NAME,而是define('THINK_MODE','Cli')。但是,还是不行,不管运行什么模块,都调到首页。
在3.0的Thinkphp 下也不行。也跳到首页。
有做过Thinkphp Cli 模式开发的吗?告诉一下怎么做啊。谢谢各位。
回复讨论(解决方案)
13.7.4 命令模式
命令模式用于支持命令行模式下面的PHP应用,需要在入口文件设置:
define('MODE_NAME', 'cli')? // 采用CLI运行模式运行
在命令模式下面,支持两种命令行的参数模式,
一、PATHINFO参数模式(URL_MODEL为1)
在PATHINFO参数模式下面,我们可以这样调用模块和操作
index.php module/action/id/4
二、普通参数模式(URL_MODEL设置为其它)
在普通参数模式下面 ,我们需要这样调用模块和操作
index.php module action id 4
在命令行模式下面,系统会自动把参数转换为GET变量,无论采用哪种命令行参数模式,我们可以直接使用GET变量获取参数,例如,采用下面的方式调用
index.php Info/read/category/2/id/4
在控制器中,我们可以直接获取$_GET['category'](这里传入的是2)和$_GET['id'](这里传入的是4)参数,如果你需要自己解析传入的参数顺序和值,就需要采用原生的系统变量$_SERVER['argv']来获取参数了。
我也遇到过相同的问题,没解决,不知道楼主现在有解决吗
看看哈,能否有帮助
入口文件define('APP_DEBUG',false);试试
我也是碰到了同样的问题,不知道楼主有没有继绝?

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



What does WeChat Do Not Disturb mode mean? Nowadays, with the popularity of smartphones and the rapid development of mobile Internet, social media platforms have become an indispensable part of people's daily lives. WeChat is one of the most popular social media platforms in China, and almost everyone has a WeChat account. We can communicate with friends, family, and colleagues in real time through WeChat, share moments in our lives, and understand each other’s current situation. However, in this era, we are also inevitably faced with the problems of information overload and privacy leakage, especially for those who need to focus or

How to execute .sh file in Linux system? In Linux systems, a .sh file is a file called a Shell script, which is used to execute a series of commands. Executing .sh files is a very common operation. This article will introduce how to execute .sh files in Linux systems and provide specific code examples. Method 1: Use an absolute path to execute a .sh file. To execute a .sh file in a Linux system, you can use an absolute path to specify the location of the file. The following are the specific steps: Open the terminal

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

PyCharm is a very popular Python integrated development environment (IDE). It provides a wealth of functions and tools to make Python development more efficient and convenient. This article will introduce you to the basic operation methods of PyCharm and provide specific code examples to help readers quickly get started and become proficient in operating the tool. 1. Download and install PyCharm First, we need to go to the PyCharm official website (https://www.jetbrains.com/pyc

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Why can't win7 run exe files? When using the Windows7 operating system, many users may encounter a common problem, that is, they cannot run exe files. exe files are common executable files in Windows operating systems. They are usually used to install and run various applications. However, some users may find that when they try to run the exe file, the system does not respond or gives an error message. There are many reasons for this problem. Below are some common causes and corresponding solutions:

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

Why can't win7 run bat files? Recently, many users using the Windows7 operating system have reported that they cannot run .bat files. This sparked widespread discussion and confusion. Why can't a well-functioning operating system run a simple .bat file? First, we need to understand the background of the .bat file. A .bat file, also known as a batch file, is a plain text file that contains a series of commands that can be used by the Windows command interpreter (cmd.ex
