1
votes

Hi I've got an error in my Zend Framework project...

It raised:

Invalid controller specified (myweb)

Here is my apache error.log:

PHP Warning: Invalid argument supplied for foreach() in /var/www/myweb/application/layouts/scripts/layout.phtml on line 107

Here's my code in layout.phtml:

<?php foreach($this->category as $categories):?>

    <li><a href="<?php echo $this->url(array('controller'=>'product', 'action'=>'index','category'=> $categories['categoriesName']), null, true);?>"><div id="sidemenu"> �<?php echo $categories['categoriesName'];?></div></a></li>

    <?php endforeach;?>

Can anybody help me?

3
misteck is in your Controller, it not supplies the categroy. so you go error in layout.phtmlDaya

3 Answers

1
votes

The problem seems to be that for some reason your url is presenting myweb as the controller instead of what should be your controller.

My guess is the you are trying to use localhost to display your application so are presenting a url similar to http://localhost/myweb/...

While it is possible to use the localhost to view ZF applications it often becomes inconvenient as applications become more complex. I would suggest you use a vhost for anything more then a very simple application.

I'm pretty sure that when you resolve the url problem the php warning will likely fix itself.

0
votes

It seems like the variable $this->category is not set in the Controller. You can do this by defining $this->view->category from your controller.

Mostly when using these controller generated variables in the layout script instead of the corresponding view script, you want to use the same data in every view. If this is the case, check this question: Sending variables to the layout in Zend Framework

0
votes

This error come because your array $this->category is blank. if this is blank array or return nothing then how foreach loop will execute?

so first print this array and check.