Replace Guzzle with farzai/transport and optimize memory #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
guzzlehttp/guzzlewithfarzai/transportfor HTTP requestsGazetteerConverterfor O(1) memory complexity when processing large datasets#[AsCommand]attributesChanges
HTTP Client Migration
Replaced Guzzle with
farzai/transportlibrary for HTTP operations, simplifying the dependency chain.Memory Optimization
Added generator-based streaming in
GazetteerConverterto process large GeoNames files without loading everything into memory. Records are yielded one at a time for constant memory usage.Code Modernization
#[AsCommand]attributes instead of static$defaultNameand$defaultDescriptionpropertieswriteToHandle()methods with proper error checking in convertersDocumentation
New Tests
Added comprehensive unit tests:
tests/Helpers/MockHttpClient.php- HTTP client mockingtests/Helpers/MockMongoDBClient.php- MongoDB client mockingtests/Unit/Converter/GazetteerConverterTest.phptests/Unit/Converter/PostalCodeConverterTest.phptests/Unit/Converter/MongoDBConvertersProcessingTest.phptests/Unit/Downloader/AbstractDownloaderTest.phptests/Unit/Downloader/GazetteerDownloaderTest.phptests/Unit/Downloader/GeonamesDownloaderTest.phpTest plan
composer testto verify all tests pass./bin/geonames geonames:download TH./bin/geonames geonames:gazetteer:download TH