Getting Fatal error: Cannot redeclare class in magento 2

Getting Fatal error: Cannot redeclare class in magento 2

enter code here我已经创建了一个从 table 获取数据的模块,但是当我 运行 这个模块时,我收到一个致命错误 cannot re-declare class。我只有一个 class 叫你好。这是我第一次创建模块,我没有 magento 1 的经验 Link for module source code github

Block\Helloworld.php

    <?php
    namespace Devchannel\Helloworld\Block;


    use Magento\Framework\View\Element\Template\Context;
    use Devchannel\Helloworld\Model\Data;
    use Magento\Framework\View\Element\Template;


    class Hello extends Template
    {

        public function __construct(Context $context, Data $model)
        {
                    $this->model = $model;
            parent::__construct($context);

        }

        public function sayHello()
        {
            return __('Hello World');
        }
            public function getHelloCollection()
            {
                $helloCollection = $this->model->getCollection();
                return $helloCollection;
            }
    }

将您的 class 名称更改为 Helloworld。它应该始终与您的文件名匹配。