ergebnis/http-method
Tiny PHP package providing named constants for HTTP request methods (GET, POST, PUT, DELETE, etc.). Use it to avoid magic strings and share a single source of truth across frameworks, libraries, and your own code.
"GET", "POST") and improve maintainability.HttpMethod::GET).Request object patterns.if ($request->method() === HttpMethod::POST)).#[Route(method: HttpMethod::PATCH)]).HttpMethod::CONNECT, HttpMethod::TRACE)."PUT" in route definitions or conditionals).Request methods or Symfony’s Request::METHOD_* constants).symfony/validator.For Executives:
"This package replaces unreliable magic strings (like 'DELETE') with typed constants (e.g., HttpMethod::DELETE) for HTTP methods, reducing bugs and improving code clarity. It’s a zero-maintenance, MIT-licensed solution that aligns with modern PHP best practices—similar to how we’d standardize on a library for logging or caching. The overhead is negligible (just a composer require), but the long-term benefits for maintainability and developer experience are significant."
For Engineers: *"This gives us:
HttpMethod::GET instead of 'get' or 'GET' inconsistencies.CONNECT, OPTIONS).
Use it in middleware, routes, or validation logic where HTTP methods are checked. Example:if ($request->method() === HttpMethod::PATCH) { ... }
Downside? None—it’s a drop-in replacement for strings with zero runtime cost."
How can I help you explore Laravel packages today?