Using the same library within another Zend Framework 3 application












0















I've recently started using zend framework 3 for work; and was asked about the possibility of using the same library files within another application, or project.



The application folder 'manufactoring' contains all expected folders within a zf3 structure, such as modules, library, etc.



The question is: can you refer to the library files within 'manufactoring' within another application/project?



This would reduce code duplication.



I have tried answers to other questions on Stack Overflow; however they related to files within the same project.



I was able to link and execute using include or require, which allowed variables to be defined, or functions to be called from a source outside the application/project; however for my use I needed to define a new class, and this method did not work for that purpose.



Any insight would be greatly appreciated.



EDIT: I found this answer from another stackoverflow question: https://stackoverflow.com/a/3272684/10647325 which suggests a solution I am aiming for. This example has a common folder at the same level as the application folders, which contains libraries which can be linked to application folders.



EDIT: I've also tried changing the library path on composer.json. This worked after running composer dump-autoload for migration.










share|improve this question





























    0















    I've recently started using zend framework 3 for work; and was asked about the possibility of using the same library files within another application, or project.



    The application folder 'manufactoring' contains all expected folders within a zf3 structure, such as modules, library, etc.



    The question is: can you refer to the library files within 'manufactoring' within another application/project?



    This would reduce code duplication.



    I have tried answers to other questions on Stack Overflow; however they related to files within the same project.



    I was able to link and execute using include or require, which allowed variables to be defined, or functions to be called from a source outside the application/project; however for my use I needed to define a new class, and this method did not work for that purpose.



    Any insight would be greatly appreciated.



    EDIT: I found this answer from another stackoverflow question: https://stackoverflow.com/a/3272684/10647325 which suggests a solution I am aiming for. This example has a common folder at the same level as the application folders, which contains libraries which can be linked to application folders.



    EDIT: I've also tried changing the library path on composer.json. This worked after running composer dump-autoload for migration.










    share|improve this question



























      0












      0








      0








      I've recently started using zend framework 3 for work; and was asked about the possibility of using the same library files within another application, or project.



      The application folder 'manufactoring' contains all expected folders within a zf3 structure, such as modules, library, etc.



      The question is: can you refer to the library files within 'manufactoring' within another application/project?



      This would reduce code duplication.



      I have tried answers to other questions on Stack Overflow; however they related to files within the same project.



      I was able to link and execute using include or require, which allowed variables to be defined, or functions to be called from a source outside the application/project; however for my use I needed to define a new class, and this method did not work for that purpose.



      Any insight would be greatly appreciated.



      EDIT: I found this answer from another stackoverflow question: https://stackoverflow.com/a/3272684/10647325 which suggests a solution I am aiming for. This example has a common folder at the same level as the application folders, which contains libraries which can be linked to application folders.



      EDIT: I've also tried changing the library path on composer.json. This worked after running composer dump-autoload for migration.










      share|improve this question
















      I've recently started using zend framework 3 for work; and was asked about the possibility of using the same library files within another application, or project.



      The application folder 'manufactoring' contains all expected folders within a zf3 structure, such as modules, library, etc.



      The question is: can you refer to the library files within 'manufactoring' within another application/project?



      This would reduce code duplication.



      I have tried answers to other questions on Stack Overflow; however they related to files within the same project.



      I was able to link and execute using include or require, which allowed variables to be defined, or functions to be called from a source outside the application/project; however for my use I needed to define a new class, and this method did not work for that purpose.



      Any insight would be greatly appreciated.



      EDIT: I found this answer from another stackoverflow question: https://stackoverflow.com/a/3272684/10647325 which suggests a solution I am aiming for. This example has a common folder at the same level as the application folders, which contains libraries which can be linked to application folders.



      EDIT: I've also tried changing the library path on composer.json. This worked after running composer dump-autoload for migration.







      zend-framework frameworks zend-framework3






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 12:37







      David McDonnell

















      asked Nov 13 '18 at 16:29









      David McDonnellDavid McDonnell

      34




      34
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Modules are autoloaded from vendor as well as module, so you'd split the module with code you want to share out into its own repository and then install it using composer in both applications in the same way as you would any other PHP library.






          share|improve this answer


























          • If the file is updated, will it update for both applications; or will it have to be installed using composer each time a change is made?

            – David McDonnell
            Nov 14 '18 at 10:58











          • There are a few different ways to set it up locally (symlinks, docker volumes) but it's a while since I did it so I'm not sure what's best these days.

            – Tim Fountain
            Nov 14 '18 at 12:53











          • Thanks for your help Tim. I found a solution by changing the path on composer.json.

            – David McDonnell
            Nov 14 '18 at 13:44











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fstackoverflow.com%2fquestions%2f53285448%2fusing-the-same-library-within-another-zend-framework-3-application%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









          1














          Modules are autoloaded from vendor as well as module, so you'd split the module with code you want to share out into its own repository and then install it using composer in both applications in the same way as you would any other PHP library.






          share|improve this answer


























          • If the file is updated, will it update for both applications; or will it have to be installed using composer each time a change is made?

            – David McDonnell
            Nov 14 '18 at 10:58











          • There are a few different ways to set it up locally (symlinks, docker volumes) but it's a while since I did it so I'm not sure what's best these days.

            – Tim Fountain
            Nov 14 '18 at 12:53











          • Thanks for your help Tim. I found a solution by changing the path on composer.json.

            – David McDonnell
            Nov 14 '18 at 13:44
















          1














          Modules are autoloaded from vendor as well as module, so you'd split the module with code you want to share out into its own repository and then install it using composer in both applications in the same way as you would any other PHP library.






          share|improve this answer


























          • If the file is updated, will it update for both applications; or will it have to be installed using composer each time a change is made?

            – David McDonnell
            Nov 14 '18 at 10:58











          • There are a few different ways to set it up locally (symlinks, docker volumes) but it's a while since I did it so I'm not sure what's best these days.

            – Tim Fountain
            Nov 14 '18 at 12:53











          • Thanks for your help Tim. I found a solution by changing the path on composer.json.

            – David McDonnell
            Nov 14 '18 at 13:44














          1












          1








          1







          Modules are autoloaded from vendor as well as module, so you'd split the module with code you want to share out into its own repository and then install it using composer in both applications in the same way as you would any other PHP library.






          share|improve this answer















          Modules are autoloaded from vendor as well as module, so you'd split the module with code you want to share out into its own repository and then install it using composer in both applications in the same way as you would any other PHP library.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '18 at 21:11

























          answered Nov 13 '18 at 17:07









          Tim FountainTim Fountain

          30.7k53364




          30.7k53364













          • If the file is updated, will it update for both applications; or will it have to be installed using composer each time a change is made?

            – David McDonnell
            Nov 14 '18 at 10:58











          • There are a few different ways to set it up locally (symlinks, docker volumes) but it's a while since I did it so I'm not sure what's best these days.

            – Tim Fountain
            Nov 14 '18 at 12:53











          • Thanks for your help Tim. I found a solution by changing the path on composer.json.

            – David McDonnell
            Nov 14 '18 at 13:44



















          • If the file is updated, will it update for both applications; or will it have to be installed using composer each time a change is made?

            – David McDonnell
            Nov 14 '18 at 10:58











          • There are a few different ways to set it up locally (symlinks, docker volumes) but it's a while since I did it so I'm not sure what's best these days.

            – Tim Fountain
            Nov 14 '18 at 12:53











          • Thanks for your help Tim. I found a solution by changing the path on composer.json.

            – David McDonnell
            Nov 14 '18 at 13:44

















          If the file is updated, will it update for both applications; or will it have to be installed using composer each time a change is made?

          – David McDonnell
          Nov 14 '18 at 10:58





          If the file is updated, will it update for both applications; or will it have to be installed using composer each time a change is made?

          – David McDonnell
          Nov 14 '18 at 10:58













          There are a few different ways to set it up locally (symlinks, docker volumes) but it's a while since I did it so I'm not sure what's best these days.

          – Tim Fountain
          Nov 14 '18 at 12:53





          There are a few different ways to set it up locally (symlinks, docker volumes) but it's a while since I did it so I'm not sure what's best these days.

          – Tim Fountain
          Nov 14 '18 at 12:53













          Thanks for your help Tim. I found a solution by changing the path on composer.json.

          – David McDonnell
          Nov 14 '18 at 13:44





          Thanks for your help Tim. I found a solution by changing the path on composer.json.

          – David McDonnell
          Nov 14 '18 at 13:44


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f53285448%2fusing-the-same-library-within-another-zend-framework-3-application%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

          Coverage of Google Street View

          Full-time equivalent

          Surfing