Ruvel Framework
Ruvel is an asynchronous, expressive web framework for Rust inspired directly by Laravel's architecture and developer ergonomics. Built on top of Tokio, Ruvel brings the elegant patterns of PHP's most beloved framework—Service Providers, IoC Containers, Resource Controllers, and Responsable contracts—into the high-performance, type-safe world of Rust.
Features
- Application Kernel & Two-Phase Lifecycle: Clean separation between service registration (
register) and bootstrapping (boot). - Laravel-Inspired Service Providers: Decouple components with
ServiceProvidercontracts (Illuminate\Support\ServiceProvider). - Flexible HTTP Routing: Expressive routing for
GET,POST,PUT,DELETE, andPATCH. ResponsableContract: Route handlers can return anything implementingResponsable(&'static str,String, tuples, or models) without manual boilerplate.- Smart Defaults: Defaults to
Content-Type: text/html; charset=utf-8for web responses, with fluent helpers for.json(),.text(), and.html(). - RFC-Compliant
HttpStatus& Case-Insensitive Headers: Strongly typedHttpStatusenum with numeric codes, canonical reason phrases, and Symfony-style constants (Response::HTTP_OK,Response::HTTP_CREATED). - Resource Controllers: Pre-configured RESTful actions (
index,create,store,show,edit,update,destroy) with sensible default fallback responses.
Project Structure
src/
├── config/ # Application configuration
├── container/ # IoC / Dependency Injection container
├── contracts/ # Core framework contracts & interfaces
│ └── support/
│ └── responsable.rs # Responsable trait (Illuminate\Contracts\Support\Responsable)
├── database/ # Database layer and Eloquent ORM
│ └── eloquent/ # Eloquent model implementations
├── foundation/ # Application bootstrap & TCP connection listener
├── http/ # HTTP kernel, Request, Response, Headers, and Controllers
│ ├── controllers.rs # RESTful resource Controller trait
│ ├── headers.rs # Case-insensitive HeaderMap
│ ├── request.rs # HTTP Request parser & methods
│ ├── response.rs # Fluent HTTP Response builder
│ └── status.rs # Strongly-typed HttpStatus enum & RFC status codes
├── routing/ # Router & dispatch engine
└── support/ # ServiceProvider trait & utilities
Quick Start
1. Basic Application
use Application;
use ;
async
Core Concepts
Service Providers
Just like Laravel's AppServiceProvider, providers in Ruvel have two distinct lifecycle stages:
register(&self, container: &mut Container): Bind singletons or services into the container.boot(&self, container: &Container, router: &mut Router): Register routes or resolve initialized dependencies.
use async_trait;
use Container;
use Router;
use ServiceProvider;
;
Register providers during application setup:
let app = new
.register_provider
.await;
The Responsable Contract
Ruvel mirrors Illuminate\Contracts\Support\Responsable. Any type implementing Responsable can be returned directly from route handlers:
use Responsable;
use Response;
// In your router:
router.get;
Resource Controllers
Resource controllers provide default implementations for all standard actions. Implement only what your resource needs:
use async_trait;
use Responsable;
use ;
;
HTTP Status Codes & Headers
HttpStatus: RFC-compliant enum withstatus.code()(e.g.200,404) andstatus.message()(e.g."OK","Not Found").- Constants: Access constants directly via
Response::HTTP_OK,Response::HTTP_CREATED,Response::HTTP_NOT_FOUND, etc. - Case-Insensitive Headers: Headers can be fetched using any casing (
Content-Type,content-type,CONTENT-TYPE).
let res = ok
.header
.html;
assert_eq!;
assert_eq!;
Roadmap
- Route parameters & regex matching (
/posts/{id}) - Onion-style HTTP middleware pipeline (
Request -> Next -> Response) - Type-safe dependency resolution in IoC container (
Arc<dyn Any>) - Validation & FormRequest abstractions
- Eloquent query builder & migrations
- Artisan CLI integration with
clap
License
This project is licensed under the MIT License or Apache-2.0 License.