Hypervel
A Laravel-Style PHP Framework for Web Artisans.
Laravel Friendly
By porting Laravel's core infrastructure and fundamental components, this framework enables Laravel developers to quickly adapt to it.
High Performance
Leveraging Swoole's native coroutine support, it delivers exceptional performance and efficient concurrency handling.
Ecosystem Compatibility
Hypervel is compatible with the Hyperf ecosystem, sharing the same community resources and packages.
Coding Like in Laravel
Laravel artisans can enjoy a familiar development experience that mirrors the original framework. The simple, elegant syntax remains intact, enabling developers to stay productive while leveraging enhanced performance.
- Authentication
- Authorization
- Eloquent ORM
- Database Migrations
- Validation
- Notification and Email
- File Storage
- Job Queues
- Task Scheduling
- Testing
- Events
Authentication
Authenticating users is as simple as adding an authentication middleware to your Hypervel route definition:
Route::get('/profile', ProfileController::class, [
'middleware' => 'auth'
]);
Once the user is authenticated, you can access the authenticated user via the Auth facade:
use Hypervel\Support\Facades\Auth;
$user = Auth::user();
Of course, you may define your own authentication middleware, allowing you to customize the authentication process.
Eloquent
Scared of databases? Don't be. Hypervel’s Eloquent ORM makes it painless to interact with your application's data, and models, migrations, and relationships can be quickly scaffolded:
php artisan make:model Invoice --migration
Once you've defined your model structure and relationships, you can interact with your database using Eloquent's powerful, expressive syntax:
// Create a related model...
$user->invoices()->create(['amount' => 100]);
// Update a model...
$invoice->update(['amount' => 200]);
// Retrieve models...
$invoices = Invoice::unpaid()->where('amount', '>=', 100)->get();
// Rich API for model interactions...
$invoices->each->pay();
Database Migrations
Migrations are like version control for your database, allowing your team to define and share your application's database schema definition:
return new class extends Migration {
public function up()
{
Schema::create('flights', function (Blueprint $table) {
$table->uuid()->primary();
$table->foreignUuid('airline_id')->constrained();
$table->string('name');
$table->timestamps();
});
}
};
Validation
Laravel has over 90 powerful, built-in validation rules and, using Hypervel Precognition, can provide live validation on your frontend:
public function update(Request $request)
{
$validated = $request->validate([
'email' => 'required|email|unique:users',
'password' => Password::required()->min(8),
]);
$request->user()->update($validated);
}
Notifications & Mail
Use Hypervel to quickly send beautifully styled notifications to your users via email, Slack, SMS, in-app, and more:
php artisan make:notification InvoicePaid
Once you have generated a notification, you can easily send the message to one of your application's users:
$user->notify(new InvoicePaid($invoice));
File Storage
Hypervel provides a robust filesystem abstraction layer, providing a single, unified API for interacting with local filesystems and cloud based filesystems like Amazon S3:
$path = Storage::disk('s3')
->put('avatars/1', $request->file('avatar'));
Regardless of where your files are stored, interact with them using Hypervel's simple, elegant syntax:
$content = Storage::get('photo.jpg');
Storage::put('photo.jpg', $content);
Job Queues
Hypervel lets you to offload slow jobs to a background queue, keeping your web requests snappy:
$podcast = Podcast::create(/* ... */);
ProcessPodcast::dispatch($podcast)->onQueue('podcasts');
You can run as many queue workers as you need to handle your workload:
php artisan queue:work redis --queue=podcasts
Task Scheduling
Schedule recurring jobs and commands with an expressive syntax and say goodbye to complicated configuration files:
$schedule->job(NotifySubscribers::class)->hourly();
Hypervel's scheduler can even handle multiple servers and offers built-in overlap prevention:
$schedule->job(NotifySubscribers::class)
->dailyAt('9:00')
->onOneServer()
->withoutOverlapping();
Testing
Hypervel is built for testing. From unit tests to feature tests, you’ll feel more confident in deploying your application:
class RefreshDatabaseTest extends TestCase
{
use RefreshDatabase;
public function testCreateUser()
{
$user = factory(User::class)->create();
$this->assertDatabaseHas('users', [
'id' => $user->id,
]);
}
}
Events & Websockets
Hypervel's events allow you to send and listen for events across your application, and listeners can easily be dispatched to a background queue:
OrderShipped::dispatch($order);
class SendShipmentNotification implements ShouldQueue
{
public function handle(OrderShipped $event): void
{
// ...
}
}
Your frontend application can even subscribe to your Hypervel events using Laravel Echo and WebSockets, allowing you to build real-time, dynamic applications:
Echo.private(`orders.${orderId}`)
.listen('OrderShipped', (e) => {
console.log(e.order);
});
Frequently Asked Questions
Is Hypervel compatible with Laravel packages?
While Hypervel maintains the similar development experience like Laravel, you can't install Laravel packages on this framework due to the fundamental differences in architecture. However, many Laravel concepts and patterns can be easily adapted for use with Hypervel.
How does Hypervel achieve high performance?
Hypervel achieves high performance through Swoole's coroutine system, which enables non-blocking I/O operations and efficient concurrency handling. This allows the framework to handle more concurrent connections with fewer resources compared to traditional PHP-FPM.
Why not use Octane directly?
Octane accelerates Laravel by maintaining the framework in a persistent application state, resetting request-scoped resources between requests. However, it doesn't introduce non-blocking I/O capabilities to Laravel's architecture. Furthermore, all components in Laravel weren't designed with coroutines in mind. It will cause states pollution while context switching among coroutines.
For I/O-intensive scenarios, even with Octane's improvements, your application's ability to handle concurrent requests is still limited by the duration of these I/O operations.