laravel 学习bug笔记

laravel 学习踩坑小记

1.前端渲染bug

今天在学习laravel+vue时编译时

npm run watch

查看Chrome浏览器老是提示组件未注册
查看代码没问题
后来换一个浏览器发现不报错了
可能是浏览器缓存了旧的js数据
清楚浏览器数据果然不报错了
很多时候我们首先会想到是代码的问题 没想到bug会出在浏览器身上

2.用户关联bug

Class 'App\Models\Userfollowers' not found (View: D:\Doc\web\PHP\laravel\laravel\resources\views\user.blade.php)

检查代码发现在定义关联关系时错了一个标点符号

//User.php
public function following(){
	$this->belongsToMany(User::class.'followers','user_id','follower_id');
}

因为对框架的不熟悉导致花费大量时间去测试代码而没能从bug信息中去寻找错误点。。
一个个小小的错误真是要人命

3 .数据库迁移错误

php artisan migrate

报错信息:1071 specified key was too long
解决方法:

//文件AppServiceProvider
use Illuminate\Support\Facades\Schema;

 public function boot()
    {
        //
        Schema::defaultStringLength(191);
    }

4.curl 60 使用GitHub oauth认证时报错

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

解决方案:

1.下载cacert

下载地址https://curl.haxx.se/ca/cacert.pem

2.配置php.ini 并重启

在php.ini中找到curl.cainfo改为文件的绝对路径如:curl.cainfo =E:\phpstudy\PHPTutorial\php\php-7.2.1-nts\cacert.pem

注意事项:

需要开启 php_curl、php_openssl 扩展;

5Laravel-Admin 创建Controller出错

1.出错原因

系统不一样执行命令不一样

2.解决方法
linux\mac: php artisan admin:make UsersController --model=App\\Mdoels\User 

windows:php artisan admin:make UsersController --model=App\Models\User

5.启动队列报错

1.出错原因

用的windows系统 未安装redis扩展

2.解决方案 安装redis扩展
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值