php bin/magento setup:di:compile command throws Source class “-------” for “-------” generation does...












5















I have added a Repository interface in my Api directory and it's implementation in located under Models directory.



I have setup the preference for the interface in etc/di.xml.



When I run bin/magento setup:di:compile the following error is thrown in the console.




Source class "NamespaceModuleModelPostInterface" for
"NamespaceModuleModelPostRepository" generation does not exist.




I have no idea why the system is searching for "NamespaceModuleModelPostInterface" while I have mentioned clearly the location of the implementation class in di.xml.



Any suggestions are welcome with thanks !!



More Info:




When I remove the Repository implementation file i.e;
app/code/Namespace/Module/Model/PostRepository.php (imlpements
app/code/Namespace/Module/Api/PostRepositoryInterface.php), the error
disappears.



Also, when I rename the file from
app/code/Namespace/Module/Model/PostRepository.php to
app/code/Namespace/Module/Model/PostRepositoryy.php, the error
disappears.




Is there any conventions that needs to be followed while using Repositories ?










share|improve this question

























  • I get the same error and removing or renaming the file does not help. It's crazy.

    – Matt Cosentino
    Sep 18 '17 at 15:25
















5















I have added a Repository interface in my Api directory and it's implementation in located under Models directory.



I have setup the preference for the interface in etc/di.xml.



When I run bin/magento setup:di:compile the following error is thrown in the console.




Source class "NamespaceModuleModelPostInterface" for
"NamespaceModuleModelPostRepository" generation does not exist.




I have no idea why the system is searching for "NamespaceModuleModelPostInterface" while I have mentioned clearly the location of the implementation class in di.xml.



Any suggestions are welcome with thanks !!



More Info:




When I remove the Repository implementation file i.e;
app/code/Namespace/Module/Model/PostRepository.php (imlpements
app/code/Namespace/Module/Api/PostRepositoryInterface.php), the error
disappears.



Also, when I rename the file from
app/code/Namespace/Module/Model/PostRepository.php to
app/code/Namespace/Module/Model/PostRepositoryy.php, the error
disappears.




Is there any conventions that needs to be followed while using Repositories ?










share|improve this question

























  • I get the same error and removing or renaming the file does not help. It's crazy.

    – Matt Cosentino
    Sep 18 '17 at 15:25














5












5








5








I have added a Repository interface in my Api directory and it's implementation in located under Models directory.



I have setup the preference for the interface in etc/di.xml.



When I run bin/magento setup:di:compile the following error is thrown in the console.




Source class "NamespaceModuleModelPostInterface" for
"NamespaceModuleModelPostRepository" generation does not exist.




I have no idea why the system is searching for "NamespaceModuleModelPostInterface" while I have mentioned clearly the location of the implementation class in di.xml.



Any suggestions are welcome with thanks !!



More Info:




When I remove the Repository implementation file i.e;
app/code/Namespace/Module/Model/PostRepository.php (imlpements
app/code/Namespace/Module/Api/PostRepositoryInterface.php), the error
disappears.



Also, when I rename the file from
app/code/Namespace/Module/Model/PostRepository.php to
app/code/Namespace/Module/Model/PostRepositoryy.php, the error
disappears.




Is there any conventions that needs to be followed while using Repositories ?










share|improve this question
















I have added a Repository interface in my Api directory and it's implementation in located under Models directory.



I have setup the preference for the interface in etc/di.xml.



When I run bin/magento setup:di:compile the following error is thrown in the console.




Source class "NamespaceModuleModelPostInterface" for
"NamespaceModuleModelPostRepository" generation does not exist.




I have no idea why the system is searching for "NamespaceModuleModelPostInterface" while I have mentioned clearly the location of the implementation class in di.xml.



Any suggestions are welcome with thanks !!



More Info:




When I remove the Repository implementation file i.e;
app/code/Namespace/Module/Model/PostRepository.php (imlpements
app/code/Namespace/Module/Api/PostRepositoryInterface.php), the error
disappears.



