smokills / laravel-http-client-default-options Goto Github PK
View Code? Open in Web Editor NEWExtends the native Laravel Http Client, so that you can define default options
License: MIT License
Extends the native Laravel Http Client, so that you can define default options
License: MIT License
In Guzzle I can do this:
$this->client = new Client(
[
'base_uri' => 'https://www.example.com',
'headers' => [
'some' => 'header',
],
]
);
I do that in a base class common to several different subclasses that call APIs relative to this common base URL.
I'm looking at switching to the built-in Http Laravel class, and found your package while looking for how to do this. From your docs I can only see that you allow setting these options globally, across all instances of the Http client, which I don't want to do as I have other scripts that don't need those defaults, or per-request, which is messy. So I'm looking to create an instance on which I can set default properties.
I've tried using:
$this->client = (new Http())->withOptions(
[
'base_uri' => 'https://www.example.com',
'headers' => [
'some' => 'header',
],
]
);
but that doesn't seem to work as it expects a request rather than a client instance. Is this possible? Is there another way? Or should I stick with native Guzzle?
Your requirements could not be resolved to an installable set of packages.
Problem 1
- smokills/laravel-http-client-default-options[v2.0.0, ..., v2.0.2] require illuminate/http ^8.0 -> found illuminate/http[v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require.
- Root composer.json requires smokills/laravel-http-client-default-options ^2.0 -> satisfiable by smokills/laravel-http-client-default-options[v2.0.0, v2.0.1, v2.0.2].
You can also try re-running composer require with an explicit version constraint, e.g. "composer require smokills/laravel-http-client-default-options:*" to figure out if any version is installable, or "composer require smokills/laravel-http-client-default-options:^2.1" if you know which you need.
Hi,
Great package, any chance to have PHP 8 support?
Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.