thinkphp3.2 cli模式的正确使用方法(2019-04-08修改)

thinkPHP3.2.3定时执行任务 thinkPHP3.2.3使用Cron实现网站访问执行任务。 立即下载

最近要使用thinkphp3.2版本的cli模式,手动执的话没有问题,比如php /www/index.php home/article/get 这样没有问题,但是一般用cli模式都是定时任务比较多,这个时候写到定时任务的时候,比如 0 * * * * * php /www/index.php home/article/get 这样就会出现引入ThinkPHP.php失败的问题,这个问题算是比较容易解决的,但是后来还有其他各种报错,经过查看相关核心代码,终于找到无需修改代码,就可以轻易使用cli模式的方法。

步骤如下:
1、官方下载的框架文件里面的index.php文件引入其他文件使用的是相对路径,这导致了定时执行的时候引入ThinkPHP.php文件不存在的问题,修改成绝对路径即可。
define( 'APP_PATH', dirname(__FILE__).'/Application/' );
require dirname( __FILE__).’/ThinkPHP/ThinkPHP.php';

2、思维要倒回去第半步,刚刚说index.php文件的相对路径跟绝对路径的问题,但是执行cli模式的时候,我们的入口文件要有别于通过web服务访问的index.php文件,比如增加cli模式的入口文件cli.php,内容跟index.php的一样,同时增加一句话
define(‘APP_MODE’,'cli');
定义APP的执行模式。此时,我们有两个入口文件,一个是web服务访问方式的index.php,另一个是cli模式访问的cli.php
3、在路径 /ThinkPHP/Mode 下面有个文件,名字叫做common.php ,复制一份出来,命名为cli.php,然后把里面引入日志类的代码注释或者删除掉
'Think\Log' => CORE_PATH . ‘Log'.EXT,

4、删除缓存下面的所有缓存——记得是所有

5、再啰嗦一句,以后cli模式调用的时候,就用cli.php入口文件,比如定时任务 0 * * * * php /www/cli.php home/article/get ,如果是web服务访问,则依然使用index.php文件

6.get传参  方式     php cli.php home/article/get/name/33/model/ddd   ,最后方法接受到的就是 name=33,model=ddd

ThinkPHP3.1.2 使用cli命令行模式运行的方法 主要介绍了ThinkPHP3.1.2 使用cli命令行模式运行的方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下 立即下载

相关推荐

Android 导出aar 用于Unity 百度语音唤醒

AndroidStudio版本下载地址Android Studio Arctic Fox Unity版本2021.3.26f1c1 新建AndroidStudio工程 新建module 这里注意一下,网上很多教程说要注意包名要和unity一样,但是测试下来,不一样也可以的 在新建的module里添加这两个jar包,并点击右键add as library 导入jniLibs 右键创建这几个package 代码就安装这个大佬的写参考代码 需要注意的的是在WakeupListener脚本里U

weixin_38777563的博客 633

thinkphp 3.2的cli模式(命令行模式)的正确使用方法

最近要使用thinkphp3.2版本的cli模式,手动执的话没有问题,比如php /www/index.php home/article/get 这样没有问题,但是一般用cli模式都是定时任务比较多,这个时候写到定时任务的时候,比如 0 * * * * * php /www/index.php home/article/get 这样就会出现引入ThinkPHP.php失败的问题,这个问题算是比较容

科比不来it 1万+

告别拼音!用VSCode+Dosbox-X搞定汇编语言课程设计里的中文姓名显示

本文详细介绍了如何利用VSCode和Dosbox-X解决汇编语言课程设计中中文姓名显示的问题。通过配置开发环境、理解GB2312编码及正确使用汇编指令,学生可以告别拼音显示,实现中文字符的正确输出。文章还提供了完整的代码示例和常见问题排查方法,帮助读者快速掌握这一实用技能。

weixin_30872337的博客 424

thinkphp 命令行执行

