I’ve created and enabled a module at app/code/Post/Test
:
app/code/Post/Test/registration.php
:
<?php
MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'Post_Test',
__DIR__
);
app/code/Post/Test/etc/module.xml
:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Post_Test" setup_version="1.0.0" />
</config>
app/code/Post/Test/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="post_test" frontName="posttest">
<module name="Post_Test" />
</route>
</router>
</config>
app/code/Post/Test/Controller/Test
:
<?php
namespace PostTestController;
use MagentoFrameworkControllerResultRaw;
use MagentoFrameworkAppActionHttpPostActionInterface;
class Test implements HttpPostActionInterface
{
private $raw;
public function __construct(Raw $raw)
{
$this->raw = $raw;
}
public function execute()
{
return $this->raw->setContents('foo bar baz');
}
}
Based on this, I think that my controller should be accessible via a POST
request to: http://localhost/posttest/test
, but it just gives me a 404.
What am I doing wrong?