src/Lifetime.php source

1 <?php
2
3 namespace mini;
4
5 /**
6 * Service lifetime for dependency injection container
7 *
8 * Defines how long a service instance should be reused.
9 */
10 enum Lifetime
11 {
12 /**
13 * Singleton - One instance for the entire application lifetime
14 *
15 * Created once and reused across all requests in long-running applications.
16 * Use for stateless services or services that manage their own state.
17 */
18 case Singleton;
19
20 /**
21 * Scoped - One instance per request scope
22 *
23 * Created once per request/fiber and reused within that scope.
24 * Automatically cleaned up when request completes.
25 * Use for services that should be fresh per request (database connections, etc.).
26 */
27 case Scoped;
28
29 /**
30 * Transient - New instance every time
31 *
32 * Created fresh on every call to get().
33 * Use for lightweight objects or when you specifically need new instances.
34 */
35 case Transient;
36 }
37