Not found class in Controller

Asked

Viewed 1,506 times

0

The model only gives NOT FOUND in a controller that manages News.

ERROR: Fatal error: Class 'App Models Site Noticiamodel' not found in C: xampp htdocs Managercontent App Controllers Site Homecontroller.php on line 13

Follow link in Pastebin to understand the problem: http://pastebin.com/HkPjXL0j

Model:

<?php

namespace App\Models\Site;

class NoticiaModel extends \ActiveRecord\Model {

    static $Table = 'noticia';
}

Controller:

<?php

namespace App\Controllers\Site;

use \App\Controllers\BaseController as Base;
use \App\Models\Site\NoticiaModel as Noticias;

class HomeController extends Base {

    public function index() {

        // List Noticias
        $Noticias = Noticias::all();
        dump($Noticias);

        $Dados = ['titulo' => 'Home'];
        $Template = $this->Twig->loadTemplate('Home.html');

        $Template->display($Dados);
    }
}
  • 2

    This framework was created by you?

  • 1

    It was. It’s a standard base structure I created, where I only create the controllers I need.

  • This looks like Laravel combined with http://twig.sensiolabs.org, that’s it?

  • Exactly, Guilherme. Within the project, via Commodore I call Twig and the helpers of Laravel. :)

  • But I don’t understand why the News Model from not found in the Home controller, to list news. I’ve reviewed the paths and everything is okay. :(

  • 2

    So your statement to @rray is wrong jonniehenrique, he asked if the framework was you who created it, but this is wrong, in fact you created the application that uses an existing framework called Laravel. Please next time post the information clearly as this complicates the understanding ;)

  • I posted clearly, William. I spoke q created a base structure using Laravel helpers. The total structure is independent of any framework. :)

Show 2 more comments

1 answer

3

Solved the problem!

composer update

The problem simply in the autoload of the Models directories that was pointing to another part of the project, making it not recognized any model created within the project! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.