当前位置:网站首页>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
边栏推荐
- SVN的使用:
- Microsoft Access database using PHP PDO ODBC sample
- Solve the problem of "suncertpathbuilderexception: unable to find valid certification path to requested target"
- 学习 Go 语言 0x02:对切片 Slice 的理解
- CUMCM 2021-B:乙醇偶合制备C4烯烃(2)
- More reliable model art than deep learning
- 《Neo4j权威指南》简介,求伯君、周鸿袆、胡晓峰、周涛等大咖隆重推荐
- 防止web项目中的SQL注入
- VIM + ctags + cscope development environment construction guide
- MySQL面试题讲解之如何设置Hash索引
猜你喜欢
Cumcm 2021 - B: préparation d'oléfines C4 par couplage éthanol (2)
Cygwin 中的 rename 用法
Google Earth engine (GEE) - scale up the original image (taking Hainan as an example)
Constraintlayout layout
PDMS soft lithography process
Redis optimization series (II) redis master-slave principle and master-slave common configuration
2022爱分析· 工业互联网厂商全景报告
Visual solutions to common problems (VIII) mathematical formulas
Visualized common drawing (II) line chart
Canvas详解
随机推荐
Implementation of inserting millions of data into MySQL database in 10 seconds
Using Baidu PaddlePaddle EasyDL to accomplish specified target recognition
Visualization Road (10) detailed explanation of segmentation canvas function
赛微微电科创板上市破发:跌幅达26% 公司市值44亿
MySQL partition table can be classified by month
Facing the global market, platefarm today logs in to four major global platforms such as Huobi
When the activity is in progress! Click the link to join the live studio to participate in "can AI really save energy?" Let's have a discussion!
More reliable model art than deep learning
How to quickly query 10 million pieces of data in MySQL
Applet payment
第六站神京门户-------手机号码的转换
Mba-day5 Mathematics - application problems - engineering problems
FileProvider 路径配置策略的理解
Go interface usage
VM set up static virtual machine
Mba-day5 Mathematics - application problems - engineering problems
学习 Go 语言 0x02:对切片 Slice 的理解
MySQL数据库10秒内插入百万条数据的实现
About the three commonly used auxiliary classes of JUC
Learn go language 0x06: Fibonacci closure exercise code in go language journey