Magento 2.2 - Problem with Helper class not found in custom module





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







2















I'm creating a payment module and I'm having a curious problem. I started by creating the module inside the app/code/Vendorname/Payment folder for convenience. It is not yet complete, but the system.xml settings options were working correctly and all configurations can be changes in admin.



One of the system.xml fields has a custom source model, where I used the module's helper and everything was ok.



So for now I created a repository in github, and put the module so that I could use the composer (and remove it from the app/code folder). I did this by thinking of leaving the module in a way that can be replicated in other stores, so with better distribution way.



However after installing with composer (and after did all upgrade and compile di things on shell), when accessing the configuration section in the admin panel I always get the error below.



Fatal error: Uncaught Error: Class 'VendornamePaymentHelperData' not found in /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:111 
Stack trace:
#0 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): MagentoFrameworkObjectManagerFactoryAbstractFactory->createObject('Vendorname\Payment\...', Array)
#1 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): MagentoFrameworkObjectManagerFactoryCompiled->create('Vendorname\Payment\...')
#2 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): MagentoFrameworkObjectManagerFactoryCompiled->get('Vendorname\Payment\...')
#3 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): MagentoFrameworkObjectManagerFactoryCompiled->create('Vendorname\Payment\...')
#4 /Users/username/sites/vendornamem2/vendor/magento/module-config/Model/Config/SourceFactory.php(37): MagentoFr in /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 111


Apparently the helper is not being found in my custom field class. They follow the source model of the field in question (Mode).



<?php
namespace VendornamePaymentModelSource;

class Mode implements MagentoFrameworkOptionArrayInterface
{
/**
* @var VendornamePaymentHelperData
*/
protected $_paymentHelper;

/**
* Mode constructor.
*
* @param VendornamePaymentHelperData $paymentHelper
*/
public function __construct(
VendornamePaymentHelperData $paymentHelper
) {
$this->_paymentHelper = $paymentHelper;
}

public function toOptionArray()
{
/** @var VendornamePaymentHelperData $VendornameHelper */
$VendornameHelper = $this->_paymentHelper;
return [
['value' => $VendornameHelper::ONPAGE_MODE, 'label' => 'On Page'],
['value' => $VendornameHelper::IFRAME_MODE, 'label' => 'Iframe'],
['value' => $VendornameHelper::REDIRECT_MODE, 'label' => 'Redirect']
];
}
}


The error came after simply by migrating the code from the app/code folder to the composer. Not even one character was modified in the process. Is there any helper mapping that needs to be done?










