PHP 错误信息解读

错误信息

1. 找不到非对象的属性

Trying to get property 'xxx' of non-object
解决方法:

判断一下此属性不存在的情况,或者添加此属性

2. WeChatController.php 包含验证码跳转

Authorize Failed:{
    "errcode":40163,"errmsg":"code been used, hints:[req_id:aenbB5yFe-mGalNa]"
}

– 解决方法
修改WeChatController.php文件添加:

// 如果 URL 包含 code,再跳转一次
if ($request->has('code')) {
    return redirect(route('wechat'));
}

3. 执行命令,名字错误,""里是错误的单词:

The "xxx" option does not exist.

4. 多后台文件链接问题,解决办法config\filesystems.php里的disks添加以下代码:

'admin' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

5. 复制的文件public\storage不可用,需要删除此文件再执行以下命令:

php artisan storage:link

6. 没有打包前端错误:

The Mix manifest does not exist.

7. 目录未设置777权限:

The stream or file "/www/wwwroot/xxxxx/xxxxx/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied

8. 缺少vendor目录:

Warning: require(D:\www\xxxxx\public/../vendor/autoload.php): failed to open stream: No such file or directory in D:\www\xxxxx\public\index.php on line 24

Fatal error: require(): Failed opening required 'D:\www\xxxxx\public/../vendor/autoload.php' (include_path='.;D:/laragon/etc/php/pear') in D:\www\xxxxx\public\index.php on line 24

解决方法:执行命令composer install

9. 日志错误:

Unable to create configured logger. Using emergency logger.

解决方法
添加配置文件logging.php

<?php
use Monolog\Handler\StreamHandler;
return [
    /*
    |--------------------------------------------------------------------------
    | Default Log Channel
    |--------------------------------------------------------------------------
    |
    | This option defines the default log channel that gets used when writing
    | messages to the logs. The name specified in this option should match
    | one of the channels defined in the "channels" configuration array.
    |
    */
    'default' => env('LOG_CHANNEL', 'daily'),
    /*
    |--------------------------------------------------------------------------
    | Log Channels
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log channels for your application. Out of
    | the box, Laravel uses the Monolog PHP logging library. This gives
    | you a variety of powerful log handlers / formatters to utilize.
    |
    | Available Drivers: "single", "daily", "slack", "syslog",
    |                    "errorlog", "monolog",
    |                    "custom", "stack"
    |
    */
    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['single'],
        ],
        'single' => [
            'driver' => 'single',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
        ],
        'daily' => [
            'driver' => 'daily',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
            'days' => 30,
        ],
        'slack' => [
            'driver' => 'slack',
            'url' => env('LOG_SLACK_WEBHOOK_URL'),
            'username' => 'Laravel Log',
            'emoji' => ':boom:',
            'level' => 'critical',
        ],
        'stderr' => [
            'driver' => 'monolog',
            'handler' => StreamHandler::class,
            'with' => [
                'stream' => 'php://stderr',
            ],
        ],
        'syslog' => [
            'driver' => 'syslog',
            'level' => 'debug',
        ],
        'errorlog' => [
            'driver' => 'errorlog',
            'level' => 'debug',
        ],
    ],
];

参考链接:https://github.com/laravel/laravel/blob/5.6/config/logging.php

10. php 版本问题:

Declaration of Symfony\Component\Translation\TranslatorInterface::setLocale($locale) must be compatible with 
Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale)

或者

Return value of Symfony\Component\DomCrawler\Crawler::createSubCrawler() must be an instance of 
Symfony\Component\DomCrawler\object, instance of Symfony\Component\DomCrawler\Crawler returned
{"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0)

解决方法
修改php版本(修改伪静态)
查看php 版本命令:

php -v

11. 缺少工厂目录(Laravel):

[RuntimeException]
 Could not scan for classes inside "database/factories" which does not appear to be a file nor a folder

解决方法
database里创建factories目录(注:为避免出现提交文件忽略目录,建议创建一个文件在里面)

12. 发送邮件报530错误(Laravel):

Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required
//或者
Expected response code 250 but got an empty response

解决方法
– 检查配置是否正确
– 清除缓存
– 清除队列缓存,或者队列重启

 3,682 total views,  6 views today

Revisions

No comments yet.

发表评论