Magento 2 Fatal error: Uncaught Error: Class not foundI created a custom module ,but getting error, not able...

Make a transparent 448*448 image

Counting certain elements in lists

How to answer questions about my characters?

Font with correct density?

Humanity loses the vast majority of its technology, information, and population in the year 2122. How long does it take to rebuild itself?

Why is "das Weib" grammatically neuter?

Bash replace string at multiple places in a file from command line

How to deal with a cynical class?

Replacing Windows 7 security updates with anti-virus?

Brexit - No Deal Rejection

How do anti-virus programs start at Windows boot?

Employee lack of ownership

How could a scammer know the apps on my phone / iTunes account?

Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?

How could a female member of a species produce eggs unto death?

Bash: What does "masking return values" mean?

Why did it take so long to abandon sail after steamships were demonstrated?

An Accountant Seeks the Help of a Mathematician

What options are left, if Britain cannot decide?

Why do Australian milk farmers need to protest supermarkets' milk price?

Why are there 40 737 Max planes in flight when they have been grounded as not airworthy?

Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?

Is having access to past exams cheating and, if yes, could it be proven just by a good grade?

What are the possible solutions of the given equation?



Magento 2 Fatal error: Uncaught Error: Class not found


I created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?Reset Password Problem : Magento 2Not able to add/update magento2 category post upgrade from 1.9 to 2.1.0Trying to uninstall module“Class mixed does not exist” with only one array param in the body in Magento 2Add configure product in Cart using Magento 2 API facing an issuePHP fatal error: Uncaught TypeError: Argument 2 passed to MagentoCatalogPluginBlockTopmenuMagento error when going to forgotten password link













1















I am using one custom php library in magento 2 to convert html to pdf. Here is the code that i am using.



<?php

namespace CompanyModuleControllerAdminhtmlQuote;

use MagentoFrameworkAppActionAction;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkAppFilesystemDirectoryList as DirectoryList;

use CompanyModuleHelperPdfCrowd;

class QuotePdf extends Action
{
/**
* @var MagentoFrameworkAppResponseHttpFileFactory
*/
protected $fileFactory;
protected $_mediaDirectory;
protected $directory_list;

protected $dompdfFactory;
protected $layoutFactory;

protected $authSession;
//protected $quote_info;
protected $userFactory;

public function __construct(
Context $context,
MagentoFrameworkAppResponseHttpFileFactory $fileFactory,
MagentoFrameworkFilesystem $filesystem,
MagentoBackendModelAuthSession $authSession,
DirectoryList $directory_list,
MagentoUserModelUserFactory $userFactory
) {
parent::__construct($context);
$this->fileFactory = $fileFactory;
$this->authSession = $authSession;
$this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->directory_list = $directory_list;
$this->userFactory = $userFactory;
}

public function execute()
{
if($this->authSession->isLoggedIn()){

$id = $this->getRequest()->getParam('id');

$client = new Pdfcrowd("MYUSERNAME", "xxxxxxx-KEY");

// set HTTP response headers
$pdf = $client->convertHtml($this->getHtmlForPdf($id));

header("Content-Type: application/pdf");
header("Cache-Control: no-cache");
header("Accept-Ranges: none");
header("Content-Disposition: attachment; filename=commercialsale-".$id.".pdf");

echo $pdf;
}
}
}


Here is my Helpler file



<?php

namespace CompanyModuleHelper;

class PdfCrowd {
//
// Pdfcrowd constructor.
//
// $username - your username at Pdfcrowd
// $apikey - your API key
// $hostname - API hostname, defaults to pdfcrowd.com
//
function __construct($username, $apikey, $hostname=null){
if ($hostname)
$this->hostname = $hostname;
else
$this->hostname = self::$api_host;
$this->useSSL(false);
$this->fields = array(
'username' => $username,
'key' => $apikey,
'pdf_scaling_factor' => 1,
'html_zoom' => 200);
$this->proxy_name = null;
$this->proxy_port = null;
$this->proxy_username = "";
$this->proxy_password = "";

$this->user_agent = "pdfcrowd_php_client_".self::$client_version."_(http://pdfcrowd.com)";
}
}
?>


And here is the error that i am getting...