echo $PATH/root/perl5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin这里/usr/local/bin优先于/usr/bin。上面的意思是,linux执行任何命令,都会先去/usr/local/sbin,如果没有再去/usr/local/bin下面,如果还没有就去/usr/local/bin,以此类推,如果都没有,就会提示找不到命令。/usr/bin存放一些用户命令,如led(控制LED灯的)。

xiaopzi的博客 1929

智能汽车竞赛摄像头处理(4)——摄像头循迹思路讲解

智能汽车竞赛摄像头处理(4)对摄像头循迹思路进行讲解。

weixin_62261692的博客 7054

在 STM32CubeIDE 中针对 STM32F407 移植 ThreadX

在 STM32CubeIDE 中针对 STM32F407 移植 ThreadX,不依赖盗版破解的Keil MDK、IAR等软件。

wangyuewu08的博客 3374

windows设置定时任务运行ThinkPHP框架程序

1. 设置Windows的任务计划可以参考win7计划任务的设置方法2. 新建Windows执行文件bat新建cron.bat文件,内容如下:D: cd \wamp\www\tp32 D:\wamp\bin\php\php.exe index.php /Home/Crontab/testPHP在命令环境下执行ThinkPHP框架程序时,必须进入到ThinkPHP框架的根目录下执行,否则会执行失败3...

国梁的学习笔记 4044

TMS320F28377D的sys/bios双核工程配置详解——从零搭建到RAM优化

本文详细解析了TMS320F28377D双核系统在sys/bios环境下的工程配置与RAM优化策略。从开发环境搭建、SYS/BIOS工程创建到双核CMD文件配置,提供了实战技巧和常见问题解决方案,帮助开发者高效实现电力电子控制系统中的双核协作与性能优化。

weixin_28292761的博客 600

ThinkPHP3.2.3使用cli命令行模式

<?php if (version_compare(PHP_VERSION, '5.3.0', '<')) die('require PHP > 5.3.0 !'); // 开启调试模式 建议开发阶段开启 部署阶段注释或者设为false define('APP_DEBUG', TRUE); //CLI //define('APP_MODE','cli'); // 采用CLI运行模式运行 define('MODE_NAME','cli'); // 定义应用目录 define('APP_P

minihuabei的博客 785

量化金融笔记1-股票量化基础

股票量化基础 文章目录什么是股票股票的定义及其诞生所解决的问题股票的主体和流通股票的常规分类股票价格收益率什么是股票价格的收益率股票价格收益率计算在python中的实现两种收益率算法的特点及应用场合股票交易规则场内交易与场外交易A股、B股、H股国内多层次的资本市场股票交易指令和撮合机制股票交易时间股票交易成本股票复权股票数据介绍与提取行业分类和指数行情数据因子数据标的数据基本面数据 什么是股票 股票的定义及其诞生所解决的问题 股票的定义:股票是一种有价证券,是股份有限公司公开发行的用以证明投资者的股东身份

折桂狂人的博客 2394

allegro 约束管理Constraint Manager(一)

介绍Cadence allegro 约束管理器CM的使用方法。

weixin_38975819的博客 8711

thinkphp3.2开启cli模式执行

摘要:CLI是Command Line Interface的缩写,即命令行界面。thinkphp对cli执行不是很友好,如果直接手动执行,是没什么太大问题,但如果crontab定时任务执行,则会报错,因此调整下。 一、在index.php同等级目录下新建一个cli.php,添加: <?php // 检测PHP环境 if(version_compare(PHP_VERSION,'5.3.0','<')) die('require PHP > 5.3.0 !'); // 开启调试模式

七叶博客 1007

SwinTransformer 改进:SSPCAB模块(2024最新改进方法)

SSPCAB(Spatial Pyramid Pooling with Channel Attention Block)是2024年提出的一种新型神经网络架构改进方法,专注于在保持高精度的同时显著降低计算复杂度和参数量。该方法通过创新的空间金字塔池化与通道注意力机制的结合,实现了网络结构的紧凑化和运算效率的大幅提升。核心创新点1. 混合空间金字塔池化(Hybrid Spatial Pyramid Pooling, HSPP)多尺度动态核池化:根据输入特征图尺寸动态调整池化核大小和步长交叉级联结构。

