Skip to content

Add Symfony HttpClient support for loading JSON from URL#51

Merged
roberto-butti merged 1 commit intoHi-Folks:mainfrom
sonnymilton:gh-49_symfony-http-client
Jan 2, 2026
Merged

Add Symfony HttpClient support for loading JSON from URL#51
roberto-butti merged 1 commit intoHi-Folks:mainfrom
sonnymilton:gh-49_symfony-http-client

Conversation

@sonnymilton
Copy link
Copy Markdown

@sonnymilton sonnymilton commented Dec 27, 2025

Adds a new way to load remote JSON using Symfony HttpClient.

What’s included

  • New method Block::fromHttpJsonUrl(string $jsonUrl, HttpClientInterface $client, array $options = []): self
    • Allows passing Symfony request options (headers, auth, timeouts, etc.)
    • Returns an empty Block when the response body is empty
  • README updated
  • New feature test verifying remote JSON loading via HttpClient::create()
  • Dependencies
    • require: symfony/http-client-contracts:^3.4.4 (for HttpClientInterface)
    • suggest: symfony/http-client as a concrete implementation
    • require-dev: symfony/http-client:^7.4 for tests

Why

fromJsonUrl() relies on PHP stream functions (e.g. file_get_contents()), which may be restricted (for example allow_url_fopen=0) and provides less control over request configuration. This PR enables a first-class alternative using Symfony HttpClient.

Related

Refs / fixes #49

@roberto-butti
Copy link
Copy Markdown
Contributor

wow, thank you @sonnymilton for the PR. I will take a look !
Thank you

@roberto-butti roberto-butti merged commit a621531 into Hi-Folks:main Jan 2, 2026
8 checks passed
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.

Implementing httpJson with Symfony\Contracts\HttpClient\HttpClientInterface

2 participants