Skip to content

Conversation

coogle
Copy link

@coogle coogle commented Dec 16, 2023

Currently this SDK isn't really usable in modern PHP applications due to it's vast usage of the global namespace which has long since been retired as a best practice. Additionally, it does not have the metadata needed to be included into modern PHP projects via the PHP package manager composer.

This PR fixes both issues. Essentially what I've done is a simple wrapping of all the global namespaced functions into the Mapcode namespace. I then created an object to hold all the global variables / lookup tables MapcodeData and updated all the references to $GLOBALS to use the MapcodeData::$varname equivalent`.

I also cleaned up the autoloading a tad and added a composer.json which can then be registered at https://packagist.org so others can easily use the library.

Along with these changes I updated the sample, unit tests (all passing), and documentation to reflect how it can be used. I updated the version to 2.3.0, although I think arguably it would make sense to call this 3.0.0.

All of these changes were necessary in order to use the library in any sort of professional PHP application context, and if necessary we'll maintain this as our own fork of the original SDK -- but I'd love to see this PR merged so we won't have to do that!

…amespace functions into the `Mapcode` namespace. Also updating all the unit test stuff, samples, docs, etc. to match the new stuff.

Additionally, added a `composer.json` file so the package can be loaded via the package manager now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant