首页
直播
壁纸
免责声明
更多
统计
关于
Search
1
一款自动化渗透工具包 TscanPlus
225 阅读
2
获取一张美国虚拟信用卡
223 阅读
3
JS Document.evaluate()的使用
199 阅读
4
Git冲突:Please commit your changes or stash them before you merge
174 阅读
5
Python 31条 pip 命令全解析
164 阅读
默认分类
操作系统
Linux
管理面板
实用工具
开发语言
PHP
Web
python
typecho
ThinkPHP
layui
爬虫
文章分享
登录
Search
标签搜索
python
php
web
linux
Git
js
requests
自动化
宝塔
thinkphp
Centos
adb
html
typecho
layui
jquery
ubuntu
multipass
虚拟机
thikphp
YiYun
累计撰写
54
篇文章
累计收到
21
条评论
首页
栏目
默认分类
操作系统
Linux
管理面板
实用工具
开发语言
PHP
Web
python
typecho
ThinkPHP
layui
爬虫
文章分享
页面
直播
壁纸
免责声明
统计
关于
搜索到
3
篇与
的结果
2024-04-10
thinkphp6 Filesystem文件系统类的使用
config/filesystem.php配置文件中配置上传根目录及上传规则,例如:return [ 'default' => 'local', 'disks' => [ 'local' => [ 'type' => 'local', 'root' => app()->getRuntimePath() . 'storage', ], 'public' => [ 'type' => 'local', 'root' => app()->getRootPath() . 'public/storage', 'url' => '/storage', 'visibility' => 'public', ], // 更多的磁盘配置信息 ], ];filesystem api的使用: //实例化类 传入当前控制器的app类 $file = new Filesystem($this->app); /** * config/filesystem.php 配置文件系统路径。 * disk('public) 是选取config/filesystem.php 里面的public配置,可以省略disk,如果省略默认就是runtime/storage路径。 */ $getMetadata = $file->disk('public')->getMetadata('20220509.png');//获取元数据 $getSize = $file->disk('public')->getSize('20220509.png');//获取大小 $getTimestamp = $file->disk('public')->getTimestamp('20220509.png');//获取时间戳 // $getWithMetadata = $file->disk('public')->getWithMetadata('20220509.png', $getMetadata); $listContents = $file->disk('public')->listContents('topic');//列出目录下的内容 dump($listContents); $delete = $file->disk('public')->delete('topic');//删除文件 $putFile = $file->disk('public')->putFile('', $image);//保存文件 $putFileAs = $file->disk('public')->putFileAs('', $image);//指定文件名保存文件 $putStream = $file->disk('public')->putStream('', $image);//创建文件或更新(如果存在) $putStream = $file->disk('public')->put('', $image);//创建文件或更新(如果存在).<br><br> $write = $file->disk('public')->write('text\zhoage.text', '这是内容');//写入文件 $write = $file->disk('public')->createDir('zhao');//创建目录 $write = $file->disk('public')->rename('text\zhoage.text','zhao.txt');//修改文件名称 $write = $file->disk('public')->has('zhao.txt');//检查文件是否存在 $write = $file->disk('public')->read('zhao.txt');//读取文件 $write = $file->disk('public')->update('zhao.txt','这是更新后的内容');//修改现有文件 $write = $file->disk('public')->copy('zhao.txt','zhaoge/fuzhi.txt');//复制文件
2024年04月10日
67 阅读
0 评论
0 点赞
2024-03-28
用tp6新建项目 -- 转载
用thinkphp6初始化一个项目composer安装tp6框架composer create-project topthink/think tp6tp6这个名字可以随意改动 添加多应用模式composer require topthink/think-multi-app添加视图,模板引擎composer require topthink/think-viewwin下phpstudy隐藏index.php文件,要在htaccess文件里/index.ph前面加个?添加权限类composer require zhenhaihou/think-auth原文出处:用tp6新建项目
2024年03月28日
130 阅读
0 评论
0 点赞
2024-03-27
thinkphp 命令行的使用--转载
1.前言ThinkPHP 支持 Console 应用,通过命令行的方式执行一些 URL 访问不方便或者安全性较高的操作。前面学习的接口封装,都是基于 HTTP 请求的,请求时间是会有超时时间的,若使用命令行可以在后台进程运行,而不是依赖于访问进程,ThinkPHP 命令行提供了一些方便的工具 ,下面介绍如何使用 ThinkPHP 命令行。2.通过命令行查看版本在框架的根目录下,有一个 think 脚本文件,可以使用 php 进程去调用它,查看 ThinkPHP 框架版本可以使用如下命令:php think version3.快速生成控制器若想要单应用 app\controller 目录下快速生成控制器和方法,可以使用如下命令:php think make:controller test生成的控制器文件内容如下:<?php declare (strict_types = 1); namespace app\controller; use think\Request; class test { /** * 显示资源列表 * * @return \think\Response */ public function index() { // } /** * 显示创建资源表单页. * * @return \think\Response */ public function create() { // } /** * 保存新建的资源 * * @param \think\Request $request * @return \think\Response */ public function save(Request $request) { // } /** * 显示指定的资源 * * @param int $id * @return \think\Response */ public function read($id) { // } /** * 显示编辑资源表单页. * * @param int $id * @return \think\Response */ public function edit($id) { // } /** * 保存更新的资源 * * @param \think\Request $request * @param int $id * @return \think\Response */ public function update(Request $request, $id) { // } /** * 删除指定资源 * * @param int $id * @return \think\Response */ public function delete($id) { // } } {callout color="#002aff"}Tips: 其中快速生成几种常见的方法名,如果只想生成控制器可以使用 php think make:controller test --plain。{/callout}4.快速生成模型若想要单应用 app\model 目录下快速生成模型,可以使用如下命令:php think make:model TestModel生成的模型文件内容如下:<?php declare (strict_types = 1); namespace app\model; use think\Model; /** * @mixin \think\Model */ class TestModel extends Model { // }{callout color="#004cff"}Tips: declare (strict_types = 1)表示开启严格模式。{/callout}5.快速生成中间件若想要单应用 app\middleware 目录下快速生成模型,可以使用如下命令:php think make:middleware Auth生成的中间件文件内容如下:<?php declare (strict_types = 1); namespace app\middleware; class Auth { /** * 处理请求 * * @param \think\Request $request * @param \Closure $next * @return Response */ public function handle($request, \Closure $next) { // } }6.快速生成验证器若想要单应用 app\Models 目录下快速生成模型,可以使用如下命令:php think make:validate Test生成的验证器文件内容如下:<?php declare (strict_types = 1); namespace app\validate; use think\Validate; class Test extends Validate { /** * 定义验证规则 * 格式:'字段名' => ['规则1','规则2'...] * * @var array */ protected $rule = []; /** * 定义错误信息 * 格式:'字段名.规则名' => '错误信息' * * @var array */ protected $message = []; } 7.清除缓存文件若想要清除 runtime目录下的缓存文件,可以使用如下命令:php think clear清除之后如下图所示:{callout color="#004cff"}Tips: 若不需要保留空目录,可以使用 php think clear --dir。{/callout}8.输出路由定义列表若想要查看定义了哪些路由,可以使用如下命令:php think route:list9.小结本小节介绍了如何简单的使用 ThinkPHP 提供的命令行,使用这些命令行可以快速的生成控制器、模型、中间件、验证器,也可以根据实际情况选择手动创建这些文件,另外还介绍了如何使用命令行清空缓存,使用命令行查看框架中定义了哪些路由的列表。熟练地掌握这些命令行将会使你的开发效率更高。原文链接:https://www.imooc.com/wiki/thinkphplesson/thinkcommand.html
2024年03月27日
141 阅读
0 评论
0 点赞