Welcome Guest, Not a member yet? Register   Sign In
Datamapper - Model Class not found
#1

[eluser]bige8000[/eluser]
I am new to CI and Datamapper and have got things working but when I went to deploy to my production server things stopped working. Everytime I try to use a Datamapper model in the code I get "Fatal error: Class 'User' not found in..." where user is whatever model im trying to use.

Hoping someone can point me in the right direction on my dev box I am running PHP 5.3.3 and the production box is PHP 5.2.14 which should meet the minimum requirements of Datamapper. The production server is a MediaTemple (gs) server if that helps at all.

Is there a php setting I need to check or something like that?
#2

[eluser]bige8000[/eluser]
So Turns out that is was the case of my Model filenames I have them beginning with a capital letter, which worked fine locally, but on the actual server not work so well. Change filenames to be all lowercase and it works.
#3

[eluser]WanWizard[/eluser]
Local server a Windows machine by any chance?

A Windows file system is case insensitive, where as a linux file system is not. Always follow the standards, and use lowercase for filenames only.
#4

[eluser]bige8000[/eluser]
No actually, I am running Mac OS X - 10.6.6
#5

[eluser]WanWizard[/eluser]
Odd, afaik it has a case-sensitive filesystem as well... Should behave the same as linux.
#6

[eluser]Arministrator[/eluser]
Hi, I'm having the same trouble that bige mentioned. Codeigniter can't seem to load the DataMapper classes I defined. I've checked for correct capitalization of files and class names. Even stayed within the limits of DM's naming conventions, but to no success.

My DM class models are all in the application/models. If a class name is Donator, then the corresponding table's name is donators, and the file is application/models/donator.php

I'm using Codeigniter 2.0.2 and the latest version of DataMapper ORM, from bitbucket.

I'll provide more info, if necessary.

I'm pulling my hair out.
#7

[eluser]WanWizard[/eluser]
Did you load the library before trying to load the model? Datamapper must be loaded, either through the autoload feature of the config, of explicitly via $this->load->library().

If you don't, the autoloader isn't active.
#8

[eluser]Arministrator[/eluser]
Let me just quickly say I'm impressed by the amount of support you provide for this library.

Now, I've tried both actually - the autoloader and through my controler (while deleting the call from the autoloader).

The problem appears to come from the core loader, this is the error:

Fatal error: Class 'Donator' not found in C:\wamp\www\ci-dm\sys\core\Loader.php on line 188

That line in the loader says: $CI->$name = new $model();
#9

[eluser]WanWizard[/eluser]
Datamapper doesn't use the loader library to load models. Are you trying to use $this->load->model() to load a datamapper model?
#10

[eluser]Arministrator[/eluser]
I've read that part in the docs, I'm just trying to load the library.

Could it have anything to do with the way Codeigniter's classes are extended? For example, you have to extend CI_Controller, or a CI_Model. On the other hand, it's a DataMapper class, not a core class extension...

I know it most probably has nothing to do with it, but nothing else comes to mind at this point. I've spent all this time reading the DM docs and I'm eager to try it out (on a real project, as the matter of fact), but I'm stuck on step 1. Frustrating Smile




Theme © iAndrew 2016 - Forum software by © MyBB