Download the PHP package webfiori/rest-easy without Composer

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

WebFiori HTTP

A powerful and flexible PHP library for creating RESTful web APIs with built-in input filtering, data validation, and comprehensive HTTP utilities. The library provides a clean, object-oriented approach to building web services with automatic parameter validation, authentication support, and JSON response handling.

Table of Contents

Motivation

With well-established PHP HTTP libraries available, you might wonder why this one exists.

Validation is not optional. In most frameworks, input validation is a separate step you wire up after defining your routes. Here, you cannot define an endpoint without declaring exactly what data it accepts, its type, and how it should be validated. The API contract is the code.

Minimal dependencies. The library has a single runtime dependency (webfiori/jsonx). No PSR-7 stack, no framework coupling, no transitive dependency tree. What you install is what you get.

One service, one unit. Each endpoint is a self-contained object with its own parameters, authorization logic, and processing — independently testable and self-documenting. Built-in OpenAPI spec generation is a natural result of this design.

Full control. Request parsing, header management, content negotiation, and response handling are all implemented internally. No hidden layers, no framework tax.

Supported PHP Versions

Build Status

Key Features

Installation

Using Composer (Recommended)

Manual Installation

Download the latest release from GitHub Releases and include the autoloader:

Quick Start

Modern Approach with Attributes (Recommended)

PHP 8+ attributes provide a clean, declarative way to define web services:

Traditional Approach

For comparison, here's the traditional approach using constructor configuration:

Both approaches work with RequestProcessor (recommended) or WebServicesManager:

Core Concepts

Terminology

Term Definition
Web Service A single endpoint that implements a REST service, represented by AbstractWebService
Services Manager An entity that manages multiple web services, represented by WebServicesManager
Request Parameter A way to pass values from client to server, represented by RequestParameter
API Filter A component that validates and sanitizes request parameters

Architecture Overview

The library follows a service-oriented architecture:

  1. AbstractWebService: Base class for all web services
  2. WebServicesManager: Manages multiple services and handles request routing
  3. RequestParameter: Defines and validates individual parameters
  4. APIFilter: Handles parameter filtering and validation
  5. Request/Response: Utilities for handling HTTP requests and responses

Creating Web Services

Using Attributes (Recommended)

PHP 8+ attributes provide a modern, declarative approach:

Traditional Class-Based Approach

Every web service must extend AbstractWebService and implement the processRequest() method:

Service Configuration

Setting Request Methods

Service Metadata

Parameter Management

Parameter Types

The library supports various parameter types through ParamType:

Adding Parameters

Simple Parameter Addition

Batch Parameter Addition

Parameter Options

Available options through ParamOption:

Custom Validation

Retrieving Parameter Values

Positional Parameter Injection

When using #[ResponseBody], method parameters are matched positionally to #[RequestParam] attributes. The PHP variable names do not need to match the request parameter names:

Allowing Empty Strings

By default, sending an empty string for a string parameter results in a validation error. Use allowEmpty: true in the #[RequestParam] attribute to accept empty strings:

This is the attribute equivalent of ParamOption::EMPTY => true in the array-based approach.

Reusable Parameter Sets

Implement the ParameterSet interface to group related parameters:

Use with attributes:

Or traditionally:

Cross-Field Validation

For validation rules that depend on multiple parameters together, use the #[Validate] attribute or override the validate() method:

Method-Specific Validation (Attribute)

Service-Wide Validation (Override)

Both run if defined — service-wide first, then method-specific. Errors are merged. If any errors exist, the request returns 422 with the error details.

Dynamic Status Codes with ResponseEntity

The ResponseEntity class allows #[ResponseBody] methods to return different HTTP status codes based on runtime logic:

Available Factory Methods

Method Status Code Use Case
ResponseEntity::ok($body) 200 Successful response
ResponseEntity::created($body) 201 Resource created
ResponseEntity::noContent() 204 Successful deletion
ResponseEntity::badRequest($body) 400 Invalid input
ResponseEntity::unauthorized($body) 401 Authentication failure
ResponseEntity::forbidden($body) 403 Authorization failure
ResponseEntity::notFound($body) 404 Resource not found
ResponseEntity::error($body) 500 Server error

You can also use the constructor directly for custom status codes:

Testing

Using ServiceTestCase

Examples

Complete CRUD Service Example

For more examples, check the examples directory in this repository.

Key Classes Documentation

Content Negotiation

Use #[Produces] to declare what content types a method can return. The framework matches against the client's Accept header:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Changelog

See CHANGELOG.md for a list of changes and version history.


All versions of rest-easy with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
webfiori/jsonx Version 5.0.x
ext-json Version *
ext-mbstring Version *
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 webfiori/rest-easy contains the following files

Loading the files please wait ...