Fatal error: Uncaught Error: Class 'CompanyModuleHelperPdfCrowd'
not found in
/home/patios/public_html/app/code/Company/Module/Controller/Adminhtml/Quote/QuotePdf.php:49
Stack trace: #0
/home/patios/public_html/vendor/magento/framework/App/Action/Action.php(107):
CompanyModuleControllerAdminhtmlQuoteQuotePdf->execute() #1
/home/patios/public_html/vendor/magento/framework/Interception/Interceptor.php(58):
MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
2 /home/patios/public_html/vendor/magento/framework/Interception/Interceptor.php(138):
CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor->___callParent('dispatch',
Array) 3
/home/patios/public_html/vendor/magento/framework/Interception/Interceptor.php(153):
CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
4 /home/patios/public_html/generated/code/Company/Module/Controller/Adminhtml
in
/home/patios/public_html/app/code/Company/Module/Controller/Adminhtml/Quote/QuotePdf.php
on line 49




Note:
Same code is working on my local and not on live server.










share|improve this question
















bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 2





    Check exact folder and class name for CompanyModuleHelperPdfCrowd

    – Sohel Rana
    Jun 8 '18 at 13:41











  • Thanks to pointing me. Sorry actually there is capital word issue in my file name. Strange that this is working in my local.

    – Hardik
    Jun 8 '18 at 13:53











  • yes, Linux is naming strict type. But other system like windows, mac not.

    – Sohel Rana
    Jun 8 '18 at 13:55
















1















I am using one custom php library in magento 2 to convert html to pdf. Here is the code that i am using.



<?php

namespace CompanyModuleControllerAdminhtmlQuote;

use MagentoFrameworkAppActionAction;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkAppFilesystemDirectoryList as DirectoryList;

use CompanyModuleHelperPdfCrowd;

class QuotePdf extends Action
{
/**
* @var MagentoFrameworkAppResponseHttpFileFactory
*/
protected $fileFactory;
protected $_mediaDirectory;
protected $directory_list;

protected $dompdfFactory;
protected $layoutFactory;

protected $authSession;
//protected $quote_info;
protected $userFactory;

public function __construct(
Context $context,
MagentoFrameworkAppResponseHttpFileFactory $fileFactory,
MagentoFrameworkFilesystem $filesystem,
MagentoBackendModelAuthSession $authSession,
DirectoryList $directory_list,
MagentoUserModelUserFactory $userFactory
) {
parent::__construct($context);
$this->fileFactory = $fileFactory;
$this->authSession = $authSession;
$this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->directory_list = $directory_list;
$this->userFactory = $userFactory;
}

public function execute()
{
if($this->authSession->isLoggedIn()){

$id = $this->getRequest()->getParam('id');

$client = new Pdfcrowd("MYUSERNAME", "xxxxxxx-KEY");

// set HTTP response headers
$pdf = $client->convertHtml($this->getHtmlForPdf($id));

header("Content-Type: application/pdf");
header("Cache-Control: no-cache");
header("Accept-Ranges: none");
header("Content-Disposition: attachment; filename=commercialsale-".$id.".pdf");

echo $pdf;
}
}
}


Here is my Helpler file



<?php

namespace CompanyModuleHelper;

class PdfCrowd {
//
// Pdfcrowd constructor.
//
// $username - your username at Pdfcrowd
// $apikey - your API key
// $hostname - API hostname, defaults to pdfcrowd.com
//
function __construct($username, $apikey, $hostname=null){
if ($hostname)
$this->hostname = $hostname;
else
$this->hostname = self::$api_host;
$this->useSSL(false);
$this->fields = array(
'username' => $username,
'key' => $apikey,
'pdf_scaling_factor' => 1,
'html_zoom' => 200);
$this->proxy_name = null;
$this->proxy_port = null;
$this->proxy_username = "";
$this->proxy_password = "";

$this->user_agent = "pdfcrowd_php_client_".self::$client_version."_(http://pdfcrowd.com)";
}
}
?>


And here is the error that i am getting...




Fatal error: Uncaught Error: Class 'CompanyModuleHelperPdfCrowd'
not found in
/home/patios/public_html/app/code/Company/Module/Controller/Adminhtml/Quote/QuotePdf.php:49
Stack trace: #0
/home/patios/public_html/vendor/magento/framework/App/Action/Action.php(107):
CompanyModuleControllerAdminhtmlQuoteQuotePdf->execute() #1
/home/patios/public_html/vendor/magento/framework/Interception/Interceptor.php(58):
MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
2 /home/patios/public_html/vendor/magento/framework/Interception/Interceptor.php(138):
CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor->___callParent('dispatch',
Array) 3
/home/patios/public_html/vendor/magento/framework/Interception/Interceptor.php(153):
CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
4 /home/patios/public_html/generated/code/Company/Module/Controller/Adminhtml
in
/home/patios/public_html/app/code/Company/Module/Controller/Adminhtml/Quote/QuotePdf.php
on line 49




