Question

This is my first deployment of FuelPHP, though I am a long time user of CodeIgniter.

I am getting the following error when I load the page:

ErrorException [ Fatal Error ]:
Class 'Model\Model_UPS' not found

/classes/controller/ups.php

<?php
use \Model\Model_UPS;
class Controller_UPS extends Controller {
    public function action_index() {
        $view = View::forge('json');
        $view->title = Model_UPS::get_load();
        return $view;
    }
}
?>

/classes/model/model_ups.php or ups.php

<?php
namespace Model;
class Model_UPS extends \Model {
    public static function get_load() {
        return "This is the load!";
    }
}
?>

/views/json.php

<?=$title;?>

The error page highlights the $view->title = Model_UPS::get_load(); line of ups.php. I have tried just about every configuration of use, namespace, model filename, and model class name that I can think of. I can't seem to find a super simple MVC example to use as a guide. I've tried to duplicate the FuelPHP Docs as best as I can, but have failed. Can anyone find anything wrong with this?

Was it helpful?

Solution

  • Rename file: model/model_ups.php to model/ups.php
  • Rename class: Model_UPS to UPS
  • Change: use \Model\Model_UPS; to use \Model\UPS;
  • Change: Model_UPS::get_load(); to UPS::get_load();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top