• Stars
    star
    3,572
  • Rank 12,418 (Top 0.3 %)
  • Language
    PHP
  • License
    Other
  • Created almost 13 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Requests for PHP is a humble HTTP request library. It simplifies how you interact with other sites and takes away all your worries.

Requests for PHP

CS Lint Test codecov.io

Requests is a HTTP library written in PHP, for human beings. It is roughly based on the API from the excellent Requests Python library. Requests is ISC Licensed (similar to the new BSD license) and has no dependencies, except for PHP 5.6.20+.

Despite PHP's use as a language for the web, its tools for sending HTTP requests are severely lacking. cURL has an interesting API, to say the least, and you can't always rely on it being available. Sockets provide only low level access, and require you to build most of the HTTP response parsing yourself.

We all have better things to do. That's why Requests was born.

$headers = array('Accept' => 'application/json');
$options = array('auth' => array('user', 'pass'));
$request = WpOrg\Requests\Requests::get('https://api.github.com/gists', $headers, $options);

var_dump($request->status_code);
// int(200)

var_dump($request->headers['content-type']);
// string(31) "application/json; charset=utf-8"

var_dump($request->body);
// string(26891) "[...]"

Requests allows you to send HEAD, GET, POST, PUT, DELETE, and PATCH HTTP requests. You can add headers, form data, multipart files, and parameters with basic arrays, and access the response data in the same way. Requests uses cURL and fsockopen, depending on what your system has available, but abstracts all the nasty stuff out of your way, providing a consistent API.

Features

  • International Domains and URLs
  • Browser-style SSL Verification
  • Basic/Digest Authentication
  • Automatic Decompression
  • Connection Timeouts

Installation

Install with Composer

If you're using Composer to manage dependencies, you can add Requests with it.

composer require rmccue/requests

or

{
    "require": {
        "rmccue/requests": "^2.0"
    }
}

Install source from GitHub

To install the source code:

$ git clone git://github.com/WordPress/Requests.git

Next, include the autoloader in your scripts:

require_once '/path/to/Requests/src/Autoload.php';

You'll probably also want to register the autoloader:

WpOrg\Requests\Autoload::register();

Install source from zip/tarball

Alternatively, you can fetch a tarball or zipball:

$ curl -L https://github.com/WordPress/Requests/tarball/stable | tar xzv
(or)
$ wget https://github.com/WordPress/Requests/tarball/stable -O - | tar xzv

Using a Class Loader

If you're using a class loader (e.g., Symfony Class Loader) for PSR-4-style class loading:

$loader = new Psr4ClassLoader();
$loader->addPrefix('WpOrg\\Requests\\', 'path/to/vendor/Requests/src');
$loader->register();

Documentation

The best place to start is our prose-based documentation, which will guide you through using Requests.

After that, take a look at the documentation for \WpOrg\Requests\Requests::request(), where all the parameters are fully documented.

Requests is 100% documented with PHPDoc. If you find any problems with it, create a new issue!

Test Coverage

Requests strives to have 100% code-coverage of the library with an extensive set of tests. We're not quite there yet, but we're getting close.

Requests and PSR-7/PSR-18

PSR-7 describes common interfaces for representing HTTP messages. PSR-18 describes a common interface for sending HTTP requests and receiving HTTP responses.

Both PSR-7 as well as PSR-18 were created after Requests' conception. At this time, there is no intention to add a native PSR-7/PSR-18 implementation to the Requests library.

However, the amazing Artur Weigandt has created a package, which allows you to use Requests as a PSR-7 compatible PSR-18 HTTP Client. If you are interested in a PSR-7/PSR-18 compatible version of Requests, we highly recommend you check out this package.

Contribute

Contributions to this library are very welcome. Please read the Contributing guidelines to get started.

More Repositories

1

WordPress

WordPress, Git-ified. This repository is just a mirror of the WordPress subversion repository. Please do not send pull requests. Submit pull requests to https://github.com/WordPress/wordpress-develop and patches to https://core.trac.wordpress.org/ instead.
PHP
19,332
star
2

gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
JavaScript
9,873
star
3

WordPress-Coding-Standards

PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions
PHP
2,383
star
4

wordpress-develop

WordPress Develop, Git-ified. Synced from git://develop.git.wordpress.org/, including branches and tags! This repository is just a mirror of the WordPress subversion repository. Please include a link to a pre-existing ticket on https://core.trac.wordpress.org/ with every pull request.
PHP
2,295
star
5

wordpress-playground

Run WordPress in the browser via WebAssembly PHP
JavaScript
1,612
star
6

gutenberg-examples

Examples for extending WordPress/Gutenberg with blocks.
JavaScript
1,189
star
7

two-factor

Two-Factor Authentication for WordPress.
PHP
724
star
8

gutenberg-starter-theme