Note:
Same code is working on my local and not on live server.










share|improve this question
















bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 2





    Check exact folder and class name for CompanyModuleHelperPdfCrowd

    – Sohel Rana
    Jun 8 '18 at 13:41











  • Thanks to pointing me. Sorry actually there is capital word issue in my file name. Strange that this is working in my local.

    – Hardik
    Jun 8 '18 at 13:53











  • yes, Linux is naming strict type. But other system like windows, mac not.

    – Sohel Rana
    Jun 8 '18 at 13:55














1












1








1








I am using one custom php library in magento 2 to convert html to pdf. Here is the code that i am using.



<?php

namespace CompanyModuleControllerAdminhtmlQuote;

use MagentoFrameworkAppActionAction;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkAppFilesystemDirectoryList as DirectoryList;

use CompanyModuleHelperPdfCrowd;

class QuotePdf extends Action
{
/**
* @var MagentoFrameworkAppResponseHttpFileFactory
*/
protected $fileFactory;
protected $_mediaDirectory;
protected $directory_list;

protected $dompdfFactory;
protected $layoutFactory;

protected $authSession;
//protected $quote_info;
protected $userFactory;

public function __construct(
Context $context,
MagentoFrameworkAppResponseHttpFileFactory $fileFactory,
MagentoFrameworkFilesystem $filesystem,
MagentoBackendModelAuthSession $authSession,
DirectoryList $directory_list,
MagentoUserModelUserFactory $userFactory
) {
parent::__construct($context);
$this->fileFactory = $fileFactory;
$this->authSession = $authSession;
$this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->directory_list = $directory_list;
$this->userFactory = $userFactory;
}

public function execute()
{
if($this->authSession->isLoggedIn()){

$id = $this->getRequest()->getParam('id');

$client = new Pdfcrowd("MYUSERNAME", "xxxxxxx-KEY");

// set HTTP response headers
$pdf = $client->convertHtml($this->getHtmlForPdf($id));

header("Content-Type: application/pdf");
header("Cache-Control: no-cache");
header("Accept-Ranges: none");
header("Content-Disposition: attachment; filename=commercialsale-".$id.".pdf");

echo $pdf;
}
}
}


Here is my Helpler file



<?php

namespace CompanyModuleHelper;

class PdfCrowd {
//
// Pdfcrowd constructor.
//
// $username - your username at Pdfcrowd
// $apikey - your API key
// $hostname - API hostname, defaults to pdfcrowd.com
//
function __construct($username, $apikey, $hostname=null){
if ($hostname)
$this->hostname = $hostname;
else
$this->hostname = self::$api_host;
$this->useSSL(false);
$this->fields = array(
'username' => $username,
'key' => $apikey,
'pdf_scaling_factor' => 1,
'html_zoom' => 200);
$this->proxy_name = null;
$this->proxy_port = null;
$this->proxy_username = "";
$this->proxy_password = "";

$this->user_agent = "pdfcrowd_php_client_".self::$client_version."_(http://pdfcrowd.com)";
}
}
?>


And here is the error that i am getting...




Fatal error: Uncaught Error: Class 'CompanyModuleHelperPdfCrowd'
not found in
/home/patios/public_html/app/code/Company/Module/Controller/Adminhtml/Quote/QuotePdf.php:49
Stack trace: #0
/home/patios/public_html/vendor/magento/framework/App/Action/Action.php(107):
CompanyModuleControllerAdminhtmlQuoteQuotePdf->execute() #1
/home/patios/public_html/vendor/magento/framework/Interception/Interceptor.php(58):
MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
2 /home/patios/public_html/vendor/magento/framework/Interception/Interceptor.php(138):
CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor->___callParent('dispatch',
Array) 3
/home/patios/public_html/vendor/magento/framework/Interception/Interceptor.php(153):
CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
4 /home/patios/public_html/generated/code/Company/Module/Controller/Adminhtml
in
/home/patios/public_html/app/code/Company/Module/Controller/Adminhtml/Quote/QuotePdf.php
on line 49




Note:
Same code is working on my local and not on live server.










share|improve this question
















I am using one custom php library in magento 2 to convert html to pdf. Here is the code that i am using.



<?php

namespace CompanyModuleControllerAdminhtmlQuote;

use MagentoFrameworkAppActionAction;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkAppFilesystemDirectoryList as DirectoryList;

use CompanyModuleHelperPdfCrowd;

