Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Gohttp Laravel Package

dcarbone/gohttp

Small PHP helper library inspired by Go’s net/http. Provides lightweight, Go-style utilities to simplify common HTTP request/response tasks in PHP, aiming to “PHP-ize” a few useful pieces of the Golang HTTP package.

View on GitHub
Deep Wiki
Context7

dcarbone/gohttp

Golang-inspired HTTP helpers for PHP, including:

  • HTTP status code constants
  • HTTP method constants
  • status text / status name helpers
  • a small URL\Values container for query-style key/value lists

Requirements

  • PHP 8.2+
  • ext-json

Installation

composer require dcarbone/gohttp

Usage

Status helpers

<?php declare(strict_types=1);

use DCarbone\Go\HTTP\HTTP;

echo HTTP::StatusOK; // 200
echo HTTP::StatusText(HTTP::StatusNotFound); // "Not Found"
echo HTTP::StatusName(HTTP::StatusNotFound); // "NotFound"

Namespace functions

The package also provides namespaced functions:

<?php declare(strict_types=1);

use function DCarbone\Go\HTTP\StatusName;
use function DCarbone\Go\HTTP\StatusText;

echo StatusText(418); // "I'm a teapot"
echo StatusName(418); // "Teapot"

Methods

<?php declare(strict_types=1);

use DCarbone\Go\HTTP\HTTP;

$methods = [
    HTTP::MethodGet,
    HTTP::MethodPost,
    HTTP::MethodPut,
    HTTP::MethodPatch,
    HTTP::MethodDelete,
];

URL values

<?php declare(strict_types=1);

use DCarbone\Go\HTTP\URL\Values;

$values = new Values();
$values->add('filter', 'active');
$values->add('filter', 'recent');
$values->set('page', '1');

echo $values->get('filter'); // "active"
print_r($values->getAll('filter')); // ["active", "recent"]

echo (string)$values; // "filter=active&filter=recent&page=1"

Values implements Iterator, ArrayAccess, Countable, and JsonSerializable.

Development

Install dependencies:

composer install

Run unit tests:

composer test

License

MIT

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support