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
Extract some Piwik Core classes into reusable PHP libraries or reuse 3rd party libraries #6487
Comments
+1 for extracting some parts into standalone libraries, like we did for component-decompress or device-detector |
Ah yes forgot to mention device-detector that's a perfect example! Cool! |
Switching to 3rd party libs sounds good for smaller bits of code (like say Piwik\Ip or Piwik\Url). Other than making sure they don't change existing behaviour, we should be sure to examine the libraries carefully. They need to be up to our standards (ie, w/ tests, documentation, etc.). Perhaps each potential move to a 3rd party library could be a separate RFC. For larger chunks of code that could be replaced w/ a 3rd party lib, I think it would be good to move the code to a standalone repository, but have the code only be a well defined interface layer & default implementation that doesn't rely on a 3rd party lib. Then we can adapt any number of libraries for use w/ Piwik, w/o requiring to use them on the wide variety of environments Piwik must run in. Finally, regarding creating standalone repos: maybe we should have a list of possible refactorings? |
absolutely! Would prefer single issues for each "refactoring" rather than a list of possible refactorings. As @diosmosis said we should do this only for some libraries that do not change often etc. Otherwise we'll have a lot of pain with our submodules and/or we need to look for a different solution for submodules |
+1 But I don't see why we would need a default implementation if we are using a 3rd party lib. But I definitely agree with having an interface layer (with adapter classes when needed) so that we do not couple Piwik to a specific 3rd party lib.
Definitely agree. I just wanted, before jumping in to specific topics, to make sure we are all on the same page with the global direction. Then we can open issues for each refactoring that we are considering.
I don't see how the submodules will be a pain in those cases? We can just install the 3rd party libs with Composer. |
Depends on the specific use case, but since Piwik has to run on so many environments it may be the case that it is not possible for some users to use a 3rd party library. Or such users may not want to use the library/technology because it incurs extra work during setup. In such a case, we would have to provide a default implementation that uses base Piwik technologies (ie, PHP + MySQL). An example of this would be parallel job processing. The default implementations would of course be minimalist. |
I meant only the own libs we create repositories for. 3rd party libs are not a problem. Didn't see the part about default implementation. Don't think we'll need a default implementation in all cases either. An interface / bridge is enough. Eg for logs, events, ... we wouldn't have to provide a default implementation but the bridge to implement the interface etc. |
OK I see, I wasn't thinking of such scenarios, it makes total sense. In other simpler scenarios where it's just a simple and plain PHP lib we wouldn't need that though, e.g. what you said @tsteur:
|
Ah we would use Composer too for our own libs right? E.g. Piwik uses |
This makes sense to me. |
This will help keep our technical debt low and keep us agile. 👍 it's a great investment in the future of the platform to create re-usable components. And we should re-use Symfony (or other high quality) components as much as possible, when a similar package is available. |
Seems everyone is on the same page! We'll have more targeted issues for specific components/classes, let's close this one. |
This is a topic that has been discussed occasionally, let's open a RFC for that topic.
Piwik Core contains many classes that are not related to analytics. For example: event dispatching, MVC, logging, database, IP helpers, URL helpers, caching, filesystem, unzip… (I could go on)
Our options are:
Right now, Piwik is using the option 1 except for a few exceptions (Symfony Console, Twig, Zend_Db). I have also applied solution 2 for the new decompress component.
This RFC is about considering options 2 and 3.
This RFC is not about discussing every component and what should we do with it. It's on a more global level: what do you think of clearing up Piwik Core with options 2 and 3, when applicable?
Pros and cons
Removing code from Piwik Core provides the following benefits:
Cons:
When should we use option 1, 2 or 3?
For classes that are not related to Piwik or analytics in general:
Regarding 3rd party libraries, I would suggest we start with high expectations of quality and reliability. E.g. Symfony components would be OK, we know it is stable, maintained and reliable. For smaller librairies, we have to be careful.
What then?
What do you think of these ideas?
To be clear: this will not be implemented tomorrow. We are just discussing a global direction.
The text was updated successfully, but these errors were encountered: