thinkPHP
嘿python
这个作者很懒,什么都没留下…
展开
-
关于Thinkphp将类放入vendor无法引入成功
因为不是从composer下载的,有些配置没有自动完成,也可以自己手动配置,但是太麻烦,有个好的解决办法首先在vendor下,新建一个文件夹,将类放进去,类里面不要写【namespace】然后再控制器中引入的时候写vendor('vendor下的文件夹名.php文件的名字'),写到php文件名就行,不要写到类名,注意加引号举例:我的是youxiang文件夹下的Youxiang.phpvendor(...原创 2018-02-08 09:43:51 · 11098 阅读 · 0 评论 -
tp5设置https后不显示主页而是自动下载index.php
http正常访问,把index.php改成index.html也正常访问,经过两天折腾才发现原来是我的nginx.conf设置出错,443端口写错,解决办法:443的内容是在80端口的基础上添加ssl相关内容而不是只写ssl相关内容,有不会的可以私聊我我的网站https://codergb.com/ server { listen 443 default_server; ...原创 2018-03-11 16:41:02 · 3349 阅读 · 0 评论 -
TP5 Validate 验证类
<?phpnamespace app\api\controller;use think\Db;use think\Session;vendor('curl.Curl');use think\Controller;use app\index\model\Visit;use think\Request;use think\Exception;use think\Validate;//引入验证类u...原创 2018-03-24 10:12:49 · 1375 阅读 · 0 评论 -
thinkphp5实现创建api
这里用的是tp5.0一、首先在application中创建api文件夹,下面再创建controller文件夹在controller中写控制器举例:class Api extends Controller{ // 查询网址ip,这里的形参就是从网址中传进来的值 public function searchIp($url,$two=null) { }}二、配置c...原创 2018-03-24 10:12:31 · 3057 阅读 · 0 评论 -
tp5的Request::instance()获取post、get、参数、表单上传的文件
use think\Request;class Name{ $request = Request::instance(); $method = $request->method();//获取上传方式 $request->param();//获取所有参数,最全 $get = $request->get();获取get上传的内容 $post = $req...原创 2018-03-24 16:57:51 · 38650 阅读 · 0 评论 -
PSR4规范
定义类名规则: 完全限定类名必须有一个顶级命名空间(Vendor Name);完全限定类名可以有多个子命名空间;完全限定类名应该有一个终止类名;下划线在完全限定类名中是没有特殊含义的;字母在完全限定类名中可以是任何大小写的组合;所有类名必须以大小写敏感的方式引用;使用规则: 在完全限定类名中,连续的一个或几个子命名空间构成的命名空间前缀(不包括顶级命名空间的分隔符),至少对应着至少一个...原创 2018-03-30 20:49:48 · 1533 阅读 · 0 评论