class QuotePdf extends Action
{
/**
* @var MagentoFrameworkAppResponseHttpFileFactory
*/
protected $fileFactory;
protected $_mediaDirectory;
protected $directory_list;

protected $dompdfFactory;
protected $layoutFactory;

protected $authSession;
//protected $quote_info;
protected $userFactory;

public function __construct(
Context $context,
MagentoFrameworkAppResponseHttpFileFactory $fileFactory,
MagentoFrameworkFilesystem $filesystem,
MagentoBackendModelAuthSession $authSession,
DirectoryList $directory_list,
MagentoUserModelUserFactory $userFactory
) {
parent::__construct($context);
$this->fileFactory = $fileFactory;
$this->authSession = $authSession;
$this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->directory_list = $directory_list;
$this->userFactory = $userFactory;
}

public function execute()
{
if($this->authSession->isLoggedIn()){

$id = $this->getRequest()->getParam('id');

$client = new Pdfcrowd("MYUSERNAME", "xxxxxxx-KEY");

// set HTTP response headers
$pdf = $client->convertHtml($this->getHtmlForPdf($id));

header("Content-Type: application/pdf");
header("Cache-Control: no-cache");
header("Accept-Ranges: none");
header("Content-Disposition: attachment; filename=commercialsale-".$id.".pdf");

echo $pdf;
}
}
}


Here is my Helpler file



<?php

namespace CompanyModuleHelper;

class PdfCrowd {
//
// Pdfcrowd constructor.
//
// $username - your username at Pdfcrowd
// $apikey - your API key
// $hostname - API hostname, defaults to pdfcrowd.com
//
function __construct($username, $apikey, $hostname=null){
if ($hostname)
$this->hostname = $hostname;
else
$this->hostname = self::$api_host;
$this->useSSL(false);
$this->fields = array(
'username' => $username,
'key' => $apikey,
'pdf_scaling_factor' => 1,
'html_zoom' => 200);
$this->proxy_name = null;
$this->proxy_port = null;
$this->proxy_username = "";
$this->proxy_password = "";

$this->user_agent = "pdfcrowd_php_client_".self::$client_version."_(http://pdfcrowd.com)";
}
}
?>


And here is the error that i am getting...




Fatal error: Uncaught Error: Class 'CompanyModuleHelperPdfCrowd'
not found in
/home/patios/public_html/app/code/Company/Module/Controller/Adminhtml/Quote/QuotePdf.php:49
Stack trace: #0
/home/patios/public_html/vendor/magento/framework/App/Action/Action.php(107):
CompanyModuleControllerAdminhtmlQuoteQuotePdf->execute() #1
/home/patios/public_html/vendor/magento/framework/Interception/Interceptor.php(58):
MagentoFrameworkAppActionAction->dispatch(Object(MagentoFrameworkAppRequestHttp))
2 /home/patios/public_html/vendor/magento/framework/Interception/Interceptor.php(138):
CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor->___callParent('dispatch',
Array) 3
/home/patios/public_html/vendor/magento/framework/Interception/Interceptor.php(153):
CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor->MagentoFrameworkInterception{closure}(Object(MagentoFrameworkAppRequestHttp))
4 /home/patios/public_html/generated/code/Company/Module/Controller/Adminhtml
in
/home/patios/public_html/app/code/Company/Module/Controller/Adminhtml/Quote/QuotePdf.php
on line 49




Note:
Same code is working on my local and not on live server.







magento2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 31 '18 at 5:16









Teja Bhagavan Kollepara

2,98141947




2,98141947










asked Jun 8 '18 at 13:09









HardikHardik

12013




12013





bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 6 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.










  • 2





    Check exact folder and class name for CompanyModuleHelperPdfCrowd

    – Sohel Rana
    Jun 8 '18 at 13:41











  • Thanks to pointing me. Sorry actually there is capital word issue in my file name. Strange that this is working in my local.

    – Hardik
    Jun 8 '18 at 13:53











  • yes, Linux is naming strict type. But other system like windows, mac not.

    – Sohel Rana
    Jun 8 '18 at 13:55














  • 2





    Check exact folder and class name for CompanyModuleHelperPdfCrowd

    – Sohel Rana
    Jun 8 '18 at 13:41











  • Thanks to pointing me. Sorry actually there is capital word issue in my file name. Strange that this is working in my local.

    – Hardik
    Jun 8 '18 at 13:53











  • yes, Linux is naming strict type. But other system like windows, mac not.

    – Sohel Rana
    Jun 8 '18 at 13:55








2




2





Check exact folder and class name for CompanyModuleHelperPdfCrowd

– Sohel Rana
Jun 8 '18 at 13:41





Check exact folder and class name for CompanyModuleHelperPdfCrowd

