Weave Code
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky