Replace Guzzle with farzai/transport and optimize memory#26
Merged
Conversation
- Migrate HTTP client from guzzlehttp/guzzle to farzai/transport - Implement streaming in GazetteerConverter for O(1) memory complexity - Use PHP 8 #[AsCommand] attributes for Symfony Console commands - Add writeToHandle methods with proper error checking - Update README with documentation improvements - Add comprehensive unit tests for converters and downloaders
Broaden symfony/http-client constraint from ^7.3 to ^6.4 || ^7.0 to support PHP 8.1, as symfony/http-client 7.3+ requires PHP 8.2+.
Return null from createProgressBar when totalLines is 0 to avoid LogicException in older Symfony Console versions that can't display estimated time with zero max value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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