资讯专栏INFORMATION COLUMN

Laravel、Lumen 错误集锦

张率功 / 3318人阅读

摘要:解决这句移到下方,可解决队列错误发现异步有些不会处理,同问这个问题,目前没有解决。开启后,自动监听任务,线程数决定刷新频率。问题可使用重新生成在环境中也会有遇到,需要设置的和项目一致

持续更新。。。

这里收集了遇见的laravel 或则 lumen 错误 和解决方法。
controller或者model不存在 1. not found
 Class "AppUserController" not found

执行 composer dump-autoload 解决.

2. User模型默认在App下,迁移到Models下之后命名空间出了问题。
Symfony  Component  Debug  Exception  FatalThrowableError (E_ERROR)
Class "AppUser" not found

User中修改命名空间:

use AppModelsUser;

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

$user = AppModelsUser::find(1);

另外,请确保User.phpappModels目录中并确保您已更改configauth.php文件中的模型:

"providers" => [
    "users" => [
        "driver" => "eloquent",
        "model" => AppModelUser::class,
    ],
],

AppHttpControllersAuthRegisterController中需要更改User的命名空间。

Unsupported driver [mongodb]。

lumen中使用mongodb报错:

 Unsupported driver [mongodb]。

解决:

$app->register(JenssegersMongodbMongodbServiceProvider::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"...
local val = redis.call("zrangebyscore", KEYS[1], "-inf", ARGV[1])

-- If we have values in the array, we will remove them from the first queue
-- and add them onto the destination queue in chunks of 100, which moves
-- all of the appropriate jobs onto the destination queue very safely.
if(next(val) ~= nil) then
    redis.call("zremrangebyrank", KEYS[1], 0, #val - 1)

    for i = 1, #val, 100 do
        redis.call("rpush", KEYS[2], unpack(val, i, math.min(i+99, #val)))
    end
end

return 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"...
local val = redis.call("zrangebyscore", KEYS[1], "-inf", ARGV[1])

-- If we have values in the array, we will remove them from the first queue
-- and add them onto the destination queue in chunks of 100, which moves
-- all of the appropriate jobs onto the destination queue very safely.
if(next(val) ~= nil) then
    redis.call("zremrangebyrank", KEYS[1], 0, #val - 1)

    for i = 1, #val, 100 do
        redis.call("rpush", KEYS[2], unpack(val, i, math.min(i+99, #val)))
    end
end

return 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...
local job = redis.call("lpop", KEYS[1])
local reserved = false

if(job ~= false) then
    -- Increment the attempt count and place job on the reserved queue...
    reserved = cjson.decode(job)
    reserved["attempts"] = reserved["attempts"] + 1
    reserved = cjson.encode(reserved)
    redis.call("zadd", KEYS[2], ARGV[1], reserved)
end

return {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...
local job = redis.call("lpop", KEYS[1])
local reserved = false

if(job ~= false) then
    -- Increment the attempt count and place job on the reserved queue...
    reserved = cjson.decode(job)
    reserved["attempts"] = reserved["attempts"] + 1
    reserved = cjson.encode(reserved)
    redis.call("zadd", KEYS[2], ARGV[1], reserved)
end

return {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"...
local val = redis.call("zrangebyscore", KEYS[1], "-inf", ARGV[1])

-- If we have values in the array, we will remove them from the first queue
-- and add them onto the destination queue in chunks of 100, which moves
-- all of the appropriate jobs onto the destination queue very safely.
if(next(val) ~= nil) then
    redis.call("zremrangebyrank", KEYS[1], 0, #val - 1)

    for i = 1, #val, 100 do
        redis.call("rpush", KEYS[2], unpack(val, i, math.min(i+99, #val)))
    end
end

return 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"...
local val = redis.call("zrangebyscore", KEYS[1], "-inf", ARGV[1])

-- If we have values in the array, we will remove them from the first queue
-- and add them onto the destination queue in chunks of 100, which moves
-- all of the appropriate jobs onto the destination queue very safely.
if(next(val) ~= nil) then
    redis.call("zremrangebyrank", KEYS[1], 0, #val - 1)

    for i = 1, #val, 100 do
        redis.call("rpush", KEYS[2], unpack(val, i, math.min(i+99, #val)))
    end
end

return 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...
local job = redis.call("lpop", KEYS[1])
local reserved = false

if(job ~= false) then
    -- Increment the attempt count and place job on the reserved queue...
    reserved = cjson.decode(job)
    reserved["attempts"] = reserved["attempts"] + 1
    reserved = cjson.encode(reserved)
    redis.call("zadd", KEYS[2], ARGV[1], reserved)
end

return {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

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/28842.html

相关文章

  • Lumen 初体验(二)

    摘要:的现状目前是版本,是基于开发。入口文件启动文件和配置文件框架的入口文件是。在路由中指定控制器类必须写全命名空间,不然会提示找不到类。目前支持四种数据库系统以及。使用时发生错误,因为在文件中,的默认驱动是。 最近使用 Lumen 做了 2 个业余项目,特此记录和分享一下。 Lumen 的介绍 在使用一项新的技术时,了解其应用场景是首要的事情。 Lumen 的口号:为速度而生的 La...

    Cheriselalala 评论0 收藏0
  • Lumen如何实现类Laravel5用户友好的错误页面

    摘要:实现用户友好的错误页面非常简单,例如想要返回,只需要在中添加一个文件即可。如何实现类用户友好的错误页面原理抛出错误的函数是进入该函数一看究竟,会发现只是抛出一个在中,处理的时候,有一个的过程,就是在这里被捕获的。 Laravel5实现用户友好的错误页面非常简单,例如想要返回status 404,只需要在view/errors中添加一个404.blade.php文件即可。Lumen中没有...

    Vicky 评论0 收藏0
  • Lumen---为速度而生的 Laravel 框架

    摘要:什么是官网是一个由组件搭建而成的微框架是当前最快的框架之一在什么时候使用专为微服务或者设计举个例子如果你的应用里面有部分业务逻辑的请求频率比较高就可以单独把这部分业务逻辑拿出来使用来构建一个小因为是对优化了框架的加载机制所以对资源的要求少很 什么是 Lumen?官网 lumen 是一个由 Laravel 组件搭建而成的微框架,是当前最快的 PHP 框架之一! 在什么时候使用 Lume...

    104828720 评论0 收藏0
  • Lumen 初体验

    摘要:介绍为速度而生的框架。是官方给出的例子,直接拷贝命名为。一般来说,我们应该避免使用末尾带斜杠的。因为它如果找不到文件,就会自动在末尾加个斜杠,尝试寻找目录下的文件等等,具体是在中配置。方案修改修改的配置文件,将指向重启。 介绍 Lumen:为速度而生的 Laravel 框架。 Lumen 是 Laravel 的作者(Taylor Otwell)的又一力作。简单、快速、优雅的它的特点...

    Leck1e 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<