0
votes

I'm new to magento development,and I'm trying to add controller for my module but it's not working out with me (404 error messages appears). here is the details: /var/www/magento/app/code/local/Myproject/Helloworld/etc/config.xml

<?xml version='1.0'?>
<config>
  <modules>
    <Myproject_Helloworld>
      <version>0.0.0.1</vresion>
    </Myproject_Helloworld>
  </modules>
  <frontend>
    <routers>
      <helloworld>
    <use>standard</use>
    <args>
      <module>Myproject_Helloworld</module>
      <frontName>helloworld</frontName>
    </args>
      </helloworld>
    </routers>
  </frontend>
</config>

/var/www/magento/app/etc/modules/Myproject_Helloworld.xml

<?xml version='1.0'?>
<config>
  <modules>
    <Myproject_Helloworld>
      <active>true</active>
      <codePool>local</codePool>
    </Myproject_Helloworld>
  </modules>
</config>

/var/www/magento/app/code/local/Myproject/Helloworld/controllers/IndexController.php

<?php

class Myproject_Helloworld_IndexController extends Mage_Core_Controller_Front_Action
{
  public function indexAction()
  {
    echo 'Hello world!';
  }
}
?>

I'm trying URL: localhost/magento/helloworld/index/index Any idea please .. thanx in advance.

3
try this: localhost/magento/index.phphelloworld/index/indexsergio
try localhost/magento/index.php/helloworld/index/indexPradeep Sanku
please check in your config.xml <version>0.0.0.1</vresion> their is spelling mistakePradeep Sanku
thanx for quick respond .. I've tried the URL and still not working :( appeared magento's requested page not foud Help please ..rramiii
As @Pradeep Sanku said, there is a mistake in you xml filesergio

3 Answers

0
votes

First check in admin if your module works at all:

System->Configuration->Advanced

check if your module is listed. If it's not it means you have an error in your XML file (which you do)

you have

<version>0.0.0.1</vresion>

change it to

<version>0.0.0.1</version>
0
votes

I have checked your code in my localhost and it worked fine there. Since your module is enabled in config, the issue may due to cache problem. Go to system->cache management and there select all items and disable them. Then go to var->cache folder of your folder directory and clear the cache items.

Now go to your controller file. There you have added ?> at the end. Please avoid it. If you check the core files in magento, you can see that, magento does not encourage the usage of 'closing php notation' (?>) for code pool files ( [core, community, local] are the codepools of magento).

Now try to load your page.Probably it will work.Good luck

0
votes

Wow .. suddenly worked .. used this URL: localhost/magento/index.php/helloworld/index/index .. thanx all and good luck