clue/framework-x

Framework X – the simple and fast micro framework for building reactive web applications that run anywhere.

dev-main 2021-12-20 08:11 UTC

This package is auto-updated.

Last update: 2021-12-20 08:11:38 UTC


README

CI status

Framework X – the simple and fast micro framework for building reactive web applications that run anywhere.

Quickstart

Start by creating an empty project directory. Next, we can start by taking a look at a simple example application. You can use this example to get started by creating a new public/ directory with an index.php file inside:

<?php

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

$app = new FrameworkX\App();

$app->get('/', function () {
    return new React\Http\Message\Response(
        200,
        [],
        "Hello wörld!\n"
    );
});

$app->get('/users/{name}', function (Psr\Http\Message\ServerRequestInterface $request) {
    return new React\Http\Message\Response(
        200,
        [],
        "Hello " . $request->getAttribute('name') . "!\n"
    );
});

$app->run();

Next, we need to install X and its dependencies to actually run this project. In your project directory, simply run the following command:

$ composer require clue/framework-x:dev-main

That's it already! The next step is now to serve this web application. One of the nice properties of this project is that is works both behind traditional web server setups as well as in a stand-alone environment.

For example, you can run the above example using the built-in web server like this:

$ php public/index.php

You can now use your favorite web browser or command line tool to check your web application responds as expected:

$ curl http://localhost:8080/
Hello wörld!

Documentation

Hooked? See website for full documentation.

Found a typo or want to contribute? The website documentation is build from the source documentation files in the docs/ folder.

Tests

To run the test suite, you first need to clone this repo and then install all dependencies through Composer:

$ composer install

To run the test suite, go to the project root and run:

$ vendor/bin/phpunit --stderr

Additionally, you can run some simple acceptance tests to verify the framework examples work as expected behind your web server. Use your web server of choice (see deployment documentation) and execute the tests with the URL to your installation like this:

$ php examples/index.php
$ tests/acceptance.sh http://localhost:8080

License

This project is released under the permissive MIT license.

Did you know that I offer custom development services and issuing invoices for sponsorships of releases and for contributions? Contact me (@clue) for details.