Also, when I rename the file from
app/code/Namespace/Module/Model/PostRepository.php to
app/code/Namespace/Module/Model/PostRepositoryy.php, the error
disappears.




Is there any conventions that needs to be followed while using Repositories ?







magento-2.1






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 36 mins ago









Amit Naraniwal

56138




56138










asked Mar 22 '17 at 14:30









N. Karthic KannanN. Karthic Kannan

575415




575415













  • I get the same error and removing or renaming the file does not help. It's crazy.

    – Matt Cosentino
    Sep 18 '17 at 15:25



















  • I get the same error and removing or renaming the file does not help. It's crazy.

    – Matt Cosentino
    Sep 18 '17 at 15:25

















I get the same error and removing or renaming the file does not help. It's crazy.

– Matt Cosentino
Sep 18 '17 at 15:25





I get the same error and removing or renaming the file does not help. It's crazy.

– Matt Cosentino
Sep 18 '17 at 15:25










3 Answers
3






active

oldest

votes


















2














After a lot of Code analysis and Google searches, I found the fix for this problem. Adding the following to the di.xml fixed this issue.



<type name="MagentoFrameworkModelEntityRepositoryFactory">
<arguments>
<argument name="entities" xsi:type="array">
<item name="NamespaceModuleApiDataPostInterface" xsi:type="string">NamespaceModuleApiDataPostRepositoryInterface
</item>
</argument>
</arguments>
</type>