share|improve this question































    2















    I'm creating a payment module and I'm having a curious problem. I started by creating the module inside the app/code/Vendorname/Payment folder for convenience. It is not yet complete, but the system.xml settings options were working correctly and all configurations can be changes in admin.



    One of the system.xml fields has a custom source model, where I used the module's helper and everything was ok.



    So for now I created a repository in github, and put the module so that I could use the composer (and remove it from the app/code folder). I did this by thinking of leaving the module in a way that can be replicated in other stores, so with better distribution way.



    However after installing with composer (and after did all upgrade and compile di things on shell), when accessing the configuration section in the admin panel I always get the error below.



    Fatal error: Uncaught Error: Class 'VendornamePaymentHelperData' not found in /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:111 
    Stack trace:
    #0 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): MagentoFrameworkObjectManagerFactoryAbstractFactory->createObject('Vendorname\Payment\...', Array)
    #1 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): MagentoFrameworkObjectManagerFactoryCompiled->create('Vendorname\Payment\...')
    #2 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): MagentoFrameworkObjectManagerFactoryCompiled->get('Vendorname\Payment\...')
    #3 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): MagentoFrameworkObjectManagerFactoryCompiled->create('Vendorname\Payment\...')
    #4 /Users/username/sites/vendornamem2/vendor/magento/module-config/Model/Config/SourceFactory.php(37): MagentoFr in /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 111


    Apparently the helper is not being found in my custom field class. They follow the source model of the field in question (Mode).



    <?php
    namespace VendornamePaymentModelSource;

    class Mode implements MagentoFrameworkOptionArrayInterface
    {
    /**
    * @var VendornamePaymentHelperData
    */
    protected $_paymentHelper;

    /**
    * Mode constructor.
    *
    * @param VendornamePaymentHelperData $paymentHelper
    */
    public function __construct(
    VendornamePaymentHelperData $paymentHelper
    ) {
    $this->_paymentHelper = $paymentHelper;
    }

    public function toOptionArray()
    {
    /** @var VendornamePaymentHelperData $VendornameHelper */
    $VendornameHelper = $this->_paymentHelper;
    return [
    ['value' => $VendornameHelper::ONPAGE_MODE, 'label' => 'On Page'],
    ['value' => $VendornameHelper::IFRAME_MODE, 'label' => 'Iframe'],
    ['value' => $VendornameHelper::REDIRECT_MODE, 'label' => 'Redirect']
    ];
    }
    }


    The error came after simply by migrating the code from the app/code folder to the composer. Not even one character was modified in the process. Is there any helper mapping that needs to be done?










    share|improve this question



























      2












      2








      2








      I'm creating a payment module and I'm having a curious problem. I started by creating the module inside the app/code/Vendorname/Payment folder for convenience. It is not yet complete, but the system.xml settings options were working correctly and all configurations can be changes in admin.



      One of the system.xml fields has a custom source model, where I used the module's helper and everything was ok.



      So for now I created a repository in github, and put the module so that I could use the composer (and remove it from the app/code folder). I did this by thinking of leaving the module in a way that can be replicated in other stores, so with better distribution way.



      However after installing with composer (and after did all upgrade and compile di things on shell), when accessing the configuration section in the admin panel I always get the error below.



      Fatal error: Uncaught Error: Class 'VendornamePaymentHelperData' not found in /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:111 
      Stack trace:
      #0 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): MagentoFrameworkObjectManagerFactoryAbstractFactory->createObject('Vendorname\Payment\...', Array)
      #1 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): MagentoFrameworkObjectManagerFactoryCompiled->create('Vendorname\Payment\...')
      #2 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): MagentoFrameworkObjectManagerFactoryCompiled->get('Vendorname\Payment\...')
      #3 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): MagentoFrameworkObjectManagerFactoryCompiled->create('Vendorname\Payment\...')
      #4 /Users/username/sites/vendornamem2/vendor/magento/module-config/Model/Config/SourceFactory.php(37): MagentoFr in /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 111


      Apparently the helper is not being found in my custom field class. They follow the source model of the field in question (Mode).



      <?php
      namespace VendornamePaymentModelSource;

      class Mode implements MagentoFrameworkOptionArrayInterface
      {
      /**
      * @var VendornamePaymentHelperData
      */
      protected $_paymentHelper;

      /**
      * Mode constructor.
      *
      * @param VendornamePaymentHelperData $paymentHelper
      */
      public function __construct(
      VendornamePaymentHelperData $paymentHelper
      ) {
      $this->_paymentHelper = $paymentHelper;
      }

      public function toOptionArray()
      {
      /** @var VendornamePaymentHelperData $VendornameHelper */
      $VendornameHelper = $this->_paymentHelper;
      return [
      ['value' => $VendornameHelper::ONPAGE_MODE, 'label' => 'On Page'],
      ['value' => $VendornameHelper::IFRAME_MODE, 'label' => 'Iframe'],
      ['value' => $VendornameHelper::REDIRECT_MODE, 'label' => 'Redirect']
      ];
      }
      }


      The error came after simply by migrating the code from the app/code folder to the composer. Not even one character was modified in the process. Is there any helper mapping that needs to be done?










      share|improve this question
















      I'm creating a payment module and I'm having a curious problem. I started by creating the module inside the app/code/Vendorname/Payment folder for convenience. It is not yet complete, but the system.xml settings options were working correctly and all configurations can be changes in admin.



      One of the system.xml fields has a custom source model, where I used the module's helper and everything was ok.



      So for now I created a repository in github, and put the module so that I could use the composer (and remove it from the app/code folder). I did this by thinking of leaving the module in a way that can be replicated in other stores, so with better distribution way.



      However after installing with composer (and after did all upgrade and compile di things on shell), when accessing the configuration section in the admin panel I always get the error below.



      Fatal error: Uncaught Error: Class 'VendornamePaymentHelperData' not found in /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:111 
      Stack trace:
      #0 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): MagentoFrameworkObjectManagerFactoryAbstractFactory->createObject('Vendorname\Payment\...', Array)
      #1 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): MagentoFrameworkObjectManagerFactoryCompiled->create('Vendorname\Payment\...')
      #2 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): MagentoFrameworkObjectManagerFactoryCompiled->get('Vendorname\Payment\...')
      #3 /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/ObjectManager.php(70): MagentoFrameworkObjectManagerFactoryCompiled->create('Vendorname\Payment\...')
      #4 /Users/username/sites/vendornamem2/vendor/magento/module-config/Model/Config/SourceFactory.php(37): MagentoFr in /Users/username/sites/vendornamem2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 111


      Apparently the helper is not being found in my custom field class. They follow the source model of the field in question (Mode).



      <?php
      namespace VendornamePaymentModelSource;

      class Mode implements MagentoFrameworkOptionArrayInterface
      {
      /**
      * @var VendornamePaymentHelperData
      */
      protected $_paymentHelper;

      /**
      * Mode constructor.
      *
      * @param VendornamePaymentHelperData $paymentHelper
      */
      public function __construct(
      VendornamePaymentHelperData $paymentHelper
      ) {
      $this->_paymentHelper = $paymentHelper;
      }

      public function toOptionArray()
      {
      /** @var VendornamePaymentHelperData $VendornameHelper */
      $VendornameHelper = $this->_paymentHelper;
      return [
      ['value' => $VendornameHelper::ONPAGE_MODE, 'label' => 'On Page'],
      ['value' => $VendornameHelper::IFRAME_MODE, 'label' => 'Iframe'],
      ['value' => $VendornameHelper::REDIRECT_MODE, 'label' => 'Redirect']
      ];
      }
      }


      The error came after simply by migrating the code from the app/code folder to the composer. Not even one character was modified in the process. Is there any helper mapping that needs to be done?







      magento2 module magento2.2 extensions helper






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago







      Denis Spalenza

















      asked 2 days ago









      Denis SpalenzaDenis Spalenza

      1,1381126




      1,1381126






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I got it.



          I forgot map folder VendornamePayment on composer.json (psr-4 node). I added the following code and it works.



          "autoload": {
          "files": [
          "registration.php"
          ],
          "psr-4": {
          "Vendorname\Payment\": ""
          }
          }





          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%2f269053%2fmagento-2-2-problem-with-helper-class-not-found-in-custom-module%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I got it.



            I forgot map folder VendornamePayment on composer.json (psr-4 node). I added the following code and it works.



            "autoload": {
            "files": [
            "registration.php"
            ],
            "psr-4": {
            "Vendorname\Payment\": ""
            }
            }





            share|improve this answer




























              0














              I got it.



              I forgot map folder VendornamePayment on composer.json (psr-4 node). I added the following code and it works.



              "autoload": {
              "files": [
              "registration.php"
              ],
              "psr-4": {
              "Vendorname\Payment\": ""
              }
              }





              share|improve this answer


























                0












                0








                0







                I got it.



                I forgot map folder VendornamePayment on composer.json (psr-4 node). I added the following code and it works.



                "autoload": {
                "files": [
                "registration.php"
                ],
                "psr-4": {
                "Vendorname\Payment\": ""
                }
                }





                share|improve this answer













                I got it.



                I forgot map folder VendornamePayment on composer.json (psr-4 node). I added the following code and it works.



                "autoload": {
                "files": [
                "registration.php"
                ],
                "psr-4": {
                "Vendorname\Payment\": ""
                }
                }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 days ago









                Denis SpalenzaDenis Spalenza

                1,1381126




                1,1381126






























                    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%2f269053%2fmagento-2-2-problem-with-helper-class-not-found-in-custom-module%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

                    What other Star Trek series did the main TNG cast show up in?

                    Berlina muro

                    Berlina aerponto