A simple theme for testing Gutenberg.
PHP
686
star
9

dashicons

Dashicons, the WordPress admin icon font. For the official resource, please see the WordPress Developer Hub.
JavaScript
563
star
10

theme-experiments

Experimenting with themes made out of blocks.
CSS
549
star
11

book

Our book about WordPress. Version 1
520
star
12

twentytwentytwo

Twenty Twenty-Two, the default WordPress theme that will launch with WordPress 5.9.
PHP
407
star
13

theme-check

Theme Check plugin
PHP
335
star
14

performance

Performance plugin from the WordPress Performance Group, which is a collection of standalone performance modules.
PHP
327
star
15

twentynineteen

Twenty Nineteen is a theme now included in all WordPress installs. To report any issues please go here: https://core.trac.wordpress.org/newticket
CSS
324
star
16

twentysixteen

Twenty Sixteen is a theme now included in all WordPress installs. To report any issues please go here: https://core.trac.wordpress.org/newticket
CSS
323
star
17

create-block-theme

A WordPress plugin to create block themes
JavaScript
304
star
18

twentytwenty

Twenty Twenty is included in Core as of WordPress 5.3 πŸŽ‰ To report any issues, please go here: https://core.trac.wordpress.org/newticket
CSS
300
star
19

Learn

WordPress.org Learn - The canonical source for the code and content behind https://learn.WordPress.org
PHP
271
star
20

plugin-check

A repository for the new Plugin Check plugin from the WordPress Performance and Plugins Team.
PHP
246
star
21

openverse

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Python
246
star
22

phpdoc-parser

Documentation parser powering developer.wordpress.org
PHP
237
star
23

sqlite-database-integration

Feature Plugin to add SQLite support to WordPress. Under Development.
PHP
219
star
24

twentytwentyfour

PHP
197
star
25

meta-environment

A collection of scripts that provision the official WordPress.org websites into a Varying Vagrant Vagrants installation.
PHP
190
star
26

wp-movies-demo

Demo of the Interactivity API
PHP
188
star
27

wp-feature-notifications

WP Feature Notifications - a proposal to modernise the way in which WordPress handles emails, admin notices and user notifications
PHP
188
star
28

application-passwords

PHP
183
star
29

twentyseventeen

Twenty Seventeen is a theme now included in all WordPress installs. To report any issues please go here: https://core.trac.wordpress.org/newticket
CSS
180
star
30

twentytwentyone

Ongoing development of Twenty Twenty-One, the new default WordPress theme slated for 5.6.
PHP
179
star
31

health-check

Health Check is a WordPress plugin that will perform a number of checks on your WordPress install to detect common configuration errors and known issues.
PHP
175
star
32

block-development-examples

Practical examples for building WordPress blocks and extending the Editor.
JavaScript
169
star
33

classic-editor

A plugin to restore the Classic Editor in WordPress.
PHP
160
star
34

playground-tools

TypeScript
136
star
35

secure-swfupload

A fork of the long-abandoned SWFUpload project, maintained by WordPress and others to ensure that a secure version of SWFUpload exists. Report security vulnerabilities to [email protected].
ActionScript
135
star
36

wporg-plugin-guidelines

WordPress.org Plugin Directory Guidelines
125
star
37

wordcamp.org

WordCamps are casual, locally-organized conferences covering everything related to WordPress.
PHP
124
star
38

twentytwentythree

Twenty Twenty-Three, the default WordPress theme sporting many styles that will launch with WordPress 6.1.
HTML
124
star
39

pattern-directory

The WordPress Block Pattern Directory
PHP
123
star
40

HelpHub

The WordPress user documentation portal
PHP
112
star
41

block-interactivity-experiments

⚠️ WARNING: This repository is no longer active. The development and discussions have been moved to the Gutenberg repository.
PHP
109
star
42

wordpress.org

WordPress.org Meta, Git-ified. Synced from git://meta.git.wordpress.org/ This repository is just a mirror of the WordPress Meta subversion repository. Please include a link to a pre-existing ticket on https://meta.trac.wordpress.org/ with every pull request.
PHP
107
star
43

browsehappy

PHP
102
star
44

Advanced-administration-handbook

WordPress Advanced Administration Handbook. This handbook will have the most technical, general, documentation about WordPress.
95
star
45

Security-White-Paper

The WordPress Security White Paper, available directly on the WordPress.org site at https://wordpress.org/about/security/
HTML
95
star
46

packages

Collection of JS modules and tools for WordPress development
JavaScript
87
star
47

slides

Slides: Presentations with WordPress
JavaScript
86
star
48

Documentation-Issue-Tracker

Issue Tracker for the WordPress Documentation team.
81
star
49

servehappy-resources

Third-party articles and specific tutorials on PHP upgrades.
80
star
50

community-themes

A collection of Block Themes built by the WordPress community.
HTML
80
star
51

