Download the PHP package jerome/fetch-php without Composer

On this page you can find all versions of the php package jerome/fetch-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package fetch-php

About Fetch PHP

Latest Version on Packagist Tests Check & fix styling Total Downloads

FetchPHP is a modern HTTP client library for PHP, built on top of the Guzzle HTTP client, designed to mimic the behavior of JavaScript’s fetch API. Leveraging Matrix for true asynchronous capabilities with PHP Fibers, FetchPHP allows developers to use a JavaScript-like async/await syntax. FetchPHP also offers a fluent API inspired by Laravel's HTTP client, making request building both flexible and readable.

Whether you're building small APIs or large-scale systems with high concurrency needs, FetchPHP provides a powerful and efficient solution for managing HTTP requests in PHP.

Make sure to check out Matrix for more information on how FetchPHP is powered by PHP Fibers.

Full documentation can be found here


Why Choose FetchPHP Over Guzzle?

Guzzle is a well-established and widely-used HTTP client for PHP. It supports asynchronous requests using Promises. However, FetchPHP takes things further by offering true asynchronous task management through PHP Fibers, powered by Matrix. Here’s why FetchPHP stands out:

How FetchPHP's Async Task Management Differs from Guzzle

Here’s a breakdown of FetchPHP’s underlying async task management powered by Matrix compared to Guzzle’s Promise-based approach:

Feature FetchPHP Guzzle
Async Task Management True async with PHP Fibers (PHP 8.1+) Promises-based concurrency
JavaScript-like API async/await syntax Traditional PHP-based Promises
Task Lifecycle Control Start, pause, resume, cancel, retry No built-in lifecycle management
Error Handling Customizable error handlers Standard Promise error handling
Concurrent Requests Supports Fibers for parallel tasks Limited to Promises and threading

Note: The fetch() function allows for flexible HTTP request handling. When a URL is provided, it immediately sends the request. When no URL is provided, it returns a ClientHandler instance to enable further chaining for advanced request configuration.

Example: Managing Asynchronous Tasks with FetchPHP


Lifecycle Control Example with FetchPHP


Why FetchPHP is Better for Asynchronous PHP

While Guzzle is a fantastic tool for making HTTP requests, FetchPHP brings modern PHP capabilities with PHP 8 Fibers, making it ideal for developers who need true asynchronous task management with a JavaScript-like syntax. FetchPHP is designed to make your code more flexible, readable, and efficient when managing complex HTTP operations, especially when concurrency and non-blocking I/O are crucial.


Installation

To install FetchPHP, run the following command:

FetchPHP requires PHP 8.1 or above due to its use of Fibers for async tasks.


Core Features


Usage Examples

JavaScript-like Fetch API (Synchronous)

JavaScript-like Fetch API (Asynchronous)


Using the Fluent API

FetchPHP’s fluent API provides the following methods for building requests:

Synchronous Example

Asynchronous Example


Using the ClientHandler Class

The ClientHandler class is responsible for managing HTTP requests, including synchronous and asynchronous handling. You can use it directly for more advanced use cases:

Basic Example with ClientHandler

Asynchronous Example with ClientHandler


Request Options

FetchPHP accepts an array of options to configure requests:


Error Handling

Both synchronous and asynchronous requests handle errors gracefully. Here's how you can manage errors:

Synchronous Error Handling

Asynchronous Error Handling


Advanced Error Handling: Retry with Exponential Backoff


Proxy and Authentication Support

FetchPHP supports proxies and authentication out of the box:

Proxy Example

Authentication Example


License

This project is licensed under the MIT License - see the LICENSE.md file for details.


Contributing

Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

We’re currently looking for help in the following areas:

To contribute:

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/amazing-feature)
  3. Commit your Changes (git commit -m 'Add some amazing-feature')
  4. Push to the Branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Authors

See also the list of contributors who participated in this project.

Acknowledgments


All versions of fetch-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
guzzlehttp/guzzle Version ^7.8
guzzlehttp/psr7 Version ^2.7
psr/http-message Version ^1.0|^2.0
jerome/matrix Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jerome/fetch-php contains the following files

Loading the files please wait ....