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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

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

  1. Overview
  2. Installation
  3. Application Container
  4. HTTP Kernel
  5. Config
  6. Session
  7. Validation
  8. CSRF Protection
  9. Exception Handling
  10. Helpers
  11. Service Providers
  12. Localisation
  13. Logging
  14. 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().

Autowiring

Unbound concrete classes are built via reflection. Constructor parameters are resolved from their class/interface type; scalar parameters use their default value and nullable parameters fall back to null:

Circular dependencies (A → B → A) throw Container\CircularDependencyException with the full chain.

PSR-11

Application implements Psr\Container\ContainerInterface:

get()/make() throw Container\NotFoundException (PSR NotFoundExceptionInterface) when nothing is bound and the class does not exist, and Container\ContainerException when an entry cannot be built. Both extend RuntimeException.

Controllers and middleware

During boot() the Kernel registers the container as luany/core's class resolver (Pipeline::setDefaultResolver() / Router::setResolver(), luany/core

= 1.1), so controllers and route middleware get constructor injection. Global Kernel middleware is always resolved through the container, also on luany/core 1.0.

With luany/core >= 1.2 the Kernel also registers Application::call() as the router's action invoker, so controller methods and closure routes get arguments injected:

Application::call(callable, array $parameters) is also available directly.

Service Provider lifecycle

Path helpers


4. HTTP Kernel

The Kernel orchestrates the full HTTP request lifecycle.

Boot sequence

boot() registers the framework defaults, then loads routes and boots providers. Every default is registered only if a service provider has not already bound it (under either the string key or the class name), so providers can replace any of them:

