2
respostas

ReflectionException (-1) Class App\Http\Controllers\ProdutoController does not exist

Estou com um erro, alias só pra avisar, todos os cursos parecem estar desatualizados, as coisas não batem, caminhos de pastas, comandos etc, muito dificil cursar assim.

Log do browser.

ReflectionException (-1) Class App\Http\Controllers\ProdutoController does not exist

E:\DESENVOLVIMENTO\Laravel\Treinamento_basico_Laravel\vendor\laravel\framework\src\Illuminate\Container\Container.php
    }

    /**
     * Instantiate a concrete instance of the given type.
     *
     * @param  string  $concrete
     * @return mixed
     *
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function build($concrete)
    {
        // If the concrete type is actually a Closure, we will just execute it and
        // hand back the results of the functions, which allows functions to be
        // used as resolvers for more fine-tuned resolution of these objects.
        if ($concrete instanceof Closure) {
            return $concrete($this, $this->getLastParameterOverride());
        }

        $reflector = new ReflectionClass($concrete);

        // If the type is not instantiable, the developer is attempting to resolve
        // an abstract type such as an Interface of Abstract Class and there is
        // no binding registered for the abstractions so we need to bail out.
        if (! $reflector->isInstantiable()) {
            return $this->notInstantiable($concrete);
        }

        $this->buildStack[] = $concrete;

        $constructor = $reflector->getConstructor();

        // If there are no constructors, that means there are no dependencies then
        // we can just resolve the instances of the objects right away, without
        // resolving any other types or dependencies out of these containers.
        if (is_null($constructor)) {
            array_pop($this->buildStack);

            return new $concrete;
        }
Arguments
"Class App\Http\Controllers\ProdutoController does not exist"

se tirar o caminho completo da outro tipo de erro.

<?php namespace Treinamento_basico_Laravel\app\Http\Controllers;

use App\Http\Controllers\Controller;

class ProdutoController extends Controller {
    public function lista(){
        return "<h1>Lista de produtos</h1>";
    }
}

arquivo web.php



Route::get('/produtos', 'ProdutoController@lista');
2 respostas

No meu caso ficou com o seguinte código:

<?php namespace estoque\Http\Controllers;

class ProdutoController extends Controller {

    public function lista(){
        return '<h1>Listagem de produtos com Laravel</h1>';
    }

}

Outra coisa que fiz foi parar o terminal (Ctrl + C) e executei o seguinte comando:

$ composer dump-autoload

em seguida:

$ php artisan serve

Oi, Alexandre, obrigado pelo feedback! Estamos planejando atualizar os cursos de Laravel, em breve teremos novidades!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software