Wire Genie version / branch | Supported PHP versions |
---|---|
v3.x |
8.0+ (native attributes support) |
v2.99 |
8.0 (native attributes support) |
v2.x |
7.2, 7.3, 7.4, 8.0+ |
v1.x |
7.2, 7.3, 7.4, 8.0 |
Migration path for PHP 8:
1.x -> 2.x -> 2.99 -> 3.x
\__________/
PHP 7 -> PHP 8
This version requires PHP 8.
The compatibility layer present in v2.99
was removed.
All deprecated classes and methods have been removed.
The default strategy for argument type detection and resolution is now based on native attributes,
but function-wise is a superset of the legacy one based on @param
annotations,
i.e. you can model the same functionality and do much more, faster.
Update your code to use native attributes instead of the wire tag in @param
annotations.
Old code using wire tags | Replace with new code |
---|---|
@param $foo [wire:identifier] |
#[Wire('identifier')] attribute |
@param $foo [wire:App\Services\FooService] (class-name wire tag) |
#[Wire(App\Services\FooService::class)] attribute |
@param $foo [wire:] (empty wire tag) |
#[Skip] attribute |
These attributes need to be applied on the particular parameter:
function(#[Wire('identifier')] $service1, #[Skip] $service2) { ... }
This is a transitional version for migration of code using v2
to PHP 8.
It contains the new resolver strategy AttributeBasedStrategy
found in v3
, but still packs the legacy code from v2
.
PHP 7 support has been dropped.
TagBasedStrategy
is now deprecated, migrate to code using AttributeBasedStrategy
.
Breaking changes:
- methods
WireGenie::provideSafe
andWireGenie::provideStrict
removed - renamed classes and namespace altered (added one level of nesting)
WireInvoker
andWireGenie
have been merged to theGenie
class, which assumed the functionality of both
Renamed classes
Previous | Current |
---|---|
Dakujem\WireGenie |
Dakujem\Wire\Genie * |
Dakujem\WireInvoker |
Dakujem\Wire\Genie * |
Dakujem\InvokableProvider |
Dakujem\Wire\Simpleton |
Dakujem\WireLimiter |
Dakujem\Wire\Limiter |
Dakujem\WireLimiterException |
Dakujem\Wire\Exceptions\ServiceNotWhitelisted |
Dakujem\PredictableAccess |
Dakujem\Wire\PredictableAccess |
Dakujem\ArgInspector |
Dakujem\Wire\TagBasedStrategy |
Dakujem\Invoker (interface) |
Dakujem\Wire\Invoker |
Dakujem\Constructor (interface) |
Dakujem\Wire\Constructor |
Compatibility layer:
- renamed classes and interfaces have aliases registered, 95% of the old code should still work (see compat.php)
- calling a removed method will trigger a dev-friendly error message
Runtime exceptions are now based on Dakujem\Wire\Exceptions\Unresolvable
exception interface. Any configuration error and incorrect usage will result in a LogicException
.
Steps needed:
- Replace any usage of
WireGenie::provideSafe
withGenie::provide
. - Replace any usage of
WireGenie::provideStrict
withGenie::provide
, remove "nullability" of the code being invoked where applicable. - In case your code uses more than 1 argument when constructing the
WireInvoker
class (either vianew WireInvoker
orWireInvoker::employ
), i.e. you are using a custom detector/reflector/proxy, you need to construct a wiring strategy and pass it to theGenie
constructor/employ method instead:The detector/proxy/reflector need no update, they work the same.// old code new WireInvoker( $container, $myDetector, $myProxy, $myReflector); WireInvoker::employ($wireGenie, $myDetector, $myProxy, $myReflector); // new code new Genie( $container, new TagBasedStrategy($myDetector, $myProxy, $myReflector)); Genie::employ($wireGenie, new TagBasedStrategy($myDetector, $myProxy, $myReflector));
- If you happen to call the internal method
WireInvoker::resolveServicesFillingInStaticArguments
, you need to change the call toTagBasedStrategy::resolveServicesFillingInStaticArguments
.
Recommended steps:
- Update the namespaces /
use
statements for all classes in use, see the "Renamed classes" table above.