工具:Xampp、thinkphp5.07、phpstorm、Xdebug(这个配置好了一直不能使用,求高手解答)、postMan、navicat
准备
一、配置tp框架 框架放入htdocs,改名为zerg,核心框架移动到zerg内
二、配置虚拟域名 apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/zerg/public"
ServerName www.tp5.com
</VirtualHost>
配置虚拟域名后还需要 配置host
127.0.0.1 localhost
127.0.0.1 www.tp5.com
三、URL三中访问模式
PATH_INFO http://www.tp5.com/index/index/index
混合模式 多个请求既可以是PATH_INFO又可以是路由模式
强制使用路由模式 http://www.tp5.com/index
强制使用路由需要配置路由之后才能使用
路由还可以定义请求方式,或者使用请求方式定义路由

四、获取参数
方式一、 直接在参数获取
public function index($a,$b)
{
$a = 10;
$b = 15 ;
echo $a;
echo $b;
}
方式二、 Request获取参数
$all = Request::instance() -> post();
$all = Request::instance() -> route();
$all = Request::instance() -> get();
$all = Request::instance() -> param();
$id = Request::instance() -> param('id');
$name = Request::instance() -> param('name');
$age = Request::instance() -> param('age');
var_dump($all);
方式三、 助手函数
$all = input('param.');
$all = input('get.name.');
$all = input('post.name.');
附、 依赖注入
public function test(Request $request){
$all = $request -> param();
var_dump($all);
}
五、配置phpstorm + Xdebug 进行断点调试
这一步失败了
使用phpinfo()去下载Xdebug,然后将下载的文件放到C:\xampp\php\ext,在配置php.ini
[Xdebug]
zend_extension ="C:\xampp\php\ext\php_xdebug-2.9.2-7.3-vc15.dll"
xdebug.remote_autostart=1
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
xdebug.remote_port=9000
xdebug.remote_host="localhost"
xdebug.idekey="PHPSTORM"
再去配置phpstorm的


总结: 个人感觉不好用是因为版本太高。
六、phpstorm配置 自动填充命名空间
配置

效果

本文详细介绍如何使用Xampp、phpstorm、Xdebug等工具搭建ThinkPHP5.07框架环境,包括配置虚拟域名、URL访问模式、参数获取方法及phpstorm与Xdebug的调试配置。
788

被折叠的 条评论
为什么被折叠?



