nzour/symfony-advanced-resolving
A Symfony package that adds advanced resolving capabilities, making service and argument resolution more flexible and context-aware. It helps reduce boilerplate, simplify dependency wiring, and keep container configuration clean, readable, and maintainable in modern Symfony applications.
1.0.0-beta.2 is current:
composer require vendor/package:1.0.0-beta.2
README.md for the supported attribute syntax and examples.src/FromQuery.php for the attribute class, its constructor options, and the new $disableTypeEnforcement static property.$request->query():
use Vendor\Package\FromQuery;
public function index(
#[FromQuery] string $search,
#[FromQuery] int $page = 1,
#[FromQuery] bool $active = false,
) {
// $search, $page, and $active are already resolved and typed.
}
/?search=invoice&page=2&active=1. If the values arrive as strings when you expected typed values, check whether FromQuery::$disableTypeEnforcement has been set anywhere in your application or test bootstrap.#[FromQuery] for read-only listing, filtering, and search endpoints. It keeps controllers small and makes query contracts visible in method signatures.int, float, bool for scalar filters.status, sort, or type.array for repeated query parameters such as ?tag[]=php&tag[]=laravel.use Vendor\Package\FromQuery;
// Disable type enforcement globally for this process.
FromQuery::$disableTypeEnforcement = true;
Set this in a service provider only when the whole application or a legacy subsystem needs raw query strings. Prefer narrower, per-parameter controls if the package exposes them.protected function setUp(): void
{
parent::setUp();
FromQuery::$disableTypeEnforcement = false;
}
protected function tearDown(): void
{
FromQuery::$disableTypeEnforcement = false;
parent::tearDown();
}
FromQuery::$disableTypeEnforcement is static global state. It affects every subsequent resolution in the same PHP process, including all requests in Octane, RoadRunner, or queue workers. Do not toggle it per request in long-running processes.tearDown() or set it once during application boot.disableTypeEnforcement. The new property is an easy accidental global switch.?active=false may not behave like a boolean false unless the package handles it explicitly. Test both ?active=0 and ?active=false.?page= may resolve to an empty string rather than null. Normalize empty values before validation or persistence.tag[]=a&tag[]=b); a comma-separated value remains a string.?search= and write tests for whichever behavior your endpoint requires.1.0.0-beta.2 may be renamed, deprecated, or replaced before stable.$request->query() to confirm the raw input.FromQuery::$disableTypeEnforcement.FromQuery::$disableTypeEnforcement only as a last-resort global fallback, not as a substitute for proper per-endpoint handling.How can I help you explore Laravel packages today?