The route element id and frontName attributes have the same value, but they do
not serve the same purpose.
app/code/Mage/Example/etc/frontend/routes.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="helloworld" frontName="helloworld">
<module name="Mage_Example" />
</route>
</router>
</config>
Route definition requires a unique id and frontName attribute values, which in our case both equal helloworld.
The frontName attribute value becomes the part of our URL structure. Simply put, the URL formula for hitting the Crud action goes like:
{magento-base-url}/index.php/{route frontName}/{controller name}/{action name}
For example, if our base URL were http://domain.com/
, the full URL would be
http://domain.com/index.php/helloworld/test/crud/
.
Note: If we have URL rewrites turned on, we could omit the index.php part.
namespace Mage\Example\Controller;
abstract class Test extends \Magento\Framework\App\Action\Action
{
}
namespace Mage\Example\Controller\Test;
class Crud extends \Mage\Example\Controller\Test
{
public function __construct(
/* Code Here */
)
{
/* Code Here */
return parent::__construct($context);
}
public function execute()
{
/* CRUD Code Here */
}
}