– Sohel Rana
Jun 8 '18 at 13:41













Thanks to pointing me. Sorry actually there is capital word issue in my file name. Strange that this is working in my local.

– Hardik
Jun 8 '18 at 13:53





Thanks to pointing me. Sorry actually there is capital word issue in my file name. Strange that this is working in my local.

– Hardik
Jun 8 '18 at 13:53













yes, Linux is naming strict type. But other system like windows, mac not.

– Sohel Rana
Jun 8 '18 at 13:55





yes, Linux is naming strict type. But other system like windows, mac not.

– Sohel Rana
Jun 8 '18 at 13:55










2 Answers
2






active

oldest

votes


















0














Try this:



<?php

namespace CompanyModuleControllerAdminhtmlQuote;

use MagentoFrameworkAppActionAction;
use MagentoFrameworkAppActionContext;
use MagentoFrameworkAppFilesystemDirectoryList as DirectoryList;

use CompanyModuleHelperPdfCrowd;

class QuotePdf extends Action
{
/**
* @var MagentoFrameworkAppResponseHttpFileFactory
*/
protected $fileFactory;
protected $_mediaDirectory;
protected $directory_list;

protected $dompdfFactory;
protected $layoutFactory;

protected $authSession;
//protected $quote_info;
protected $userFactory;
protected $_pdfCrowd;
public function __construct(
Context $context,
MagentoFrameworkAppResponseHttpFileFactory $fileFactory,
MagentoFrameworkFilesystem $filesystem,
MagentoBackendModelAuthSession $authSession,
PdfCrowd $pdfCrowd,
DirectoryList $directory_list,
MagentoUserModelUserFactory $userFactory
) {
parent::__construct($context);
$this->_pdfCrowd = $pdfCrowd;
$this->fileFactory = $fileFactory;
$this->authSession = $authSession;
$this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->directory_list = $directory_list;
$this->userFactory = $userFactory;
}

public function execute()
{
if($this->authSession->isLoggedIn()){

$id = $this->getRequest()->getParam('id');

$client = $this->_pdfCrowd->createPdf("MYUSERNAME", "xxxxxxx-KEY");

// set HTTP response headers
$pdf = $client->convertHtml($this->getHtmlForPdf($id));

header("Content-Type: application/pdf");
header("Cache-Control: no-cache");
header("Accept-Ranges: none");
header("Content-Disposition: attachment; filename=commercialsale-".$id.".pdf");

echo $pdf;
}
}
}


I have replaced method name and called with dependency injection.



<?php

namespace CompanyModuleHelper;

class PdfCrowd {
//
// Pdfcrowd constructor.
//
// $username - your username at Pdfcrowd
// $apikey - your API key
// $hostname - API hostname, defaults to pdfcrowd.com
//
function createPdf($username, $apikey, $hostname=null){
if ($hostname)
$this->hostname = $hostname;
else
$this->hostname = self::$api_host;
$this->useSSL(false);
$this->fields = array(
'username' => $username,
'key' => $apikey,
'pdf_scaling_factor' => 1,
'html_zoom' => 200);
$this->proxy_name = null;
$this->proxy_port = null;
$this->proxy_username = "";
$this->proxy_password = "";

$this->user_agent = "pdfcrowd_php_client_".self::$client_version."_(http://pdfcrowd.com)";
}
}
?>





share|improve this answer
























  • This error. Class CompanyModuleHelperPdfCrowd does not exist in [CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor]

    – Hardik
    Jun 8 '18 at 13:38













  • please run this php bin/magento setup:di:compile then php bin/magento cache:flush

    – kunj
    Jun 8 '18 at 14:22



















0














Use below on your helper file:



class PdfCrowd extends MagentoFrameworkAppHelperAbstractHelper{
}


instead of



