前后分离,快速打开 PhpStorm 项目和启动测试环境的脚本
前后端分离,Laravel + React,使用 PhpStorm 和 WebStorm 开发,每次都要打开 Laravel 和 React,然后再点击 IDE 的 yarn start
按钮、php artisan serve
,又或者手动输入。这样很麻烦。
可以这样使用
- 安装 pstorm
- 写 shell 脚本,自动打开项目和启动测试环境
保存为 lrs,chmod +x lrs
,复制到 /usr/local/bin/lrs
需要依赖 screen
➜ ~ lrs
start Laravel
start soketi-server
start React
#!/bin/bash
# Laravel
LaravelPath="antic-api"
Laravel="Laravel"
# React
ReactPath="antic"
React="React"
PackageManager="yarn" # 或 npm
cd ~/PhpstormProjects/
pstorm ${LaravelPath} ${ReactPath}
# 或者分别使用不同 IDE 打开
# webstorm ${ReactPath}
# pstorm ${LaravelPath}
# Laravel
ps -fe|grep "php ${LaravelPath}/artisan serve"|grep -v grep >/dev/null
if [ $? -ne 0 ]
then
echo "start ${Laravel}"
screen -dmS ${LaravelPath} php ${LaravelPath}/artisan serve
else
echo "${Laravel} running"
fi
# React
ps -fe|grep "${PackageManager} start --prefix ${ReactPath}" | grep -v grep >/dev/null
if [ $? -ne 0 ]
then
echo "start ${React}"
screen -dmS ${ReactPath} ${PackageManager} --cwd ${ReactPath} start
else
echo "${React} running"
fi
这样就可以快速地 Happy Coding 了
第一次写 shell,格式和代码都比较乱,勿喷。可以的话,可以帮忙改进或告诉已有的轮子,谢谢。
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: