Download the PHP package luany/framework without Composer
On this page you can find all versions of the php package luany/framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package framework
luany/framework
Application framework for Luany. IoC container, HTTP kernel, sessions, validation, config, CSRF, i18n.
Version: v1.0.0 | PHP: >= 8.2 | License: MIT Author: António Ambrósio Ngola | Org: luany-ecosystem
Table of Contents
- Overview
- Installation
- Application Container
- HTTP Kernel
- Config
- Session
- Validation
- CSRF Protection
- Exception Handling
- Helpers
- Service Providers
- Changelog
1. Overview
luany/framework is the application layer of the Luany ecosystem. It wires together the IoC container, HTTP lifecycle, session management, validation, configuration, and i18n into a coherent application runtime.
It depends on luany/core for routing, request and response primitives, and on luany/lte for the template engine.
2. Installation
The framework is typically used through the application skeleton (luany/luany), which already configures everything correctly.
3. Application Container
The Application class is the IoC container and global registry.
The Application instance is accessible globally via app().
Auto-resolution
Classes with no constructor dependencies are auto-resolved:
Service Provider lifecycle
Path helpers
4. HTTP Kernel
The Kernel orchestrates the full HTTP request lifecycle.
Boot sequence
boot() runs in order:
registerConfig()— loadsconfig/*.phpregisterSession()— startsFileSessionregisterCsrf()— bindsCsrfTokenregisterLte()— binds the LTE view engineloadRoutes()— requiresroutes/http.phpbootProviders()— callsboot()on all registered providers
Global middleware
Override in your application kernel:
Middleware runs on every request, before routing.
5. Config
Loads PHP files from config/ and provides dot-notation access.
Direct usage:
6. Session
Cookie-based sessions backed by the filesystem (file-per-session in storage/sessions/).
Flash data is available on the next request only:
Old input is automatically available via old() after a failed validate():
7. Validation
Validator directly
validate() helper — recommended
The validate() helper removes all boilerplate from controllers. On failure it automatically flashes errors and old input to the session, then throws a ValidationException which the Kernel resolves as a redirect.
On failure the user is redirected to /users/create with errors and old input in session. The third argument defaults to $_SERVER['HTTP_REFERER'] if omitted.
In the view:
Available rules
| Rule | Description |
|---|---|
required |
Field must be present and non-empty |
string |
Must be a string |
email |
Must be a valid email address |
numeric |
Must be numeric |
min:N |
Minimum length (string) or value (numeric) |
max:N |
Maximum length (string) or value (numeric) |
in:a,b,c |
Must be one of the listed values |
confirmed |
Must match {field}_confirmation |
unique:table,col |
Must not already exist (requires setUniqueChecker) |
unique rule with database
8. CSRF Protection
CsrfToken generates and validates tokens stored in the session.
In LTE templates, use @csrf:
The CsrfMiddleware automatically validates tokens on POST, PUT, PATCH, DELETE requests. It skips validation for GET, HEAD, OPTIONS.
9. Exception Handling
abort()
Abort the current request with an HTTP status code:
Throws HttpException which the Kernel converts to the appropriate response.
Custom handler
Register in a service provider:
Exception priority in Kernel
ValidationException→ flash is already done → redirect to$e->getRedirectTo()HttpException→Response::make($message, $statusCode)RouteNotFoundException→Response::notFound()- Everything else → custom
Handler::render()orResponse::serverError()
10. Helpers
All helpers are in src/Support/helpers.php and auto-loaded via Composer.
| Helper | Description |
|---|---|
app(?string $abstract) |
Resolve from container |
env(string $key, mixed $default) |
Get environment variable |
base_path(string $path) |
Absolute path from app root |
view(string $name, array $data) |
Render a view via LTE |
redirect(string $url, int $status) |
Create redirect Response |
response(string $body, int $status) |
Create Response |
config(string $key, mixed $default) |
Get config value |
session(?string $key, mixed $default) |
Get session or value |
csrf_token() |
Get current CSRF token |
old(string $key, mixed $default) |
Get previous request input |
validate(array $data, array $rules, string $back) |
Validate or throw |
abort(int $code, string $message) |
Abort with HTTP error |
__(string $key, array $replace) |
Translate a key |
locale() |
Get current locale |
11. Service Providers
Service providers are the recommended way to register application bindings.
Register in bootstrap/app.php:
Total: OK (174 tests, 223 assertions)
12. Changelog
next/v1 — Phase 6
New:
src/Exceptions/HttpException.php— thrown byabort(), carries status code and messagesrc/Exceptions/ValidationException.php— thrown byvalidate()on failure, carries errors + redirect URLhelpers.php— addedabort(int $code, string $message = ''): neverhelpers.php— addedvalidate(array $data, array $rules, string $back = ''): array
Modified:
src/Http/Kernel.php—handleException()handlesValidationExceptionandHttpExceptionbefore custom handler
v0.4.0 — Phase 2
IoC container (Application), HTTP Kernel, FileSession, Config, CsrfToken, CsrfMiddleware, Validator (9 rules), Translator, LocaleMiddleware. Full helpers.php: app(), env(), base_path(), view(), redirect(), response(), config(), session(), csrf_token(), old(), __(), locale().
All versions of framework with dependencies
luany/core Version ^1.0
luany/lte Version ^1.0
vlucas/phpdotenv Version ^5.6
psr/log Version ^3.0