Using the same library within another Zend Framework 3 application
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
add a comment |
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
add a comment |
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
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
zend-framework frameworks zend-framework3
edited Nov 14 '18 at 12:37
David McDonnell
asked Nov 13 '18 at 16:29
David McDonnellDavid McDonnell
34
34
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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