Skip to content

Commit

Permalink
Simplify documentation by omitting optional LoopInterface argument
Browse files Browse the repository at this point in the history
  • Loading branch information
clue committed Jun 18, 2021
1 parent 26e6a51 commit 74dcc40
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 39 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ empty project directory:

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

$loop = React\EventLoop\Factory::create();
$app = new FrameworkX\App($loop);
$app = new FrameworkX\App();

$app->get('/', function () {
return new React\Http\Message\Response(
Expand All @@ -41,7 +40,6 @@ $app->get('/users/{name}', function (Psr\Http\Message\ServerRequestInterface $re
});

$app->run();
$loop->run();
```

Next, we need to install X and its dependencies to actually run this project.
Expand Down
25 changes: 1 addition & 24 deletions docs/api/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,19 @@
The `App` class is your main entrypoint to any application that builds on top of X.
It provides a simple API for routing HTTP requests as commonly used in RESTful applications.

Internally, the `App` object builds on top of [ReactPHP](https://reactphp.org/)
to do its magic, hence you have to create it like this:

```php
# app.php
<?php

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

$loop = React\EventLoop\Factory::create();
$app = new FrameworkX\App($loop);
$app = new FrameworkX\App();

// Register routes here, see routing…

$app->run();
$loop->run();
```

> ℹ️ **Heads up!**
>
> Major improvements upcoming! We're actively contributing to our underlying
> libraries to make sure this can look like this in the near future:
>
> ```php
> # app.php
> <?php
>
> require __DIR__ . '/vendor/autoload.php';
>
> $app = new FrameworkX\App();
>
> // Register routes here, see routing…
>
> $app->run();
> ```
## Routing

The `App` class offers a number of API methods that allow you to route incoming
Expand Down
4 changes: 1 addition & 3 deletions docs/api/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,11 @@ a global middleware handler for all registered routes:
use Acme\Todo\AdminMiddleware;
use Acme\Todo\UserController;

$loop = React\EventLoop\Factory::create();
$app = new FrameworkX\App($loop, new AdminMiddleware());
$app = new FrameworkX\App(new AdminMiddleware());

$app->get('/user', new UserController());

$app->run();
$loop->run();
```

You can also combine global middleware handlers (think logging) with additional
Expand Down
8 changes: 2 additions & 6 deletions docs/best-practices/controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ To get started, let's take a look at the following simple closure definitions:

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

$loop = React\EventLoop\Factory::create();
$app = new FrameworkX\App($loop);
$app = new FrameworkX\App();

$app->get('/', function () {
return new React\Http\Message\Response(
Expand All @@ -33,7 +32,6 @@ $app->get('/users/{name}', function (Psr\Http\Message\ServerRequestInterface $re
});

$app->run();
$loop->run();
```

While easy to get started, it's also easy to see how this will get out of hand for more complex
Expand All @@ -49,14 +47,12 @@ definition into three even simpler files:

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

$loop = React\EventLoop\Factory::create();
$app = new FrameworkX\App($loop);
$app = new FrameworkX\App();

$app->get('/', new Acme\Todo\HelloController());
$app->get('/users/{name}', new Acme\Todo\UserController());

$app->run();
$loop->run();
```

```php
Expand Down
4 changes: 1 addition & 3 deletions docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ You can use this example to get started by creating a new `app.php` file in your

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

$loop = React\EventLoop\Factory::create();
$app = new FrameworkX\App($loop);
$app = new FrameworkX\App();

$app->get('/', function () {
return new React\Http\Message\Response(
Expand All @@ -42,7 +41,6 @@ $app->get('/users/{name}', function (Psr\Http\Message\ServerRequestInterface $re
});

$app->run();
$loop->run();
```

On a code level, this is everything you need to get started.
Expand Down

0 comments on commit 74dcc40

Please sign in to comment.