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.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels