随笔分类 - thinkphp5
1
thinkphp5
摘要:模板基本使用 控制器 application/index/controller/index.php <?php namespace app\index\controller; use think\Controller; class Index extends Controller { public
阅读全文
摘要:安装图片处理类库 composer require topthink/think-image 打开图片 $image = \think\Image::open('./image.png'); $image = \think\Image::open(request()->file('image'));
阅读全文
摘要:thinkphp版本 5.0.24 安装验证码库 composer require topthink/think-captcha=1.0.8 captcha_img()方法修改 vendor\topthink\think-captcha\src\helper.php function captcha
阅读全文
摘要:单文件上传 控制器 application/index/index.php <?php namespace app\index\controller; use think\Controller; class Index extends Controller { public function ind
阅读全文
摘要:用法 控制器 <?php namespace app\index\controller; use think\Controller; class Index extends Controller { public function index() { $users = model('user')->
阅读全文
摘要:多语言配置 config.php 默认语言 'default_lang' => 'zh-cn', 开启语言切换 'lang_switch_on' => true, 英文包 application/lang/en-us.php <?php return [ 'title' => 'Title', 'l
阅读全文
摘要:cookie配置 config.php 'cookie' => [ // cookie 名称前缀 'prefix' => '', // cookie 保存时间 'expire' => 0, // cookie 保存路径 'path' => '/', // cookie 有效域名 'domain' =
阅读全文
摘要:session配置 config.php file配置 'session' => [ 'id' => '', // SESSION_ID的提交变量,解决flash上传跨域 'var_session_id' => '', // SESSION 前缀 'prefix' => 'think', // 驱动
阅读全文
摘要:缓存独立配置文件 extra/cache.php <?php return [ // 驱动方式,type为complex时为混合类型 'type' => 'complex', // 默认使用的缓存 'default' => [ // 驱动方式 'type' => 'file', 'prefix' =
阅读全文
摘要:独立验证 <?php namespace app\index\controller; use think\Controller; use think\Validate; class Index extends Controller { public function index() { $valid
阅读全文
摘要:开启调试模式 .env app_debug = true 开启Trace调试 'app_trace' => true, 异常捕捉 try{ $user = Db::table('user')->where('id',6)->find(); var_dump($user); }catch(\Excep
阅读全文
摘要:日志配置文件 config.php 'log' => [ // 日志记录方式,内置 file socket 支持扩展 'type' => 'File', // 日志保存目录 'path' => LOG_PATH, // 日志记录级别 'level' => [], //自动清理 'max_files'
阅读全文
摘要:基本用法 index控制器 controller/Index.php <?php namespace app\index\controller; use think\Controller; class Index extends Controller { public function index(
阅读全文
摘要:基本用法 命令行生成User模型 php think make:model index/User 模型调用 $user = new \app\index\model\User(); $user = $user->where('id',3)->find(); var_dump($user->toArr
阅读全文
摘要:命令行生成控制器 php think make:controller index/User 渲染模板 use think\View; $view = new View(); $view->assign('name','huyongjian'); return $view->fetch('index'
阅读全文
摘要:基本使用 mysql生成数据库 create database tp5; use tp5; mysql生成数据表 create table user( id int unsigned NOT NULL AUTO_INCREMENT, name varchar(100), status tinyint
阅读全文
摘要:实例化请求对象 $request = Request::instance(); $request = request(); 获取请求信息 $request = Request::instance(); // 获取当前域名 echo 'domain: ' . $request->domain() .
阅读全文
摘要:路由开关模式 普通模式 'url_route_on' => false, 混合模式 'url_route_on' => true, 'url_route_must'=> false, 强制模式 'url_route_on' => true, 'url_route_must' => true, 路由定
阅读全文
摘要:配置目录 系统默认的配置文件目录就是应用目录application下面 定义配置文件目录和应用目录同级 define('CONF_PATH', __DIR__.'/../config/'); 读取配置 echo \think\Config::get('default_return_type'); e
阅读全文
摘要:composer方式下载源码 composer create-project topthink/think=5.0.* tp5 --prefer-dist nginx配置(默认不支持path_info模式,要使用?s=/的方式访问地址) server { listen 80; server_name
阅读全文
1