班级不存在 - Laravel

时间:2016-10-05 10:15:35

标签: php laravel

我关注this tutorial。我目前正在使用laravel 5.3,所以它有点过时了。我按照教程的说法一步一步地完成了,但是,我得到了

spool_dir.sources = src-1
spool_dir.channels = channel-1
spool_dir.sinks = sink_to_hdfs
# source
spool_dir.sources.src-1.type = spooldir
spool_dir.sources.src-1.channels = channel-1
spool_dir.sources.src-1.spoolDir = /home/data/
spool_dir.sources.src-1.fileHeader = false
# HDFS sinks
spool_dir.sinks.sink_to_hdfs.type = hdfs
spool_dir.sinks.sink_to_hdfs.hdfs.fileType = DataStream
spool_dir.sinks.sink_to_hdfs.hdfs.path = hdfs://192.168.1.71/home/user/flumepush
spool_dir.sinks.sink_to_hdfs.hdfs.filePrefix = customevent
spool_dir.sinks.sink_to_hdfs.hdfs.fileSuffix = .log
spool_dir.sinks.sink_to_hdfs.hdfs.batchSize = 1000
spool_dir.channels.channel-1.type = file
spool_dir.channels.channel-1.checkpointDir = /home/user/spool_dir_checkpoint
spool_dir.channels.channel-1.dataDirs = /home/user/spool_dir_data
spool_dir.sources.src-1.channels = channel-1
spool_dir.sinks.sink_to_hdfs.channel = channel-1

一切都像教程中一样。我不知道问题出在哪里。

1 个答案:

答案 0 :(得分:8)

问题是您创建了FirstMiddleware,但在此处仅将其称为First

<?php
Route::get('/usercontroller/path',[
   'middleware' => 'First',
   'uses' => 'UserController@showPath'
]);

正如官方文件中所述,

  

如果您想将中间件分配给特定路线,您应该这样做   首先为中间件分配app/Http/Kernel.php

中的密钥

因此,请将此添加到您的app/Http/Kernel.php文件中:

protected $routeMiddleware = [
    // the other route middlewares are defined here
    'First' => \App\Http\Middleware\FirstMiddleware::class, // add this line
]

我认为这应该足够了。