-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename app/code to app/modules #357
Comments
👍 |
Internally it's already named |
👍 |
👍 :-) |
👍 |
1 similar comment
👍 |
+1 |
2 similar comments
👍 |
👍 |
It maybe better to rename the "app/modules" in the "vendor"? |
I support @kandy's suggestion - currently I do not see a reason to use the |
There was a big proposed directory structure change that did not make it before dev beta - too big/risky. One of the challenges at present is all modules are located by looking for app/code///etc/module.xml (I think). So all modules need to be under the same directory. With the new config.php approach (the list of modules is created by setup script, not at runtime) one idea being played with was to include the path name of each module root directory in config.php as well. Then modules could be located in different places more easily without extra overhead per http request. (There would be more overhead when setup is run, but that does not matter so much.) That would make it easier to put modules under app/code (or better app/modules) as well as vendor/. Oh, themes into a 'themes' directory instead of 'design' was another possible change. |
As @alankent mentioned we wanted to make this change (to /vendor) as part of dev beta and again we've looked at it for dev rc. Our struggle was to complete before the release date so the work was suspended. The complexities highlighted were a result of a single base path variable used throughout the code. When the modules were moved this required a new separate variable and we need to address each usage of base path to map to new structure. Not a difficult task but just proved very time consuming and the decision was made to not hold release for this change. I believe it was the primarily the tests that were highly impacted. |
+1 for modules under vendor. |
A concern that I heard voiced by several at the beta forum this week was that it is messy to package an extension into a repo in such a way that is compatible with composer. An example repo would ideally look something like this (subjective of course):
Currently I do not know of a way to map the contents of src/ into app/code/ using composer because composer wants to instead place the src/ directory itself into app/code/ like app/code/Vendor/Module/src/. Of course this can be resolved by using modman but TBH I'd like to see a solution that works without requiring modman since so much progress has been made to reduce the need for symlinks already. Of course I could just be missing some feature of composer that allows one to do this currently (aside from magento-composer-installer which would also be nice to not have to depend on). |
Hi @colinmollenhour,
But this is not the point. IMHO the real problem is that Magento requires to have modules in
I think that a better approach for loading modules is like it's done by Symfony. |
@mmenozzi, is there some crucial difference between Symfony approach and module bitmap in Thus currently you may change |
@mmenozzi Yes, this is why I stated at the end:
And thank you for mentioning the headache that comes with copying files.. IMO a good solution definitely does not involve duplicating files. I don't have a solution, but one idea just to get the point across is something like modifying the include path in the autoloader to expect an intermediate directory such that instead of loading My/Module/Model/Foo.php it becomes My/Module/src/Model/Foo.php. However, this breaks PSR convention and many will probably hate this idea because it is ugly.. I personally don't think modman is a bad solution, it just seems like this is a good opportunity to make it unnecessary. |
Hi @orlangur,
maybe I'm missing something but from what I can see the It's good to have modules automatically in You asked me if there is any crucial difference with Symfony... With Magento we have duplicated class files around the project (so the problems stated above) this doesn't happen with Symfony. So from a pragmatic point of view I answer: yes I think that there is at least one crucial difference. |
I would like to avoid such flexibility by convention over configuration. So, if there is no |
Why?
I already explained what are the differences between the two approaches. I don't know if these differences are crucial for you. Anyway I agree with your proposal of searching modules in Would you like that I work on PR for this? |
I would like to see modules, themes, lang packs under app or vendor. So can have local modules for your project without uploading to a repo. Problem was base directory (look at prev comments above). Please let us know where this effort occurs so can keep in sync with internal work |
To make the things simpler. If we have
Totally second this, also, would like to see |
We tried to allow downloaded modules to stay under vendor, but hit a problem with the code not being flexible enough. Architecturally, I personally like the main site getting the list of module directories from a configuration file created by the setup process. That is, let them be anywhere! Setup can have conventions like only looking in vendor and app/code (or app/modules) to create this config file. Scan back up the comment history for "The complexities highlighted were a result of a single base path variable used throughout the code" for more details. We want to do it, there is a plan, it just proved harder to do than expected. We trade effort off against business value when defining our internal backlog. |
Hi @alankent,
Yes it's true. Unfortunately, there are a lot of components in Magento Framework that assume that there is only one modules base directory. It's sufficient to search the usages of the
Ok I understand that, it's fine. Can you tell us when approximately this could be fixed? |
@davidalger, @mmenozzi thanks for the use case I was not aware of. Do not insist on "2." but just want to understand whether Didn't try to use So, site-specific code could be placed in separate repository and added via Composer (no need to register package - it is possible to specify repository URL) or placed in the same repository by adding exception to
It would be something similar to |
Not sure if any of you have seen it or not, but looks like @fooman is set on finding out how difficult this would be to work out over in #897 @orlangur hate to point out the semantics of it, but the term "vendor" itself implies that what's inside is provided by somebody, not built by self. Even if it's possible, why would we want to put custom code in vendor outside of avoiding the work of having the system support multiple locations for loading modules? |
Regarding the 'when' question, this one we want to do, but are not committing to do by GA. We try to slot in as much as we can, but the ROI on this one may mean it won't be done by GA. |
@davidalger I have started with some trials to see what would be involved. But did stop on this when I heard that some internal thinking was going on around this as well. The main problem at the moment seem to be the hardcoded tests. @alankent one thing which I hope you can commit to is to have the individual repositories of the Magento modules available online. My guess is that these already exist internally and already come with a composer.json file but I might be wrong. This would allow for further experimentation without having to actually check in the moved code under the vendor folder https://github.com/fooman/magento2/blob/modules-under-vendor/.gitignore#L48 |
Hi @fooman. The internal repository is the same structure as the external one. That is why its easier to process pull requests etc. That is, one big repo that we generate multiple packages from. While we are doing global edits and platform changes, this makes life easier. Commits are atomic across the platform. We don't have it with half the modules updated. Once the framework level is more stable (fewer global edits) then we will review the benefit of splitting per module. It makes complete sense, but it requires our internal test automation framework and practices to be adjusted. Its doable, but needs thought and planning. The question is how important before 2.0 ships (relative to other work). The main value appears to be post 2.0 - do you agree? Oh, and re-reading your request, I wanted to expand upon one point. There is the GIT repository and the Composer repository of released packages. We don't rely on GitHub to check out the modules - we use a snapshotted ZIP on the Magento master Composer repository. This is not definite, but it means we can package CE and EE modules in the one place, and paid extensions could go there as well. (We password protect the download area of course.) The EE git repo will not be public (!), so we must support ZIPs or similar for Composer downloads. I would prefer to do all Magento downloads the same way (for consistency), so the need for separate Git repos per modules may be lower as a result. |
Thanks for the insights - makes sense.
The pessimist in me says that if this is not done soon it would only happen for 3.0 - as deemed too risky / too big a change. Another reason to having the file structure finalised and no further planned changes sooner rather than later is that it would also help with documentation and generally developers only having to learn one new way of doing things. I am just picturing all those blog posts, stack exchange answers et all which become outdated and creating unnecessary confusion. |
One further thought - as the file structure will likely impact on the New Connect as well I think having this stabilised early would benefit that effort as well. |
I don't think Connect will be impacted because I believe Connect will host ZIPs of modules etc. We are not talking about changing the structure inside a module here, but rather the directory structure above modules (e.g. allow them in 'vendor' or 'app/modules'). The Composer packages themselves should not care which directory they are installed within. Would love to do sooner, but not sure internal timelines and priorities will allow this. The problem we hit when we tried was mainly in the test infrastructure being too dependent on the overall directory structure. We need to get that cleaned up first. A part of the issue is I believe the developer experience will be better with downloaded modules under 'vendor', but there are workarounds. That pushes it down the priority list. (Just being open here.) |
This issue was originally to rename app/code to app/modules, which is a good request in its own right. I have spun out the 'vendor' question into #1013. |
@alankent Thanks for keeping up with the thread! Going back to the original question though, I would like to "upvote" the recommendation to rename |
There seems to be two ways forward. Rename it (which requires all internal teams to commit all their work at the same time - causes lots of conflicts for work in progress otherwise), or support multiple directories for modules (which would allow app/code, app/modules, and vendor to all work at same time - making incremental migration easier). The former is up to @maksek as the main effort is scheduling (with some fixing of tests etc to adjust paths). The latter would depend on someone taking on #1013, which I am not sure the community is up to. |
git handles file relocations pretty well in my experience. This would definitely be a massive update, but I would be surprised if the upstream did not merge cleanly into the various branches in progress.. Would be worth testing I think. |
"Would be worth testing I think..." - now that is a candidate for understatement of the year! ;-) ;-) ;-) |
Sorry, in hindsight you were talking about testing how Git works, not testing the change itself. Sorry if my warped humor got the better of me. We have done a number of global changes in the past so have good experience with this. It was much easier to coordinate across teams and minimize checked out code - less time wasted all around. |
Hah! I meant would be worth testing to see if it is easy rather than assuming it will create lots of difficult conflicts and not trying.. But yeah.. testing is good. :) |
Lol. @alankent Your "warped humor" gave me a good laugh anyways! :) FWIW, as I understand from looking at the branch @fooman was experimenting on, the automated tests should work if the location is changed to app/modules and the correct constants updated. I'd PR it it to verify this, but figured if this is done it'd be better handled by the core team for stated reasons possibly necessitating internal cooperation between teams. Git is pretty good about renames… if you guys do test how easy it is, make sure you have the rename detection variable set high enough to allow for it to do rename checks on as many files as exist in the repo and then some. |
Ahh, thanks for chiming in @davidalger, I was not aware that there was git config that could affect the rename detection. Might be useful for everyone to observe before doing merges. |
Now that the developer RC is out and this has not been implemented, what are the future plans? |
Developer RC slows down making changes like this, but we are reviewing an internal idea around allowing multiple directories. If we can support multiple, then migration would be much easier (we could support the old and new directory trivially). So its not completely dead. |
Given that so many people seem to care about this, I'd recommend taking a look at PR #1206 and providing some feedback. |
[MX][Virtual Team] Public GitHub Issues, Bug Fixes
Thank you for your submission. We recently made some changes to the way we process GitHub submissions to more quickly identify and respond to core code issues. Feature Requests and Improvements should now be submitted to the new Magento 2 Feature Requests and Improvements forum (see details here). We are closing this GitHub ticket and have moved your request to the new forum. |
Fixed issue: - MAGETWO-57099: Order can't be placed via Payflow Pro payment method patch for 2.0.x - MAGETWO-57172: [GITHUB#4741] CC Model doesn't assigns cc data passed in additional_data field patch for 2.0.x
It seems that with all of the module components being moved into the app/code directories that the name "code" for this directory is far too specific and "modules" would be more appropriate.
The text was updated successfully, but these errors were encountered: