PHPackages                             fahrradkrucken/yaae - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fahrradkrucken/yaae

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

fahrradkrucken/yaae
===================

Yet Another PHP Engine

v1.0.1(6y ago)09PHP

Since Sep 8Pushed 6y ago1 watchersCompare

[ Source](https://github.com/fahrradkrucken/yaae)[ Packagist](https://packagist.org/packages/fahrradkrucken/yaae)[ RSS](/packages/fahrradkrucken-yaae/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)DependenciesVersions (7)Used By (0)

Yet Another AppEngine
=====================

[](#yet-another-appengine)

This peace of "code" is a simple start point for your codebase. Please, keep in mind 3 simple facts: it's not a framework, it was written in about 16 hours, most of it made while author was drunk. The good part is - it has no external dependencies.

Application Lifecycle
---------------------

[](#application-lifecycle)

#### Quick Start

[](#quick-start)

Basically it's just a Request-Response handler. See simple example in `demo/demo.php`.

#### Action Callbacks

[](#action-callbacks)

You can use any `callable` parameter, or some kind of Laravel style `ControllerClass@actionMethod`.

#### Request &amp; Response

[](#request--response)

Well, Request &amp; Response objects are not interesting at all, and they're not like PSR best practices. But! But you can manipulate them as you want, so they could become more pretty with your code. We have 3 rules:

- Request Handler accepts 1 arg `RequestInterface $request` and SHOULD return `RequestInterface $request`. If you'll not return `RequestInterface`, everything will be fine anyway, so you can just do something inside your "Request Middleware" and return nothing;
- Action handler accepts 2 args `RequestInterface $request, ResponseInterface $response` and SHOULD return `ResponseInterface $response`;
- Response Handler accepts 1 arg `ResponseInterface $response` and SHOULD return `ResponseInterface $response`. We have here the same rules as for request handlers.

Request handlers will be executed from external (global or group) level to internal (individual route) level. Response handlers will be executed in reverse order.

Configuration
-------------

[](#configuration)

#### Main Config

[](#main-config)

You can replace request method and path through:

- `$engine->setRequestPath(string $requestPath)`, default is `$_SERVER['REQUEST_URI']`, without `/` at the end and without params after `?`;
- `$engine->setRequestMethod(string $requestMethod)`, default is `$_SERVER['REQUEST_METHOD']`

You can replace default classes:

- `FahrradKrucken\YAAE\Http\Request` through `$engine->setRequest(RequestInterface $request)`;
- `FahrradKrucken\YAAE\Http\Response` through `$engine->setResponse(ResponseInterface $response)`;
- `FahrradKrucken\YAAE\Core\RouteHandler` through `$engine->setRouteHandler(RouteHandlerInterface $routeHandler)`.

#### Errors

[](#errors)

You can replace error handlers:

- `\Throwable` errors handler through `$engine->setErrorHandler(callable $errorHandler)`;
- `\FahrradKrucken\YAAE\Http\Error` errors handler through `$engine->setErrorHandlerHttp(callable $errorHandler)`.

Note that `\FahrradKrucken\YAAE\Http\Error` has `$request` and `$response` props, it could be useful. For example, when you'll get 404 (Not Found) or 405 (Method not allowed) error from `RouteHandler`, you can understand this by `$errorHttp->getCode()`.

Examples for API errors:

```
