4
respostas

::namespace:: alterado, porem projeto com erro!

Olá, alterei o namespace utilizando o comando da aula, meu bash retornou o seguinte:

$ php artisan app:name estoque
Application namespace set!
The compiled services & packages files have been removed.

Fui em localhost:8080/estoque/public e apareceu o seguinte erro:

Fatal error: Uncaught ReflectionException: Class estoque\Http\Kernel does not exist in
C:\xampp\htdocs\estoque\vendor\laravel\framework\src\Illuminate\Container\Container.php:752
Stack trace: 
#0C:\xampp\htdocs\estoque\vendor\laravel\framework\src\Illuminate\Container\Container.php(752): ReflectionClass->__construct('estoque\\Http\\Ke...') 
#1C:\xampp\htdocs\estoque\vendor\laravel\framework\src\Illuminate\Container\Container.php(631): Illuminate\Container\Container->build('estoque\\Http\\Ke...')
#2C:\xampp\htdocs\estoque\vendor\laravel\framework\src\Illuminate\Container\Container.php(586): Illuminate\Container\Container->resolve('estoque\\Http\\Ke...', Array)
#3C:\xampp\htdocs\estoque\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(721): Illuminate\Container\Container->make('estoque\\Http\\Ke...', Array)
#4C:\xampp\htdocs\estoque\vendor\laravel\framework\src\Illuminate\Container\Container.php(256): Illuminate\Foundation\Application->make('estoque\\Http\\Ke...', Array)
#5C:\xampp\htdocs\estoque\vendo in C:\xampp\htdocs\estoque\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 752

O que devo fazer? Criar um novo projeto?

4 respostas

Fala, Davi.

Confere no arquivo Kernel.php se o namespace tá certinho.

O autoload não tá achando ele, então talvez o problema esteja aí.

Kernel.php

<?php

namespace estoque\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \estoque\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
        \estoque\Http\Middleware\TrustProxies::class,
    ];

    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
            \estoque\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \estoque\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

    /**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \estoque\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
    ];
}

Parece estar certinho.. o que fazer?

Em que pasta ele tá?

Vê se tá na pasta mapeada certinho no autoload do composer.json, que fica na raiz.

Eu não manjo muito de Laravel, mas, parece que o caminho pra esse arquivo não está batendo com o namespace no autoload.

Já vi coisa parecida acontecer. Resolvi usando o comando abaixo dentro do diretório do projeto

composer dump-autoload

Ele refaz o mapeamento dos namespaces que estão cacheados