class PdfCrowd{
}





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f229214%2fmagento-2-fatal-error-uncaught-error-class-not-found%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Try this:



    <?php

    namespace CompanyModuleControllerAdminhtmlQuote;

    use MagentoFrameworkAppActionAction;
    use MagentoFrameworkAppActionContext;
    use MagentoFrameworkAppFilesystemDirectoryList as DirectoryList;

    use CompanyModuleHelperPdfCrowd;

    class QuotePdf extends Action
    {
    /**
    * @var MagentoFrameworkAppResponseHttpFileFactory
    */
    protected $fileFactory;
    protected $_mediaDirectory;
    protected $directory_list;

    protected $dompdfFactory;
    protected $layoutFactory;

    protected $authSession;
    //protected $quote_info;
    protected $userFactory;
    protected $_pdfCrowd;
    public function __construct(
    Context $context,
    MagentoFrameworkAppResponseHttpFileFactory $fileFactory,
    MagentoFrameworkFilesystem $filesystem,
    MagentoBackendModelAuthSession $authSession,
    PdfCrowd $pdfCrowd,
    DirectoryList $directory_list,
    MagentoUserModelUserFactory $userFactory
    ) {
    parent::__construct($context);
    $this->_pdfCrowd = $pdfCrowd;
    $this->fileFactory = $fileFactory;
    $this->authSession = $authSession;
    $this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
    $this->directory_list = $directory_list;
    $this->userFactory = $userFactory;
    }

    public function execute()
    {
    if($this->authSession->isLoggedIn()){

    $id = $this->getRequest()->getParam('id');

    $client = $this->_pdfCrowd->createPdf("MYUSERNAME", "xxxxxxx-KEY");

    // set HTTP response headers
    $pdf = $client->convertHtml($this->getHtmlForPdf($id));

    header("Content-Type: application/pdf");
    header("Cache-Control: no-cache");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=commercialsale-".$id.".pdf");

    echo $pdf;
    }
    }
    }


    I have replaced method name and called with dependency injection.



    <?php

    namespace CompanyModuleHelper;

    class PdfCrowd {
    //
    // Pdfcrowd constructor.
    //
    // $username - your username at Pdfcrowd
    // $apikey - your API key
    // $hostname - API hostname, defaults to pdfcrowd.com
    //
    function createPdf($username, $apikey, $hostname=null){
    if ($hostname)
    $this->hostname = $hostname;
    else
    $this->hostname = self::$api_host;
    $this->useSSL(false);
    $this->fields = array(
    'username' => $username,
    'key' => $apikey,
    'pdf_scaling_factor' => 1,
    'html_zoom' => 200);
    $this->proxy_name = null;
    $this->proxy_port = null;
    $this->proxy_username = "";
    $this->proxy_password = "";

    $this->user_agent = "pdfcrowd_php_client_".self::$client_version."_(http://pdfcrowd.com)";
    }
    }
    ?>





    share|improve this answer
























    • This error. Class CompanyModuleHelperPdfCrowd does not exist in [CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor]

      – Hardik
      Jun 8 '18 at 13:38













    • please run this php bin/magento setup:di:compile then php bin/magento cache:flush

      – kunj
      Jun 8 '18 at 14:22
















    0














    Try this:



    <?php

    namespace CompanyModuleControllerAdminhtmlQuote;

    use MagentoFrameworkAppActionAction;
    use MagentoFrameworkAppActionContext;
    use MagentoFrameworkAppFilesystemDirectoryList as DirectoryList;

    use CompanyModuleHelperPdfCrowd;

    class QuotePdf extends Action
    {
    /**
    * @var MagentoFrameworkAppResponseHttpFileFactory
    */
    protected $fileFactory;
    protected $_mediaDirectory;
    protected $directory_list;

    protected $dompdfFactory;
    protected $layoutFactory;

    protected $authSession;
    //protected $quote_info;
    protected $userFactory;
    protected $_pdfCrowd;
    public function __construct(
    Context $context,
    MagentoFrameworkAppResponseHttpFileFactory $fileFactory,
    MagentoFrameworkFilesystem $filesystem,
    MagentoBackendModelAuthSession $authSession,
    PdfCrowd $pdfCrowd,
    DirectoryList $directory_list,
    MagentoUserModelUserFactory $userFactory
    ) {
    parent::__construct($context);
    $this->_pdfCrowd = $pdfCrowd;
    $this->fileFactory = $fileFactory;
    $this->authSession = $authSession;
    $this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
    $this->directory_list = $directory_list;
    $this->userFactory = $userFactory;
    }

    public function execute()
    {
    if($this->authSession->isLoggedIn()){

    $id = $this->getRequest()->getParam('id');

    $client = $this->_pdfCrowd->createPdf("MYUSERNAME", "xxxxxxx-KEY");

    // set HTTP response headers
    $pdf = $client->convertHtml($this->getHtmlForPdf($id));

    header("Content-Type: application/pdf");
    header("Cache-Control: no-cache");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=commercialsale-".$id.".pdf");

    echo $pdf;
    }
    }
    }


    I have replaced method name and called with dependency injection.



    <?php

    namespace CompanyModuleHelper;

    class PdfCrowd {
    //
    // Pdfcrowd constructor.
    //
    // $username - your username at Pdfcrowd
    // $apikey - your API key
    // $hostname - API hostname, defaults to pdfcrowd.com
    //
    function createPdf($username, $apikey, $hostname=null){
    if ($hostname)
    $this->hostname = $hostname;
    else
    $this->hostname = self::$api_host;
    $this->useSSL(false);
    $this->fields = array(
    'username' => $username,
    'key' => $apikey,
    'pdf_scaling_factor' => 1,
    'html_zoom' => 200);
    $this->proxy_name = null;
    $this->proxy_port = null;
    $this->proxy_username = "";
    $this->proxy_password = "";

    $this->user_agent = "pdfcrowd_php_client_".self::$client_version."_(http://pdfcrowd.com)";
    }
    }
    ?>





    share|improve this answer
























    • This error. Class CompanyModuleHelperPdfCrowd does not exist in [CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor]

      – Hardik
      Jun 8 '18 at 13:38













    • please run this php bin/magento setup:di:compile then php bin/magento cache:flush

      – kunj
      Jun 8 '18 at 14:22














    0












    0








    0







    Try this:



    <?php

    namespace CompanyModuleControllerAdminhtmlQuote;

    use MagentoFrameworkAppActionAction;
    use MagentoFrameworkAppActionContext;
    use MagentoFrameworkAppFilesystemDirectoryList as DirectoryList;

    use CompanyModuleHelperPdfCrowd;

    class QuotePdf extends Action
    {
    /**
    * @var MagentoFrameworkAppResponseHttpFileFactory
    */
    protected $fileFactory;
    protected $_mediaDirectory;
    protected $directory_list;

    protected $dompdfFactory;
    protected $layoutFactory;

    protected $authSession;
    //protected $quote_info;
    protected $userFactory;
    protected $_pdfCrowd;
    public function __construct(
    Context $context,
    MagentoFrameworkAppResponseHttpFileFactory $fileFactory,
    MagentoFrameworkFilesystem $filesystem,
    MagentoBackendModelAuthSession $authSession,
    PdfCrowd $pdfCrowd,
    DirectoryList $directory_list,
    MagentoUserModelUserFactory $userFactory
    ) {
    parent::__construct($context);
    $this->_pdfCrowd = $pdfCrowd;
    $this->fileFactory = $fileFactory;
    $this->authSession = $authSession;
    $this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
    $this->directory_list = $directory_list;
    $this->userFactory = $userFactory;
    }

    public function execute()
    {
    if($this->authSession->isLoggedIn()){

    $id = $this->getRequest()->getParam('id');

    $client = $this->_pdfCrowd->createPdf("MYUSERNAME", "xxxxxxx-KEY");

    // set HTTP response headers
    $pdf = $client->convertHtml($this->getHtmlForPdf($id));

    header("Content-Type: application/pdf");
    header("Cache-Control: no-cache");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=commercialsale-".$id.".pdf");

    echo $pdf;
    }
    }
    }


    I have replaced method name and called with dependency injection.



    <?php

    namespace CompanyModuleHelper;

    class PdfCrowd {
    //
    // Pdfcrowd constructor.
    //
    // $username - your username at Pdfcrowd
    // $apikey - your API key
    // $hostname - API hostname, defaults to pdfcrowd.com
    //
    function createPdf($username, $apikey, $hostname=null){
    if ($hostname)
    $this->hostname = $hostname;
    else
    $this->hostname = self::$api_host;
    $this->useSSL(false);
    $this->fields = array(
    'username' => $username,
    'key' => $apikey,
    'pdf_scaling_factor' => 1,
    'html_zoom' => 200);
    $this->proxy_name = null;
    $this->proxy_port = null;
    $this->proxy_username = "";
    $this->proxy_password = "";

    $this->user_agent = "pdfcrowd_php_client_".self::$client_version."_(http://pdfcrowd.com)";
    }
    }
    ?>





    share|improve this answer













    Try this:



    <?php

    namespace CompanyModuleControllerAdminhtmlQuote;

    use MagentoFrameworkAppActionAction;
    use MagentoFrameworkAppActionContext;
    use MagentoFrameworkAppFilesystemDirectoryList as DirectoryList;

    use CompanyModuleHelperPdfCrowd;

    class QuotePdf extends Action
    {
    /**
    * @var MagentoFrameworkAppResponseHttpFileFactory
    */
    protected $fileFactory;
    protected $_mediaDirectory;
    protected $directory_list;

    protected $dompdfFactory;
    protected $layoutFactory;

    protected $authSession;
    //protected $quote_info;
    protected $userFactory;
    protected $_pdfCrowd;
    public function __construct(
    Context $context,
    MagentoFrameworkAppResponseHttpFileFactory $fileFactory,
    MagentoFrameworkFilesystem $filesystem,
    MagentoBackendModelAuthSession $authSession,
    PdfCrowd $pdfCrowd,
    DirectoryList $directory_list,
    MagentoUserModelUserFactory $userFactory
    ) {
    parent::__construct($context);
    $this->_pdfCrowd = $pdfCrowd;
    $this->fileFactory = $fileFactory;
    $this->authSession = $authSession;
    $this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
    $this->directory_list = $directory_list;
    $this->userFactory = $userFactory;
    }

    public function execute()
    {
    if($this->authSession->isLoggedIn()){

    $id = $this->getRequest()->getParam('id');

    $client = $this->_pdfCrowd->createPdf("MYUSERNAME", "xxxxxxx-KEY");

    // set HTTP response headers
    $pdf = $client->convertHtml($this->getHtmlForPdf($id));

    header("Content-Type: application/pdf");
    header("Cache-Control: no-cache");
    header("Accept-Ranges: none");
    header("Content-Disposition: attachment; filename=commercialsale-".$id.".pdf");

    echo $pdf;
    }
    }
    }


    I have replaced method name and called with dependency injection.



    <?php

    namespace CompanyModuleHelper;

    class PdfCrowd {
    //
    // Pdfcrowd constructor.
    //
    // $username - your username at Pdfcrowd
    // $apikey - your API key
    // $hostname - API hostname, defaults to pdfcrowd.com
    //
    function createPdf($username, $apikey, $hostname=null){
    if ($hostname)
    $this->hostname = $hostname;
    else
    $this->hostname = self::$api_host;
    $this->useSSL(false);
    $this->fields = array(
    'username' => $username,
    'key' => $apikey,
    'pdf_scaling_factor' => 1,
    'html_zoom' => 200);
    $this->proxy_name = null;
    $this->proxy_port = null;
    $this->proxy_username = "";
    $this->proxy_password = "";

    $this->user_agent = "pdfcrowd_php_client_".self::$client_version."_(http://pdfcrowd.com)";
    }
    }
    ?>






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jun 8 '18 at 13:18









    kunjkunj

    2,6502423




    2,6502423













    • This error. Class CompanyModuleHelperPdfCrowd does not exist in [CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor]

      – Hardik
      Jun 8 '18 at 13:38













    • please run this php bin/magento setup:di:compile then php bin/magento cache:flush

      – kunj
      Jun 8 '18 at 14:22



















    • This error. Class CompanyModuleHelperPdfCrowd does not exist in [CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor]

      – Hardik
      Jun 8 '18 at 13:38













    • please run this php bin/magento setup:di:compile then php bin/magento cache:flush

      – kunj
      Jun 8 '18 at 14:22

















    This error. Class CompanyModuleHelperPdfCrowd does not exist in [CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor]

    – Hardik
    Jun 8 '18 at 13:38







    This error. Class CompanyModuleHelperPdfCrowd does not exist in [CompanyModuleControllerAdminhtmlQuoteQuotePdfInterceptor]

    – Hardik
    Jun 8 '18 at 13:38















    please run this php bin/magento setup:di:compile then php bin/magento cache:flush

    – kunj
    Jun 8 '18 at 14:22





    please run this php bin/magento setup:di:compile then php bin/magento cache:flush

    – kunj
    Jun 8 '18 at 14:22













    0














    Use below on your helper file:



    class PdfCrowd extends MagentoFrameworkAppHelperAbstractHelper{
    }


    instead of



    class PdfCrowd{
    }





    share|improve this answer




























      0














      Use below on your helper file:



      class PdfCrowd extends MagentoFrameworkAppHelperAbstractHelper{
      }


      instead of



      class PdfCrowd{
      }





      share|improve this answer


























        0












        0








        0







        Use below on your helper file:



        class PdfCrowd extends MagentoFrameworkAppHelperAbstractHelper{
        }


        instead of



        class PdfCrowd{
        }





        share|improve this answer













        Use below on your helper file:



        class PdfCrowd extends MagentoFrameworkAppHelperAbstractHelper{
        }


        instead of



        class PdfCrowd{
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 8 '18 at 14:24









        Sukumar GoraiSukumar Gorai

        6,8753729




        6,8753729






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f229214%2fmagento-2-fatal-error-uncaught-error-class-not-found%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            迭戈·戈丁...

            A phrase ”follow into" in a context The 2019 Stack Overflow Developer Survey Results Are...

            1960s short story making fun of James Bond-style spy fiction The 2019 Stack Overflow Developer...