Key Class alias Default
config Support\Config loads config/*.php
session Contracts\SessionInterface FileSession (options from config/session.php)
csrf Security\CsrfToken session-backed token
view Luany\Lte\Engine LTE engine (also tells Luany\Lte\Runtime about debug mode, lte >= 1.1)
translator Support\Translator lang/{locale}.php (see §12)
log Psr\Log\LoggerInterface Log\FileLogger (see §13)

Then: wire the container as luany/core resolver → load routes/*.php → bootProviders().

Global middleware

Override in your application kernel:

Middleware runs on every request, before routing. Entries are resolved through the container, so constructor dependencies are injected.


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/).

Security defaults

FileSession configures PHP before session_start():

Option Default
httponly true
samesite 'Lax'
secure null = automatic (on when the request is HTTPS)
strict_mode true (session.use_strict_mode)
only_cookies true (session.use_only_cookies, no trans-sid)
name, lifetime, path, domain PHP defaults / 0 / '/' / ''

Override them in an optional config/session.php (plus save_path):

On login and logout, rotate both the session ID and the CSRF token:

Flash data is available on the next request only:

Old input is automatically available via old() after a failed validate():

Sensitive fields are never flashed: password*, _token, csrf_token, _method (extend with ValidationException::$dontFlash[] = 'card_number';).


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. If the third argument is omitted, the Referer is used only when it points to the current host; otherwise the redirect goes to / (prevents open redirects).

When the request expects JSON (Accept: application/json or X-Requested-With: XMLHttpRequest) the Kernel returns 422 instead of redirecting:

In the view:

Available rules

Rule Description
required Field must be present and non-empty
sometimes Validate only when the field is present
nullable null/'' accepted (other rules skipped, '' becomes null)
string Must be a string
email Must be a valid email address
integer Integer or integer string ("42", "-3")
numeric Must be numeric
boolean true/false/1/0/"1"/"0"/"true"/"false"/"on"/"off"/"yes"/"no", cast to bool
array Must be an array
date Parseable date
after:date\|field, before:… Date after/before a date or another field
after_or_equal:…, before_or_equal:… Inclusive variants
min:N / max:N Length (string), value (numeric) or item count (array)
between:min,max Inclusive, same semantics as min/max
digits:N Exactly N digits
in:a,b,c / not_in:a,b Must (not) be one of the listed values
regex:/…/ / not_regex:/…/ Must (not) match — use array syntax if the pattern contains \|
url Absolute http/https URL
confirmed Must match {field}_confirmation
same:field / different:field Must equal / differ from another field
unique:table,col,ignore,ignoreCol No row has col = value (col defaults to the field; ignore skips the current record, ignoreCol defaults to id)
exists:table,col A row has col = value; for arrays, every element must exist

Unknown rules throw InvalidArgumentException — a typo never silently disables validation.

Except for required, confirmed and boolean, rules skip null/'' values.

Absent fields are still processed. A field with the boolean rule that is missing from the input (an unchecked checkbox) validates to false and is included in validated(); add sometimes to leave it out instead. Other absent fields are not included in validated().

Custom rules

Closures return true/null (pass), false (generic message) or a string (error message). Custom rules are skipped for null/'' values.

unique / exists — database rules

The Kernel wires these rules to the application database automatically when a db binding (PDO) exists — the skeleton's DatabaseServiceProvider registers it. Nothing is queried until a rule runs. Table and column names in rules are validated and quoted; values are always bound.

Elsewhere (scripts, tests), register a verifier yourself:

Without a verifier, unique and exists throw a LogicException — they never pass silently. setUniqueChecker() still works but is deprecated.


8. CSRF Protection

Ecosystem convention:

Name
Form field _token (CsrfToken::FIELD) — legacy csrf_token also accepted
Session key _csrf_token (CsrfToken::SESSION_KEY)
Header X-CSRF-TOKEN (CsrfToken::HEADER)

The token is per session and is not rotated on every request.

In forms:

Register Luany\Framework\Http\Middleware\CsrfMiddleware in the Kernel's $middleware (or as route middleware). It validates POST, PUT, PATCH, DELETE and skips GET, HEAD, OPTIONS. On mismatch it returns 403 (JSON {"message": "CSRF token mismatch."} for JSON requests); non-string input such as _token[]=x is treated as missing, never a 500.


9. Exception Handling

abort()

Abort the current request with an HTTP status code:

Throws HttpException which the Kernel converts to the matching status. The message is HTML-escaped (safe with user input); JSON requests get {"message": …}.

Custom handler

Register in a service provider:

The base Handler::render() keeps HTTP statuses: HttpException → its status, RouteNotFoundException → 404, MethodNotAllowedException → 405 (with Allow), ValidationException → 422; everything else → 500 (debug page when debug is on). Handler::report() logs through the container logger and skips those expected HTTP exceptions ($dontReport).

Exception priority in Kernel

  1. ValidationException → 422 JSON when the request expects JSON, else redirect to $e->getRedirectTo()
  2. HttpException → its status and headers (escaped HTML or JSON)
  3. MethodNotAllowedException → 405 with Allow header
  4. Everything else → bound Handler (report() + render()); without one, RouteNotFoundException → 404 and other exceptions are logged and → 500

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\|array\|null $key, mixed $default) Repository, value, or set values
session(?string $key, mixed $default) Get session or value
csrf_token() Get current CSRF token
csrf_field() Hidden _token input
logger(?string $message, array $context, string $level = 'debug') PSR-3 logger, or write a record
old(string $key, mixed $default) Get previous request input
validate(array $data, array $rules, string $back) Validate or throw
abort(int $code, string $message, array $headers) Abort with HTTP error
__(string $key, array $replace) Translate a key
locale() Get current locale
url(string $path = '') Absolute URL (from app.url / APP_URL)
route(string $name, array $params) URL of a named route
asset(string $path) URL of a file in public/assets
e(mixed $value) HTML-escape a value
flash(string $type, string $message) / get_flash() One-request flash message

Live reload

Luany\Framework\Http\Middleware\LiveReloadMiddleware serves the luany dev browser client and injects it into HTML responses — only when APP_ENV=development (or local) and the request comes from the loopback interface. Register it first in the application Kernel.

Timezone

config('app.timezone') (or APP_TIMEZONE) is applied with date_default_timezone_set() during boot; invalid identifiers are ignored.


11. Service Providers

Service providers are the recommended way to register application bindings.

Register in bootstrap/app.php:


12. Localisation

A default translator is registered by the Kernel, so __(), locale() and LocaleMiddleware work without a custom provider. Translation files live in lang/{locale}.php. Settings come from config/app.php, then .env:

config/app.php .env Default
locale APP_LOCALE en
fallback_locale APP_FALLBACK_LOCALE en
supported_locales APP_SUPPORTED_LOCALES (comma list) [locale, fallback]

LocaleMiddleware picks the locale from the app_locale cookie, then Accept-Language (languages with q=0 are ignored), then APP_LOCALE.


13. Logging

The Kernel binds a PSR-3 Log\FileLogger as log / Psr\Log\LoggerInterface, writing daily files to storage/logs/luany-YYYY-MM-DD.log:

Optional config/logging.php: path, channel (luany), level (LOG_LEVEL, default debug), daily (true). Unhandled exceptions are logged by the Kernel (or by Handler::report() when an app handler is bound). The helper is named logger() because PHP already defines a global log() function.


14. Changelog

next/v1 — Phase 6

New:

Modified:

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

PHP Build Version
Package Version
Requires php Version >=8.2
luany/core Version ^1.2
luany/lte Version ^1.4
vlucas/phpdotenv Version ^5.6
psr/log Version ^3.0
psr/container Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package luany/framework contains the following files

Loading the files please wait ...