【发布时间】:2020-01-11 10:16:46
【问题描述】:
运行时出现 404 not found 错误
https://example.com/uicustomer/index/test
请帮忙!!
vendor\magento2-vendor-ui_customer\Controller\Index\Test.php
<?php
namespace Vendor\UiCustomer\Controller\Index;
class Test extends \Magento\Framework\App\Action\Action
{
protected $_pageFactory;
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $pageFactory)
{
$this->_pageFactory = $pageFactory;
return parent::__construct($context);
}
public function execute()
{
echo "Hello World";
exit;
}
}
供应商\magento2-vendor-ui_customer\etc\module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_UiCustomer" setup_version="1.1.3">
</module>
</config>
vendor\magento2-vendor-ui_customer\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 frontName="uicustomer" id="uicustomer">
<module name="Vendor_UiCustomer"/>
</route>
</router>
</config>
供应商\magento2-vendor-ui_customer\composer.json
{
"name": "vendor/magento2-vendor-ui_customer",
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Vendor\\UiCustomer\\": ""
}
}
}
供应商\magento2-vendor-ui_customer\registration.php
<?php
use \Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Vendor_UiCustomer',
__DIR__
);
【问题讨论】:
-
我只是查看了 composer/autoload_psr4.php 它没有在这个文件中生成命名空间
标签: php composer-php magento2