wordpress-importer

The WordPress Importer
PHP
78
star
52

wpcs-docs

WordPress Coding Standards Docs
77
star
53

openverse-api

The Openverse API allows programmatic access to search for CC-licensed and public domain digital media.
Python
76
star
54

WP-Reasons

A public domain marketing flyer/brochure about the reasons to use WordPress, brought to you by some members of the WordPress community.
HTML
72
star
55

openverse-frontend

The gateway to the Openverse. Openverse is a search tool for CC-licensed and public domain content across the internet.
Vue
72
star
56

hosting-handbook

WordPress Hosting Team Handbook
PHP
71
star
57

revisions-extended

PHP
70
star
58

data-liberation

69
star
59

wp-lazy-loading

Feature plugin for testing and experimenting with the "loading" HTML attribute.
PHP
68
star
60

phpunit-test-runner

PHP
65
star
61

wporg-main-2022

A block-based child theme for WordPress.org, plus local environment
PHP
64
star
62

wp-plugin-dependencies

WordPress Feature Project: Plugin Dependencies
PHP
63
star
63

wporg-code-analysis

An experiment.
PHP
62
star
64

wpdev-docker-images

Docker images for use with the Core local development environment.
Dockerfile
61
star
65

wporg-developer

WordPress.org Developer theme
PHP
61
star
66

wporg-mu-plugins

Development of the Global Header and other mu-plugins used on WordPress.org.
PHP
60
star
67

openverse-catalog

Identifies and collects data on cc-licensed content across web crawl data and public apis.
Python
57
star
68

wp-autoupdates

Feature plugin building a UI for opting-in to plugin, theme, and core auto-updates.
PHP
56
star
69

servehappy

Information page about PHP versions and updates, to be used through the WordPress.org project.
53
star
70

grunt-patch-wordpress

Patch Trac based projects
JavaScript
49
star
71

WordPress-Documentation-Style-Guide

Style Guide for WordPress documentation.
47
star
72

design-experiments

A simple plugin for WP-Admin design experiments. Brought to you by the WordPress Design Team.
CSS
47
star
73

blueprints

Blueprints gallery and examples
Python
46
star
74

press-this

Press This is a little tool that lets you grab bits of the web and create new posts with ease. It will even allow you to choose from images or videos included on the page and use them in your post. Use Press This as a quick and lightweight way to highlight another page on the web.
CSS
45
star
75

wp20-book

Our book about WordPress. Version 2
43
star
76

plugin-check-action

Test your WordPress plugin with Plugin Check
TypeScript
42
star
77

five-for-the-future

Plugins and themes for the Five for the Future subsite
PHP
39
star
78

plugin-check-legacy

Work in progress of a "Plugin Check" plugin, this is in development and is not final.
PHP
39
star
79

css-audit

JavaScript
38
star
80

better-code-editing

[βœ… Merged into 4.9-alpha] Better Code Editing WordPress plugin
CSS
38
star
81

wporg-two-factor

2FA for WordPress.org accounts
JavaScript
37
star
82

developer-blog-content

In this GitHub space, WordPress team coordinate content to be published on the Developer Blog. Discussion and montly meetings (first Thu) in WP Slack #core-dev-blog
37
star
83

meeting-calendar

The plugin powering https://make.wordpress.org/meetings/
PHP
35
star
84

block-theme-examples

A repository of feature examples for block themes.
PHP
34
star
85

rollback-update-failure

Feature plugin to test zip rollback of plugin/theme update failures.
PHP
33
star
86

wporg-news-2021

The WordPress.org News Theme
SCSS
31
star
87

blueprints-library

PHP
30
star
88

theme-review-action

JavaScript
28
star
89

phpunit-test-reporter

PHP
28
star
90

Marketing-Team

The central repository for the WordPress Marketing Team
27
star
91

block-directory

Block library: Timeline and plan: https://make.wordpress.org/design/2019/04/26/block-library-installing-blocks-from-within-gutenberg/
27
star
92

contributor-day-handbook

25
star
93

gutenberg.run

Gutenberg live branch preview provisioning service
JavaScript
25
star
94

openverse-browser-extension

A cross-browser extension that lets you search, filter, and use openly-licensed images.
JavaScript
21
star
95

google-fonts-to-wordpress-collection

Gets the Google fonts collection and transform it to a WordPress font library collection, including SVG previews
JavaScript
19
star
96

wporg-showcase-2022

The official theme of the WordPress.org showcase.
PHP
19
star
97

spain-handbook

Manuales de la Comunidad de WordPress EspaΓ±a (Handbook)
18
star
98

wporg-parent-2021

SCSS
17
star
99

classic-widgets

A plugin to restore the Classic Widgets in WordPress.
PHP
17
star
100

Community

WordPress Community Team Projects and Plans | https://make.wordpress.org/community/
16
star