orb/orb

A quick and easy framework to rapidly create API or simple website.

1.1.2 2025-04-12 10:23 UTC

This package is auto-updated.

Last update: 2025-06-12 10:36:30 UTC


README

Latest Stable Version License

Orb

A simple and fast framework to build REST APIs and simple web applications.


Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Testing
  5. Contributing
  6. License
  7. Acknowledgments

About The Project

Quickly and easily create REST APIs and simple web applications with Orb.
Versatile enough to build any kind of application, and simple enough to be used by beginners.

(back to top)

Getting Started

Prerequisites

You need PHP >= 8.2 to use Orb but the latest stable version of PHP is always recommended.

Installation

Via composer :

composer require orb/orb

(back to top)

Usage

require_once __DIR__.'/vendor/autoload.php';

use Orb\Orb;

$orb = new Orb();

$orb->get('/', 'Hello world !');
$orb->get('/using-function', fn() => 'Hello world !');
$orb->get('/using-invoke', MyController::class);
$orb->get('/using-class-method-1', 'MyController::method1');
$orb->get('/using-class-method-2', 'MyController->method2');
$orb->get('/psr7-response', fn() => new \Laminas\Diactoros\Response\HtmlResponse('Hello world !'));

$orb->run();

It is possible to return mostly anything from a route handler.
If you do not return a PSR-7 ResponseInterface, Orb will try to convert the returned value to a ResponseInterface.

Note that Orb will return a JSON response if the returned value is an array or an object, and an XML response if the returned value is a SimpleXMLElement or DOMDocument.
The default response is a text/html response.

(back to top)

Testing

This package uses Pest as test framework.
To run tests :

./vendor/bin/pest tests

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See License File for more information.

(back to top)