使用ThinkPHP框架创建并运行脚本
2022/2/11 22:15:36
本文主要是介绍使用ThinkPHP框架创建并运行脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
以tp5为例
1,在application下面创建一个公共的脚本文件夹 command
2,在command下面创建一个脚本php文件 test.php
test.php 内容为下
<?php namespace app\command; use think\console\Command; //必须引入 use think\console\Input; //必须引入 use think\console\Output; //必须引入 use think\Db; /** * TODO 测试脚本 * ============================================== * 未经授权不许任何使用和传播。 * ============================================== * @date: 2022/12/11 10:30 * @author: <liumy> * @version: 1.1 */ class test extends Command //必须继承 { protected function configure() { // 指令配置 $this->setName('test'); // 设置参数 } protected function execute(Input $input, Output $output) { // 书写代码逻辑 } }
执行命令 在tp框架根目录下面
php think 创建的文件名
root@iZuf64cui3lryxchuxo6gaZ:/usr/local/nginx/html/tp5_renhe# php think test
这篇关于使用ThinkPHP框架创建并运行脚本的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-29env: php: no such file or directory
- 2024-03-01php foreach break
- 2024-02-26Exception参数 php-icode9专业技术文章分享
- 2023-12-30PHP文件批量上传-icode9专业技术文章分享
- 2023-12-30thinkphp6 withJoin-icode9专业技术文章分享
- 2023-12-27MagicArray:像php一样,让Go业务代码不再卷!
- 2023-11-18centos7编译安装PHP教程。
- 2023-11-18centos7编译安装phpMyAdmin教程。
- 2023-10-13唱衰这么多年,PHP 仍然还是你大爷!
- 2023-07-25PHP8,性能更好,语法更好,类型安全更完善