Fatal error: Cannot declare class Vendor\Modelname\ResourceModel\Doccount, because the name is already in use in /var/www/html/readyresale/app/code/Vendor\Modelname/Model/ResourceModel/Doccount.php on line 23

ResourceModel/Doccount.php file

namespace Vendor\Modulename\ResourceModel;

use Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class Doccount extends AbstractDb
    protected function _construct()
        $this->_init ( 'documentcountable','id' );

model/Doccountmodel.php file

namespace Vendor\Modulename\Model;

use Magento\Framework\Model\AbstractModel;

class Doccountmodel extends AbstractModel
    public function _construct()
        $this->_init ( 'Vendor\Modulename\Model\ResourceModel\Doccount' );
  • can you please add code for this file? – Abhishek Panchal Jul 3 '18 at 15:03

It's an issue with your namespace declaration

Change the code in file ResourceModel/Doccount.php file

namespace Vendor\Modulename\ResourceModel;


namespace Vendor\Modulename\Model\ResourceModel;

Also, make sure that ResourceModel/Doccount.php inside Model directory so it'll be Model/ResourceModel/Doccount.php

namespace Vendor\Modulename\ResourceModel;


namespace Vendor\Modulename\model\ResourceModel;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.