I wanted to use code like this in my Zend Framework project:
public function indexAction() {
$user = new User();
$user->name = "Guest";
$user->save();
}
The main thing that is important for me is that the class is called just User and not App_Model_User but how could I manage that?
I thought I could add the path to the file User.php in the model-folder to the include_path:
<?php
class User {
/* Some code */
}
But how could I config the autoloader to load that file/class?
Currently I’m using the autoloader with the appnamespace (“App”) to load classes called App_Model_User which works but the class naming is not the right I think. It should be cleaner and clearer.
I use
set_include_pathas follows:Then the autoloader picks up any models (with any name) which I put in /application/models. The above is in my only public facing script (index.php). This is how I set up the autoloader:
The second line will ensure that your models do not have to be explicitly included. See:
http://framework.zend.com/manual/en/zend.loader.autoloader.html