-
Notifications
You must be signed in to change notification settings - Fork 13
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
Splitting up ISO 3166 2 per country #12
Comments
Yes, that code is not optimal.
Database file is large, and it needs to be loaded to memory. I thought to add some cache layer, because parsing of ~500KB JSON file and creading value objects not very optimal, but then decide that this layer must be on the client side. Maybe there is a reason to split database json file to php files with one country's subdivisions inside. Opcache will help to cache and locate this parts. |
Why not adding both ( one file and isolated JSON files per country ) and make it configurable ? This will give people more choices. If the original data is begin delivered in one single file I think it's sane to create a little script that automate the extraction part to make life easier for future database updates. |
If there is profit with single file in some use cases, maybe both variants will stay. Not shure about configuration, choosing of strategy may be done dependin on concrete method without configuration, benchmarking will show better way. And of course splitting must be automated. There is also languages database (ISO 639-3) with 847KB file. |
The cache layer would work for the loading but it wouldn't work for the searching, at least with the current implementation of I think keeping both variants is not a good idea: more options = more code = mode maintenance points = more hassle. I think there are not many use cases in which you need all subdivisions listed if not by country, and if that's really the case it makes sense to get them by country (as most of the interface of And talking about really splitting it up, it will require breaking BC because both |
There is no much benefit from having individual rules for each country's subdivision, quite the opposite. It increases the amount of code and makes it hard to change the implementation of these rules. Right now, the only sane way to change those rules is with a customized script. This commit will remove the Subdivision Code rules per country and instead will put that information into JSON files. We both wouldn't like to keep this in this library anymore, and we are considering having another library to deal with this data [1], but since it seems like it may take some time, looks better to do it temporarily here. [1]: sokil/php-isocodes#12 Co-authored-by: Mazen Touati <mazen_touati@hotmail.com> Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
There is no much benefit from having individual rules for each country's subdivision, quite the opposite. It increases the amount of code and makes it hard to change the implementation of these rules. Right now, the only sane way to change those rules is with a customized script. This commit will remove the Subdivision Code rules per country and instead will put that information into JSON files. We both wouldn't like to keep this in this library anymore, and we are considering having another library to deal with this data [1], but since it seems like it may take some time, looks better to do it temporarily here. [1]: sokil/php-isocodes#12 Co-authored-by: Mazen Touati <mazen_touati@hotmail.com> Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
|
Done in 3.0.0 |
First of all, thank you very much for maintaining this library, very much appreciated! I am very interested to incorporate this library into a library that I have been maintaining in a while called Respect\Validation because I don't want to deal with keeping this type of data in sync.
I noticed that you load all the subdivisions (ISO 3166 2) at once and then you iterate on them to fetch them by Country. Wouldn't it be optimal to have once file per country instead?
I get that this is the implementation of iso-codes, but they don't have to worry with web environment as most of PHP code has to deal with.
The text was updated successfully, but these errors were encountered: