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

Fluent Laravel Package

respect/fluent

Respect/Fluent is a small PHP library for building fluent, chainable APIs and expressive method chains. It helps create readable domain-specific syntax and cleaner interfaces with minimal boilerplate, making object interactions more natural and easier to compose.

Deep Wiki
Context7

respect/fluent is a lightweight PHP utility for building fluent interfaces — chainable APIs where every call returns an object ready for the next step. It lets you express transformations and configuration as compact, linear chains instead of nested calls or temporary variables.

  • Chainable wrappers for readable, step-by-step code
  • Minimal, dependency-free implementation
  • Small building block that fits alongside other Respect components
  • Unobtrusive API that stays out of your own classes' way
  • Easy to drop into existing projects
Frequently asked questions about Fluent
What is respect/fluent and how does it work in Laravel?
Respect/Fluent is a PHP package that builds fluent interfaces from class namespaces, letting you chain methods for readable domain-specific APIs. In Laravel it can complement Eloquent and the query builder by wrapping custom query or service logic in chains such as Order::filter()->byStatus()->withItems(). It is not a replacement for Eloquent or the query builder.
How do I install respect/fluent in a Laravel application?
Install it with Composer using composer require respect/fluent. The package does not ship a Laravel service provider or config file, so adoption is mostly about defining namespace mappings and fluent contracts in your own code. You can adopt it incrementally in a single domain before expanding.
Does respect/fluent need a Laravel service provider or configuration file?
No. Based on the technical assessment, respect/fluent is namespace-agnostic and does not enforce Laravel-specific dependencies. You may still need to define your own namespace mappings and conventions for fluent interfaces. No package config is required for basic use.
Which PHP and Laravel versions does respect/fluent support?
Respect/Fluent requires PHP 8.1 or newer. The package does not declare Laravel version constraints, so Laravel compatibility depends on your application running on a supported PHP version. Test in your target Laravel release before rolling it out broadly.
How does respect/fluent compare to Laravel query scopes and Eloquent macros?
Query scopes and macros are native Laravel tools for extending Eloquent and the query builder. Respect/Fluent adds namespace-based fluent interfaces and may reduce boilerplate for custom domain query layers, but it can introduce redundancy if overused. Use it where it clearly improves readability over native scopes or macros.
Can I use respect/fluent with Eloquent models and Laravel's query builder?
It is best used alongside Eloquent and the query builder, not as a replacement. You can wrap custom query logic in fluent interfaces such as User::filter()->active()->admin()->get(). Avoid overriding core Laravel classes or model methods to prevent conflicts.
How should I map namespaces for respect/fluent to avoid collisions?
Define a clear convention for fluent interfaces, such as App\Domain\User\Queries\FluentUser, rather than overriding App\Models\User. Scope namespaces by module or domain and use traits or base classes to standardize fluent behavior. This reduces collision risk and keeps IDE support manageable.
What are the performance implications of respect/fluent's dynamic method generation?
Dynamic fluent method generation has a minor runtime cost, often associated with reflection, so benchmark critical paths against native Laravel methods. For most domain-specific query builders the impact should be small, but it should be measured. Avoid using fluent wrappers in hot paths unless the readability benefit is clear.
How do I test fluent interfaces built with respect/fluent?
Keep fluent and non-fluent logic clearly separated so unit tests can target the underlying behavior. Chained methods can be harder to mock, so consider testing the final query or service output and using integration tests for chains. Document the fluent contracts and verify them with focused tests.
What are the production risks and alternatives to respect/fluent in Laravel?
Respect/Fluent is not a replacement for Laravel's Collection, query builder, or Eloquent fluent APIs; it is a low-coupling wrapper for custom domain layers. Production risks include over-engineering, harder debugging of chained stack traces, minor reflection overhead, and redundancy if Laravel adds similar patterns. Pilot it in one module and benchmark against native scopes or macros before wider use.
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.
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle