1

when i download log file from admin then this error occur Error: Class "Zend_Filter_BaseName" not found in app/code/vendor/module/Controller/adminhtml/Download/GetLog.php Here is that file.

<?php
namespace vendor\module\Controller\Adminhtml\Download;

use Magento\Backend\App\Action\Context;
use Magento\Backend\Controller\Adminhtml\System;
use Magento\Framework\App\Response\Http\FileFactory;
use Magento\Framework\Exception\NotFoundException;
use Zend_Filter_BaseName;

abstract class GetLog extends System
{
    protected $fileFactory;
    public function __construct(Context $context, FileFactory $fileFactory)
    {
        $this->fileFactory = $fileFactory;
        parent::__construct($context);
    }

    public function execute()
    {
        $param = $this->getRequest()->getParams();
        $filePath = $this->getFilePathWithFile($param[0]);

        $filter   = new Zend_Filter_BaseName();
        $fileName = $filter->filter($filePath);
        try {
            return $this->fileFactory->create(
                $fileName,
                [
                    'type'  => 'filename',
                    'value' => $filePath
                ]
            );
        } catch (\Exception $e) {
            throw new NotFoundException(__($e->getMessage()));
        }
    }
}
5
  • can you share more details? Commented May 12, 2023 at 13:54
  • when i download log file from admin then this error occur Error: Class "Zend_Filter_BaseName" not found in app/code/vendor/module/Controller/adminhtml/Download/GetLog.php I edit my question also.
    – Ekta
    Commented May 13, 2023 at 2:53
  • it looks like zend_filter_basename class is not available you may try this Zend\Filter\FilterChain class. Commented May 14, 2023 at 10:06
  • Try replacing it with \Laminas\Filter\BaseName() Commented May 14, 2023 at 11:25
  • Replace my code like this and my problem is solved. i remove use Zend_Filter_BaseName; and edit this line like $filter = basename($filePath);
    – Ekta
    Commented May 25, 2023 at 5:06

0

Browse other questions tagged or ask your own question.