Php 迁移laravel 5和get类不存在
我在app/Http/Middleware/corsmidleware.php上创建了一个中间件。这是相当简单的,它已经在我的脱机宅地盒工作。问题发生在我的远程计算机上:Php 迁移laravel 5和get类不存在,php,laravel-5,Php,Laravel 5,我在app/Http/Middleware/corsmidleware.php上创建了一个中间件。这是相当简单的,它已经在我的脱机宅地盒工作。问题发生在我的远程计算机上: ReflectionException in Container.php line 738: Class App\Http\MiddleWare\CorsMiddleware does not exist 我的文件结构: Middleware: total 20 -rwxr-xr-x 1 CasatoroWeb Casato
ReflectionException in Container.php line 738:
Class App\Http\MiddleWare\CorsMiddleware does not exist
我的文件结构:
Middleware:
total 20
-rwxr-xr-x 1 CasatoroWeb CasatoroWeb 676 Mar 16 12:53 Authenticate.php
-rwxr-xr-x 1 CasatoroWeb CasatoroWeb 1570 Mar 16 12:53 CorsMiddleware.php
-rwxr-xr-x 1 CasatoroWeb CasatoroWeb 300 Mar 16 12:53 EncryptCookies.php
-rwxr-xr-x 1 CasatoroWeb CasatoroWeb 519 Mar 16 12:53 RedirectIfAuthenticated.php
-rwxr-xr-x 1 CasatoroWeb CasatoroWeb 311 Mar 16 12:53 VerifyCsrfToken.php
我的班级:
<?php namespace App\Http\Middleware;
use Closure;
class CorsMiddleware {
/**
* Run the request filter.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
/*
* Get the response like normal.
* When laravel cannot find the exact route it will try to find the same route for different methods
* If the method is OPTION and there are other methods for the uri,
* it will then return a 200 response with an Allow header
*
* Else it will throw an exception in which case the user is trying to do something it should not do.
*/
$response = $next($request);
// We only want the headers set for the api requests
if ($request->segment(1) == 'api') {
// Set the default headers for cors If you only want this for OPTION method put this in the if below
$response->headers->set('Access-Control-Allow-Origin','*');
$response->headers->set('Access-Control-Allow-Headers','Content-Type, X-Auth-Token, Origin, Authorization');
// Set the allowed methods for the specific uri if the request method is OPTION
if ($request->isMethod('options')) {
$response->headers->set(
'Access-Control-Allow-Methods',
$response->headers->get('Allow')
);
}
}
return $response;
}
}
我试着用这里发布的解决方案来解决这个问题-:
还有跑步
php artisan cache:clear
我不知道还能去哪里找。谁能给我指出正确的方向吗 Homestead让我摆脱了中间件声明中的一个坏案例:
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\MiddleWare\CorsMiddleware::class,
];
我不得不将案例从中间件更改为中间ware Homestead让我摆脱了中间件声明中的一个坏案例:
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\MiddleWare\CorsMiddleware::class,
];
我不得不将案例从中间件更改为中间ware
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\MiddleWare\CorsMiddleware::class,
];