Extract a "big" tar file with Console command

Hii there,

I’m trying to make a console command to easily download the MaxMind GeoLite2 databases.
One such database (the City database) is 30MB big, which isn’t that big of a file, except that it exhausts the memory of the PHP process.
I know this could relatively easily be fixed by setting the max memory for PHP to yes. (“how much memory does it need? yes.”) but I think you would agree with me if I said that that’s a dirty way to do it.
So my question hereby is how I could download this file nicely without having to resort to a dirty hack like that?

this is the code that I’m using:

public function initialize() {
  $this->http = new \Cake\Http\Client();

protected function download() {
  $res = $this->http->get($this->baseUrl, [
    'edition_id' => 'GeoLite2-City',
    'license_key' => $this->licenseKey,
    'suffix' => 'tar.gz',

EDIT: Apparently, the issue is not the download itself but the extraction :frowning: :

$p = new \PharData($tmp->path);
$p->extractTo(TMP . '/geolite2-city');

Solved it by adding this between extraction and downloading: