Laravel、Lumen 错误集锦

持续更新。。。

这里收集了遇见的laravel 或则 lumen 错误 和解决方法。

controller或者model不存在

1. not found

Class '\App\UserController' not found

执行 composer dump-autoload 解决.

2. User模型默认在App下,迁移到Models下之后命名空间出了问题。

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Class '\App\User' not found

User中修改命名空间:

use App\Models\User;

或者,您可以使用完整的名称空间:

$user = App\Models\User::find(1);

另外,请确保User.phpapp\Models目录中并确保您已更改config\auth.php文件中的模型:

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => App\Model\User::class,
    ],
],

App\Http\Controllers\Auth\RegisterController中需要更改User的命名空间。

Unsupported driver [mongodb]。

lumen中使用mongodb报错:

Unsupported driver [mongodb]。

解决:

$app->register(Jenssegers\Mongodb\MongodbServiceProvider::class);
 
$app->withFacades();   //这句移到$app->register下方,可解决

laravel Redis 队列错误

发现异步有些不会处理,https://laracasts.com/discuss... 同问这个问题,目前没有解决。

redis-climonitor 监控

1527832745.339231 [0 lua] "zrangebyscore" "queues:wechat_xcx:delayed" "-inf" "1527832745"
1527832745.339382 [0 127.0.0.1:59268] "EVAL" "-- Get all of the jobs with an expired \"score\"...\nlocal val = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[1])\n\n-- If we have values in the array, we will remove them from the first queue\n-- and add them onto the destination queue in chunks of 100, which moves\n-- all of the appropriate jobs onto the destination queue very safely.\nif(next(val) ~= nil) then\n    redis.call('zremrangebyrank', KEYS[1], 0, #val - 1)\n\n    for i = 1, #val, 100 do\n        redis.call('rpush', KEYS[2], unpack(val, i, math.min(i+99, #val)))\n    end\nend\n\nreturn val" "2" "queues:wechat_xcx:reserved" "queues:wechat_xcx" "1527832745"
1527832745.339440 [0 lua] "zrangebyscore" "queues:wechat_xcx:reserved" "-inf" "1527832745"
1527832745.339452 [1 127.0.0.1:53568] "EVAL" "-- Get all of the jobs with an expired \"score\"...\nlocal val = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[1])\n\n-- If we have values in the array, we will remove them from the first queue\n-- and add them onto the destination queue in chunks of 100, which moves\n-- all of the appropriate jobs onto the destination queue very safely.\nif(next(val) ~= nil) then\n    redis.call('zremrangebyrank', KEYS[1], 0, #val - 1)\n\n    for i = 1, #val, 100 do\n        redis.call('rpush', KEYS[2], unpack(val, i, math.min(i+99, #val)))\n    end\nend\n\nreturn val" "2" "queues:default:reserved" "queues:default" "1527832745"
1527832745.339503 [1 lua] "zrangebyscore" "queues:default:reserved" "-inf" "1527832745"
1527832745.339648 [0 127.0.0.1:59268] "EVAL" "-- Pop the first job off of the queue...\nlocal job = redis.call('lpop', KEYS[1])\nlocal reserved = false\n\nif(job ~= false) then\n    -- Increment the attempt count and place job on the reserved queue...\n    reserved = cjson.decode(job)\n    reserved['attempts'] = reserved['attempts'] + 1\n    reserved = cjson.encode(reserved)\n    redis.call('zadd', KEYS[2], ARGV[1], reserved)\nend\n\nreturn {job, reserved}" "2" "queues:wechat_xcx" "queues:wechat_xcx:reserved" "1527832745"
1527832745.339694 [0 lua] "lpop" "queues:wechat_xcx"
1527832745.339722 [1 127.0.0.1:53568] "EVAL" "-- Pop the first job off of the queue...\nlocal job = redis.call('lpop', KEYS[1])\nlocal reserved = false\n\nif(job ~= false) then\n    -- Increment the attempt count and place job on the reserved queue...\n    reserved = cjson.decode(job)\n    reserved['attempts'] = reserved['attempts'] + 1\n    reserved = cjson.encode(reserved)\n    redis.call('zadd', KEYS[2], ARGV[1], reserved)\nend\n\nreturn {job, reserved}" "2" "queues:default" "queues:default:reserved" "1527832805"
1527832745.339763 [1 lua] "lpop" "queues:default"
1527832745.807436 [1 127.0.0.1:53566] "GET" "laravel:illuminate:queue:restart"
1527832745.807651 [1 127.0.0.1:53566] "EVAL" "-- Get all of the jobs with an expired \"score\"...\nlocal val = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[1])\n\n-- If we have values in the array, we will remove them from the first queue\n-- and add them onto the destination queue in chunks of 100, which moves\n-- all of the appropriate jobs onto the destination queue very safely.\nif(next(val) ~= nil) then\n    redis.call('zremrangebyrank', KEYS[1], 0, #val - 1)\n\n    for i = 1, #val, 100 do\n        redis.call('rpush', KEYS[2], unpack(val, i, math.min(i+99, #val)))\n    end\nend\n\nreturn val" "2" "queues:default:delayed" "queues:default" "1527832745"
1527832745.807738 [1 lua] "zrangebyscore" "queues:default:delayed" "-inf" "1527832745"
1527832745.807863 [1 127.0.0.1:53566] "EVAL" "-- Get all of the jobs with an expired \"score\"...\nlocal val = redis.call('zrangebyscore', KEYS[1], '-inf', ARGV[1])\n\n-- If we have values in the array, we will remove them from the first queue\n-- and add them onto the destination queue in chunks of 100, which moves\n-- all of the appropriate jobs onto the destination queue very safely.\nif(next(val) ~= nil) then\n    redis.call('zremrangebyrank', KEYS[1], 0, #val - 1)\n\n    for i = 1, #val, 100 do\n        redis.call('rpush', KEYS[2], unpack(val, i, math.min(i+99, #val)))\n    end\nend\n\nreturn val" "2" "queues:default:reserved" "queues:default" "1527832745"
1527832745.807930 [1 lua] "zrangebyscore" "queues:default:reserved" "-inf" "1527832745"
1527832745.808092 [1 127.0.0.1:53566] "EVAL" "-- Pop the first job off of the queue...\nlocal job = redis.call('lpop', KEYS[1])\nlocal reserved = false\n\nif(job ~= false) then\n    -- Increment the attempt count and place job on the reserved queue...\n    reserved = cjson.decode(job)\n    reserved['attempts'] = reserved['attempts'] + 1\n    reserved = cjson.encode(reserved)\n    redis.call('zadd', KEYS[2], ARGV[1], reserved)\nend\n\nreturn {job, reserved}" "2" "queues:default" "queues:default:reserved" "1527832805"
1527832745.808146 [1 lua] "lpop" "queues:default"

后来发现这个貌似不是错误,对队列没有影响。
开启supervisor后,自动监听任务,线程数决定刷新频率。(有懂的大神请指教)。

Whoops, looks like something went wrong.

APP_key 问题:
可使用重新生成

php artisan key:generate

在 Heroku 环境中也会有遇到,需要设置 heroku 的 key 和 项目一致:

heroku config:set APP_KEY=Your_app_key

相关推荐