share|improve this answer































    0














    This is an old post now, but for anyone else that's still experiencing this, a fix that seems to work is rather than defining the repository interface as a use statement, add its fully qualified name, for example:



    use VendorModuleInterface;

    class MyClass implements Interface


    Becomes:



    class MyClass implements VendorModuleInterface


    This fixed this for us when compiling repositories on M2 2.2.3






    share|improve this answer































      0














      Remove var/generation and var/di folders
      Then try again with command



      php bin/magento setup:upgrade

      php bin/magento setup:di:compile

      php bin/magento setup:static-content:deploy





      share|improve this answer


























      • I have followed these steps and the error still appears.

        – N. Karthic Kannan
        Mar 23 '17 at 6:46











      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%2f165630%2fphp-bin-magento-setupdicompile-command-throws-source-class-for%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      After a lot of Code analysis and Google searches, I found the fix for this problem. Adding the following to the di.xml fixed this issue.



      <type name="MagentoFrameworkModelEntityRepositoryFactory">
      <arguments>
      <argument name="entities" xsi:type="array">
      <item name="NamespaceModuleApiDataPostInterface" xsi:type="string">NamespaceModuleApiDataPostRepositoryInterface
      </item>
      </argument>
      </arguments>
      </type>





      share|improve this answer




























        2














        After a lot of Code analysis and Google searches, I found the fix for this problem. Adding the following to the di.xml fixed this issue.



        <type name="MagentoFrameworkModelEntityRepositoryFactory">
        <arguments>
        <argument name="entities" xsi:type="array">
        <item name="NamespaceModuleApiDataPostInterface" xsi:type="string">NamespaceModuleApiDataPostRepositoryInterface
        </item>
        </argument>
        </arguments>
        </type>





        share|improve this answer


























          2












          2








          2







          After a lot of Code analysis and Google searches, I found the fix for this problem. Adding the following to the di.xml fixed this issue.



          <type name="MagentoFrameworkModelEntityRepositoryFactory">
          <arguments>
          <argument name="entities" xsi:type="array">
          <item name="NamespaceModuleApiDataPostInterface" xsi:type="string">NamespaceModuleApiDataPostRepositoryInterface
          </item>
          </argument>
          </arguments>
          </type>





          share|improve this answer













          After a lot of Code analysis and Google searches, I found the fix for this problem. Adding the following to the di.xml fixed this issue.



          <type name="MagentoFrameworkModelEntityRepositoryFactory">
          <arguments>
          <argument name="entities" xsi:type="array">
          <item name="NamespaceModuleApiDataPostInterface" xsi:type="string">NamespaceModuleApiDataPostRepositoryInterface
          </item>
          </argument>
          </arguments>
          </type>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 24 '17 at 7:07









          N. Karthic KannanN. Karthic Kannan

          575415




          575415

























              0














              This is an old post now, but for anyone else that's still experiencing this, a fix that seems to work is rather than defining the repository interface as a use statement, add its fully qualified name, for example:



              use VendorModuleInterface;

              class MyClass implements Interface


              Becomes:



              class MyClass implements VendorModuleInterface


              This fixed this for us when compiling repositories on M2 2.2.3






              share|improve this answer




























                0














                This is an old post now, but for anyone else that's still experiencing this, a fix that seems to work is rather than defining the repository interface as a use statement, add its fully qualified name, for example:



                use VendorModuleInterface;

                class MyClass implements Interface


                Becomes:



                class MyClass implements VendorModuleInterface


                This fixed this for us when compiling repositories on M2 2.2.3






                share|improve this answer


























                  0












                  0








                  0







                  This is an old post now, but for anyone else that's still experiencing this, a fix that seems to work is rather than defining the repository interface as a use statement, add its fully qualified name, for example:



                  use VendorModuleInterface;

                  class MyClass implements Interface


                  Becomes:



                  class MyClass implements VendorModuleInterface


                  This fixed this for us when compiling repositories on M2 2.2.3






                  share|improve this answer













                  This is an old post now, but for anyone else that's still experiencing this, a fix that seems to work is rather than defining the repository interface as a use statement, add its fully qualified name, for example:



                  use VendorModuleInterface;

                  class MyClass implements Interface


                  Becomes:



                  class MyClass implements VendorModuleInterface


                  This fixed this for us when compiling repositories on M2 2.2.3







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 18 '18 at 11:44









                  Daniel DoyleDaniel Doyle

                  11




                  11























                      0














                      Remove var/generation and var/di folders
                      Then try again with command



                      php bin/magento setup:upgrade

                      php bin/magento setup:di:compile

                      php bin/magento setup:static-content:deploy





                      share|improve this answer


























                      • I have followed these steps and the error still appears.

                        – N. Karthic Kannan
                        Mar 23 '17 at 6:46
















                      0














                      Remove var/generation and var/di folders
                      Then try again with command



                      php bin/magento setup:upgrade

                      php bin/magento setup:di:compile

                      php bin/magento setup:static-content:deploy





                      share|improve this answer


























                      • I have followed these steps and the error still appears.

                        – N. Karthic Kannan
                        Mar 23 '17 at 6:46














                      0












                      0








                      0







                      Remove var/generation and var/di folders
                      Then try again with command



                      php bin/magento setup:upgrade

                      php bin/magento setup:di:compile

                      php bin/magento setup:static-content:deploy





                      share|improve this answer















                      Remove var/generation and var/di folders
                      Then try again with command



                      php bin/magento setup:upgrade

                      php bin/magento setup:di:compile

                      php bin/magento setup:static-content:deploy






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 23 hours ago









                      Ashish Viradiya

                      774822




                      774822










                      answered Mar 22 '17 at 16:21









                      RizwanRizwan

                      790326




                      790326













                      • I have followed these steps and the error still appears.

                        – N. Karthic Kannan
                        Mar 23 '17 at 6:46



















                      • I have followed these steps and the error still appears.

                        – N. Karthic Kannan
                        Mar 23 '17 at 6:46

















                      I have followed these steps and the error still appears.

                      – N. Karthic Kannan
                      Mar 23 '17 at 6:46





                      I have followed these steps and the error still appears.

                      – N. Karthic Kannan
                      Mar 23 '17 at 6:46


















                      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%2f165630%2fphp-bin-magento-setupdicompile-command-throws-source-class-for%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

                      Magento 2 controller redirect on button click in phtml file

                      Polycentropodidae