Henry的博客 1306

thinkphp3.2 cli模式的正确使用方法

最近要使用thinkphp3.2版本的cli模式,手动执的话没有问题,比如php /www/index.php home/article/get 这样没有问题,但是一般用cli模式都是定时任务比较多,这个时候写到定时任务的时候,比如 0 * * * * * php /www/index.php home/article/get 这样就会出现引入ThinkPHP.php失败的问题,这个问题算是比较容

tingliting的专栏 669

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

ThinkPHP5.1 CLI命令行模式

今天在改进老项目的时候遇到了需要使用ThinkPHP的CLI模式,也就是命令行模式去运行PHP代码。 普通的PHP使用命令行模式这个就不用我多说了~ 其实ThinkPHP5.1关于这个命令行模式官方手册也有介绍。当然,还是记录一下,以防后面忘记了又要翻文档。 当前TP5.1版本是5.1.38,关于查看TP版本,在CMD下输入php think version即可查看 如果输入PHP命令,...

九城科技 博客:https://blog.minkse.cn/ 5465

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Thinkphp3.2 cli模式的配置与使用方法

平常我们在命令行执行php脚本的方法一般都是这样的 1 2 #...phpcommon.php #...phpcommon.phpparams.. 以上php为服务器上的php可执行文件,common.php 是你要执行的脚本文件,params 参数 参数设置方法 php文件后空格+参数 程序里用argv[]来读参数,你会接到一个 argv 数组 argv[1] argv[2] ... thinkphp在地址栏上访问...

实际工作与学习当中的随记 827

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

php think命令,ThinkPHP3.1.2 使用cli命令行模式运行的方法

前言thinkphp3.1.2 需要使用cli方法运行脚本折腾了一天才搞定3.1.2的版本真的很古老解决增加cli.php入口文件define ('APP_NAME','App');define ('APP_PATH','./App/');define('APP_DEBUG', true);define('MODE_NAME','cli');require './Base/ThinkPHP.php...

weixin_39634985的博客 375

tp cli.php,Thinkphp3.2 cli模式的配置与使用方法

平常我们在命令行执行php脚本的方法一般都是这样的#...phpcommon.php#...phpcommon.phpparams..以上php为服务器上的php可执行文件,common.php 是你要执行的脚本文件,params 参数参数设置方法php文件后空格+参数程序里用argv[]来读参数,你会接到一个 argv 数组 argv[1] argv[2] ...thinkphp...

weixin_39721953的博客 467

thinkphp3.2版本的cli模式 实现定时任务 curl

最近要使用thinkphp3.2版本的cli模式,手动执的话没有问题,比如php /www/index.php home/article/get 这样没有问题,但是一般用cli模式都是定时任务比较多,这个时候写到定时任务的时候,比如 0 * * * * * php /www/index.php home/article/get 这样就会出现引入ThinkPHP.php失败的问题,这个问题算是比

智行晓东的博客 1925

ThinkPHP中关于CLI的使用方法

ThinkPHP中关于CLI的使用方法

xiao_xiao_meng的博客 5326

Java Excel处理升级:从EasyExcel到POI自定义引擎

Excel文件处理是Java企业级应用中的基础能力,其核心涉及Workbook、Sheet、Row、Cell等物理结构操作与样式、公式、合并单元格等语义表达。Apache POI作为底层事实标准,提供了对.xlsx/.xls格式的完整XML级控制能力;而EasyExcel则在其之上构建了注解驱动的声明式封装。当面临复杂表头导入、动态合并单元格、富文本换行失效、NoSuchFieldError工厂异常等高频问题时,封装带来的抽象泄漏便暴露无遗——这并非EasyExcel缺陷,而是工程权衡下的必然边界。真正的技

weixin_34345753的博客 195
上一篇: mysql 获取某个时间段每一天、每一个小时的统计数据
下一篇: 网络爬虫技术
chenrui310
博客等级 码龄15年 165粉丝 48原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值