Windows-试用phpthink发现原来可这样快速搭建mysql、redis等环境、xdebug

一、前言

最近在简单学习 php 国人框架 phpthink,不得不说牛,我在 github 上既然搜不到此项目... 但是发现搭建依赖环境不会,于是百度一下,几乎都是各种集成工具什么宝塔、小皮面板等等。有固然是方便,但为什么其它语言就没听说过有类似的集成工具?不知其然,我认为只要想方便你都可以使用它!
在这里插入图片描述


二、phpstudy 快速搭建mysql、redis等环境

一键安装、一键启动,整活挺方便...
1、安装PHP >= 7.2.5
使用 phpstudy 安装:phpstudy

  1. mysql

  2. redis

redis Windows依赖安装:

$ php -v
PHP 7.3.4 (cli) (built: Apr  2 2019 21:57:22) ( NTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies

上述看到 PHP 7.3.4 与 VC15,则选择版本时候需对应
①redis
②igbinary

php.ini 新增

;php_redis
extension=php_igbinary.dll
extension=php_redis.dll
;End

测试连接

<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$auth = $redis->auth('123456');
var_dump($auth);
echo "Connection to server successfully";
//查看服务是否运行
echo "Server is running: " . $redis->ping();

2、安装 composer 作为 php 的依赖包管理

# linux系统下
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
  1. 在 Windows 中,你需要下载并运行 Composer-Setup.exe

  2. 配置阿里云镜像

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
  1. composer next 时选择php安装目录,如:D:\phpstudy_pro\Extensions\php

三、创建 phpthink 项目

composer create-project topthink/think projectName

# 指定80端口运行项目
cd projectName
php think run -p 80

访问:127.0.0.1/index.php

4、多应用模式,你需要安装多应用模式扩展

composer require topthink/think-multi-app

5、html模板依赖下载

composer require topthink/think-view

四、xdebug

1、IDEA 设置代理 IP、端口、key

IDE KYE = PHPSTORM
HOST    = localhost
PORT    = 9000

在这里插入图片描述
2、IDEA Servers
既监听的服务ip、port,所使用xdebug模式
在这里插入图片描述
3、设置 php.ini + chrome xdebug 插件

[XDebug]
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
zend_extension="D:\phpstudy_pro\Extensions\php\php7.3.4nts\ext\php_xdebug.dll"

在这里插入图片描述
xdebug插件:点击 debug 绿色表示在等待debug(下载插件需要FQ,插件商店直接搜索:xdebug)
在这里插入图片描述
4、IEDA 尝试与插件Xdebug进行调试
1、启动服务
在这里插入图片描述
2、代码加个debug断点
在这里插入图片描述
3、开启监听,如下图则监听中...
在这里插入图片描述
且网页绿色甲虫打开
在这里插入图片描述
4、访问服务至我们断点的那段代码...
弹出,接受许可
在这里插入图片描述
debug 成功
在这里插入图片描述
在这里插入图片描述


总结:
还是不错的,本次主要学习了 xdebug...还想着我该如何去debug又不想Java sprintboot等等。phpthink虽然在github没有什么名气,但在早十年前的国产框架也是非常不错了总之牛掰,太混乱了可能是我使用不习惯,以前一些个人开发者、工作室应该还是比较多人使用的。
End

posted @ 2023-01-14 21:13  广深-小龙  阅读(130)  评论(0编辑  收藏  举报