Coder Social home page Coder Social logo

smokills / laravel-http-client-default-options Goto Github PK

View Code? Open in Web Editor NEW
28.0 3.0 9.0 45 KB

Extends the native Laravel Http Client, so that you can define default options

License: MIT License

PHP 100.00%
laravel guzzle http laravel-package lumen lumen-package hacktoberfest

laravel-http-client-default-options's Issues

How to set default options per instance?

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?

it is not installing in laravel v9.x-dev

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.

PHP 8 support

Hi,
Great package, any chance to have PHP 8 support?
Thanks,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.