Skip to content

2.0 main#7

Merged
velkymx merged 5 commits intomainfrom
2.0-main
Mar 6, 2026
Merged

2.0 main#7
velkymx merged 5 commits intomainfrom
2.0-main

Conversation

@velkymx
Copy link
Copy Markdown
Owner

@velkymx velkymx commented Mar 6, 2026

This is a major release that transforms the framework from a traditional request-response library into a production-grade, fiber-safe foundation for high-concurrency PHP 8.4+ applications.

Benchmark Results

Running on FrankenPHP (Worker Mode) with 4 workers on Apple M2 (MacBook Air), the refactored framework achieves massive throughput improvements. After applying Container Fast-Paths and Route Pre-loading, we observed a >150% increase in performance over early v2 dev builds.

Command: wrk -t8 -c200 -d30s http://localhost:8081/health

Metric Result
Requests per Second 40,058.37
Average Latency 5.15ms
Total Requests (30s) 1,202,023
Memory Stability Stable (Zero leaks after 1.2M+ requests)

🛠 Upgrading from v1.0.5

VibeFW v2.0.0 introduces breaking changes to core execution patterns. Follow this guide to migrate your application.

1. Update Kernel Execution

The HttpKernel::handle() method no longer emits the response. You must now capture the returned object and emit it using the new SapiEmitter.

Old (v1.0.5):

$app->run(); // Implicitly called $kernel->handle($req, $res) which echoed output

New (v2.0.0):

$response = $app->getKernel()->handle($request);
(new SapiEmitter())->emit($response);

2. Mandatory QueryBuilder Re-assignment

The QueryBuilder is now immutable. Method chaining remains supported, but you must assign the result back to a variable if branching your queries.

Old (v1.0.5):

$query = $db->table('users');
$query->where('active', 1); // Modified $query in place

New (v2.0.0):

$query = $db->table('users')->where('active', 1); // Returns new instance

3. Request Property Access

Direct modification of Request properties is no longer allowed as they are now readonly. If you were manually overriding $_GET values on the Request object, you must now inject those values during construction or via the Middleware pipeline.

4. Resettable Interface

If you have custom services that store data in-memory (static arrays or class properties), they should now implement Fw\Support\ResettableInterface and be registered in the Container. This ensures they are automatically cleared between requests in worker mode.


Summary of Changes

Performance & Async Improvements

  • True Non-Blocking I/O: Refactored AsyncHttp to use non-blocking socket streams and the EventLoop watcher system.
  • Event Loop Optimization: Removed "busy-wait" loops in the Kernel. The framework now yields control back to the loop while waiting for Fiber completion.
  • Boot Optimization: Routes and global middleware are now pre-loaded once at boot time in worker mode.
  • Container Fast-Path: Added a high-speed resolution path for global singletons.

State Integrity & Safety

  • Fiber-Scoped Singletons: The Container now isolates request-scoped services per Fiber.
  • Fiber-Safe Context: RequestContext now uses a WeakMap keyed by the current Fiber to prevent data leakage between concurrent requests.
  • Leak Detection: Added a "State Integrity Check" in HttpKernel that throws a RuntimeException if request state from a previous execution is detected.
  • Memory Management: Services like MemoryCache and QueryWatcher are now automatically reset after every request.

@velkymx velkymx merged commit 742fb6f into main Mar 6, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant