You are not logged in.
Pages: 1
Hi,
I have problems with the autoloading.
I have a normal zend setup with the models folder in the application folder.
Application.ini has appnamespace = "Application"
In some way he does not load the model auto, i need to do an require_once for it ...
autoloaderNamespaces[] = "ZendX" works like a charm, but i want to use the default model folder ... any ideas what i'm doing wrong?
htaccess has :
SetEnv APPLICATION_ENV production
RewriteEngine On
#RewriteBase /
#RewriteCond %{REQUEST_URI} =""
#RewriteRule ^.*$ /public/index.php [NC,L]
#RewriteCond %{REQUEST_FILENAME} -s [OR]
#RewriteCond %{REQUEST_FILENAME} -l [OR]
#RewriteCond %{REQUEST_FILENAME} -d
#RewriteRule ^.*$ - [NC,L]
#RewriteRule ^.*$ index.php [NC,L]
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
thx,
Xavier
Offline
Hi Xavier,
you need to change "Application" in your config.ini to "" (this way, the default prefix is nothing)
Offline
Hi Xavier,
you need to change "Application" in your config.ini to "" (this way, the default prefix is nothing)
Hi,
thx for your answer.
I still have the issue : Fatal error: Class 'Application_Model_Referenties' not found in ...
The models is in the standard way ...
bootstrap:
/* autoloader Application_ */
protected function _initResourceAutoloader()
{
$autoloader = new Zend_Loader_Autoloader_Resource(array(
'basePath' => APPLICATION_PATH,
'namespace' => 'Application_',
));
Last edited by Xavier (2010-08-10 08:31:23)
Offline
are you creating a [code=php] new Model_Referenties();
or new Application_Model_Referenties();
[/code] ?
Offline
are you creating a [code=php] new Model_Referenties();
or new Application_Model_Referenties();
[/code] ?
thx for the quick answer!
require_once(APPLICATION_PATH.'/models/referenties.php');
$obj = new Application_Model_Referenties();
Deleting the application appnamespace did crash my form class.
Application -> models
-> forms
-> controller
-> ...
I tought the Application did tell the autoloader to default load everything in the application folder an starting with Application_
Last edited by Xavier (2010-08-10 08:37:54)
Offline
your file should be called Referenties.php. You shouldn't need to autoload it (since Zend_Autoload will do that for you).
the class inside should be (assuming your config.ini appnamespace = "")
[code=php]
class Model_Referenties
{
}
...
$obj = new Model_Referenties();
[/code]
Offline
Fatal error: Class 'Model_Referenties' not found in
referenties = Model_Referenties
application.inc = appnamespace ""
controller = new Model_Referenties()
I think there is something missed up somewhere, I did normal setup with Zend Tool
referenties:
class Model_Referenties
{
public static function getReferenties($count = false){
if($count){
$sql = "SELECT * FROM referenties ORDER BY id DESC LIMIT 0,$count";
}else{
$sql = "SELECT * FROM referenties ORDER BY id DESC";
}
$db = Zend_Registry::get("db");
return $db->fetchAll($sql);
}
}
IndexController
class IndexController extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
// action body
$layout = $this->_helper->layout();
$layout->setLayout('layout');
/* standaard encoding, meta ... */
$this->view->headTitle('Billonline');
// Deze zou normaal niet geplaatst moeten worden
//require_once(APPLICATION_PATH.'/models/referenties.php');
$obj = new Model_Referenties();
$referenties = $obj->getReferenties(2);
$this->view->referenties = $referenties;
$this->view->page = "home";
}
}
application.ini
appnamespace = ""
removing the Application did crash my form class
Offline
what's the name of the php file? make sure it's "Referenties.php" (case sensitive)
Offline
what's the name of the php file? make sure it's "Referenties.php" (case sensitive)
ouch ... stupid of me! thx!
Offline
Pages: 1