Laravel、Lumen 錯誤集錦

持續更新。。。php

這裏收集了碰見的 laravel 或則 lumen 錯誤 和解決方法。

controller或者model不存在

1. not found

Class '\App\UserController' not found

執行 composer dump-autoload 解決.laravel

2. User模型默認在App下,遷移到Models下以後命名空間出了問題。

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

User中修改命名空間:redis

use App\Models\User;

或者,您可使用完整的名稱空間:mongodb

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

另外,請確保User.phpapp\Models目錄中並確保您已更改config\auth.php文件中的模型:json

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

App\Http\Controllers\Auth\RegisterController中須要更改User的命名空間。app

Unsupported driver [mongodb]。

lumen中使用mongodb報錯:composer

Unsupported driver [mongodb]。

解決:異步

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

laravel Redis 隊列錯誤

發現異步有些不會處理,https://laracasts.com/discuss... 同問這個問題,目前沒有解決。ide

redis-climonitor 監控oop

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
相關文章
相關標籤/搜索