Download the PHP package aegisora/guardian without Composer

On this page you can find all versions of the php package aegisora/guardian. 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 guardian

Aegisora Guardian

PHPStan Badge

Aegisora Guardian is a lightweight and extensible validation orchestrator for the Aegisora ecosystem.

The package provides a fluent and predictable way to execute validation rules against arbitrary values using the standardized architecture defined in aegisora/rule-contract.

Guardian focuses on:

The library is intentionally minimalistic while still being powerful enough to build complex domain validation layers.


✨ Features

Fluent Validation Pipeline

Guardian allows validation rules to be chained together in a readable and expressive way.

This makes complex validation scenarios easy to maintain and extend.


Rule-Based Validation

Validation logic is completely separated into independent rule objects implementing:

This promotes:


Structured Validation Flow

Guardian follows a strict validation flow:

Each rule receives a Context object and returns a standardized Result object.

No raw booleans are used internally.


Custom Exception Handling

Every rule can define its own exception.

This enables precise domain-level error handling:


Lightweight Architecture

The package has:

Guardian can be used in:


Safe Rule Execution

Internal rule execution is protected from unexpected contract-level failures.

If a rule throws RuleException, Guardian converts it into:

This keeps the validation layer consistent and isolated.


📦 Installation

Install the package via Composer:


🔗 Related Packages

Guardian is part of the broader Aegisora ecosystem.

Several ready-to-use validation rules are already implemented as separate packages and can be found in the official Aegisora repositories:

https://github.com/orgs/Aegisora/repositories

Rule repositories follow a consistent naming convention:

Examples:

These packages provide reusable validation logic fully compatible with Guardian and aegisora/rule-contract.

The ecosystem is designed to allow combining independent validation rules into flexible and composable validation pipelines.


📚 Requirements

Required Package

Guardian relies on:

which provides:


🚀 Core Concept

Guardian acts as a validation execution engine.

Instead of manually invoking validation logic throughout the application, Guardian centralizes the process and provides a consistent execution model.

Validation flow:

  1. A value is passed into Guardian
  2. Validation rules are attached
  3. Guardian creates a Context
  4. Rules are executed sequentially
  5. Every rule returns a Result
  6. Validation failures trigger exceptions

This architecture makes validation:


🏗️ Basic Usage

Simple Validation

The simplest way to validate a value is using check().

If validation passes, execution continues normally.

If validation fails, Guardian throws:


Validation with Custom Exception

You may provide a custom exception for validation failures.

If validation fails, the provided exception will be thrown instead of the default Guardian exception.

This is especially useful in:


🔗 Fluent Validation API

Guardian supports fluent rule chaining through GuardianExecutor.

Example:

Execution behavior:


Multiple Rules with Different Exceptions

Each rule may define its own exception.

This enables extremely precise validation semantics.


🧩 Real-World Example: User Registration Validation

Guardian can be used in an application service to validate incoming data before executing business logic.

In this example, a user registration command is validated by three independent rules:

Guardian does not contain validation logic itself. It receives a value, passes it into rules through Context, executes rules one by one, and stops on the first failed rule.

Registration Command

The command contains the data required to register a user.

Email Rule

This rule checks that the command contains a valid email address.

Password Rule

This rule checks that the password is at least 12 characters long and contains both an uppercase letter and a number.

Age Rule

This rule checks that the user is old enough to register.

Application Service

The service describes the validation pipeline. Each rule may have its own domain exception.

Usage

If all rules pass, the user is created.

If one rule fails, Guardian immediately stops execution and throws the exception attached to that rule.

For example, if ValidEmailRule fails, InvalidEmailException is thrown. StrongPasswordRule and AdultUserRule will not be executed.

If a rule fails internally and throws RuleException, Guardian converts it into GuardianExecutingRuleException, keeping rule execution errors separate from business validation errors.


🏛️ Architecture

Guardian contains several small and focused components.

Guardian

Main entry point for validation operations.

Responsibilities:

Methods:

GuardianExecutor

Core validation execution engine.

Responsibilities:

Methods:

GuardRule

Immutable transport object containing:

Purpose:

GuardValue

Simple wrapper around arbitrary validated value.

Purpose:


⚙️ Validation Lifecycle

Complete internal validation lifecycle:


🚨 Exceptions

Guardian defines dedicated exceptions for predictable error handling.

GuardianValidationException

Thrown when validation fails and no custom exception is provided.

Example:

The exception contains the failed rule code returned by Result.

GuardianExecutingRuleException

Thrown when internal rule execution fails due to contract-level exceptions.

Example scenario:

This protects application code from low-level rule implementation failures.


🧠 Validation Philosophy

Guardian follows several important principles.

Explicit Validation

Validation should be visible and explicit.

Bad:

Good:

Domain-Oriented Exceptions

Validation errors should communicate domain meaning.

Example:

instead of generic runtime errors.

Structured Result Objects

Rules should return standardized objects instead of booleans.

This enables:

Separation of Concerns

Guardian separates:

This keeps code maintainable and scalable.


⚖️ License

This package is open-source and licensed under the MIT License. See the LICENSE for details.


🌱 Contributing

Contributions are welcome and greatly appreciated!. See the CONTRIBUTING for details.


🌟 Support

If you find this project useful, please consider giving it a star on GitHub!

It helps the project grow and motivates further development of the Aegisora ecosystem.


All versions of guardian with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
aegisora/rule-contract Version ^1.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 aegisora/guardian contains the following files

Loading the files please wait ...