当前位置:网站首页>laravel编写Console脚本
laravel编写Console脚本
2022-04-23 11:16:00 【书生及第】
一:
app\Console\Commands目录下创建脚本文件TestConsole.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Base\CommonPoolMethod;
//连接数据库可引入数据库相关类
class TestConsole extends Command
{
use CommonPoolMethod;
/** * The name and signature of the console command. * update:artisan下命令组,可使用【php artisan -v】或【php artisan list】查看 * test_function :解释命令作用(随意) * 完整命令【php artisan update:test_function】 * @var string */
protected $signature = 'update:test_function';
/** * The console command description. * * @var string */
protected $description = "更新测试方法";
/** * Create a new command instance. * * @return void */
public function __construct()
{
parent::__construct();
}
public function handle()
{
//编写脚本方法
}
}
二:laravel根目录下执行artisan命令【php artisan update:test_function】
注:执行命令报错【SQLSTATE[HY000] [2002] No such file or directory 】
原因:未找不到mysql.sock文件
解决:
1:打开MySQL管理工具,执行sql语句 【show variables like ‘%sock%’】,得到一个目录【/Applications/MAMP/tmp/mysql/mysql.sock】
2:找到 ./config/database.php 中的 unix_socket,修改【‘unix_socket’ => ‘/Applications/MAMP/tmp/mysql/mysql.sock’】
或者
.env中对应的DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
版权声明
本文为[书生及第]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_38989173/article/details/124347725
边栏推荐
- Solutions to common problems in visualization (VIII) solutions to problems in shared drawing area
- 年度最尴尬的社死瞬间,是Siri给的
- Excel · VBA array bubble sorting function
- Structure of C language (Advanced)
- FileProvider 路径配置策略的理解
- redis优化系列(二)Redis主从原理、主从常用配置
- mysql中整数数据类型tinyint详解
- Google Earth engine (GEE) - scale up the original image (taking Hainan as an example)
- 卷积层和池化层总结
- Mysql8.0安装指南
猜你喜欢
After the MySQL router is reinstalled, it reconnects to the cluster for boot - a problem that has been configured in this host before
采用百度飞桨EasyDL完成指定目标识别
初探 Lambda Powertools TypeScript
Visualization Road (10) detailed explanation of segmentation canvas function
ConstraintLayout布局
VM set up static virtual machine
《Neo4j权威指南》简介,求伯君、周鸿袆、胡晓峰、周涛等大咖隆重推荐
Visual common drawing (I) stacking diagram
PDMS soft lithography process
An interesting interview question
随机推荐
使用 PHP PDO ODBC 示例的 Microsoft Access 数据库
Data analysis learning (I) data analysis and numpy Foundation
CUMCM 2021-B:乙醇偶合制备C4烯烃(2)
mysql创建存储过程及函数详解
26. 删除有序数组中的重复项
CUMCM 2021-B:乙醇偶合制備C4烯烴(2)
R-Drop:更强大的Dropout正则方法
Oracle连通性测试小工具
How to Ping Baidu development board
MBA-day6 逻辑学-假言推理练习题
Visualization Road (10) detailed explanation of segmentation canvas function
Mysql系列SQL查询语句书写顺序及执行顺序详解
ConstraintLayout布局
MBA-day5数学-应用题-工程问题
VM set up static virtual machine
Promise details
面向全球市场,PlatoFarm今日登录HUOBI等全球四大平台
PlatoFarm推出正式版游戏经济模型的特点分析
Typora operation skill description (I)
Mysql8. 0 installation guide