Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello Framework X! #14

Merged
merged 1 commit into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ jobs:
with:
php-version: ${{ matrix.php }}
- run: composer install --no-dev
- run: docker run -d -v "$PWD":/home/frugal php:${{ matrix.php }}-fpm
- run: docker run -d -p 80:80 --link $(docker ps -qn1):php -v "$PWD":/home/frugal -v "$PWD"/examples/nginx/nginx.conf:/etc/nginx/conf.d/default.conf nginx:stable-alpine
- run: docker run -d -v "$PWD":/home/framework-x php:${{ matrix.php }}-fpm
- run: docker run -d -p 80:80 --link $(docker ps -qn1):php -v "$PWD":/home/framework-x -v "$PWD"/examples/nginx/nginx.conf:/etc/nginx/conf.d/default.conf nginx:stable-alpine
- run: bash tests/await.sh http://localhost
- run: bash tests/acceptance.sh http://localhost

Expand All @@ -88,7 +88,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
- run: composer install --no-dev
- run: docker run -d -p 80:80 -v "$PWD":/home/frugal php:${{ matrix.php }}-apache sh -c "rmdir /var/www/html;ln -s /home/frugal/examples/apache /var/www/html;ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground"
- run: docker run -d -p 80:80 -v "$PWD":/home/framework-x php:${{ matrix.php }}-apache sh -c "rmdir /var/www/html;ln -s /home/framework-x/examples/apache /var/www/html;ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground"
- run: bash tests/await.sh http://localhost
- run: bash tests/acceptance.sh http://localhost

Expand Down
24 changes: 7 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# Frugal
# Framework X

[![CI status](https://github.com/clue/frugalphp-incubator/workflows/CI/badge.svg)](https://github.com/clue/frugalphp-incubator/actions)
[![CI status](https://github.com/clue-access/framework-x/workflows/CI/badge.svg)](https://github.com/clue-access/framework-x/actions)

Lightweight microframework for fast, event-driven and async-first web applications, built on top of ReactPHP.

[…]

> TODO: Introduction text, start with the why. List some noticeable features.
Take a look at https://ninenines.eu/docs/en/cowboy/2.6/guide/modern_web/
Framework X – the simple and fast micro framework for building reactive web applications that run anywhere.

* [Quickstart](#quickstart)
* [Documentation](#documentation)
Expand All @@ -20,26 +15,21 @@ First manually change your `composer.json` to include these lines:

```json
{
…,
"repositories": [
{
"type": "vcs",
"url": "https://github.com/clue-engineering/frugal"
"url": "https://github.com/clue-access/framework-x"
}
]
}
```

> TODO: Change package name and register on Packagist.

Simply install FrugalPHP:
Simply install Framework X:

```bash
$ composer require clue/frugal:dev-main
$ composer require clue/framework-x:dev-main
```

> TODO: Tagged release.

Once everything is installed, you can now use this example to get started with
a new `app.php` file:

Expand All @@ -49,7 +39,7 @@ a new `app.php` file:
require __DIR__ . '/../vendor/autoload.php';

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

$app->get('/', function () {
return new React\Http\Message\Response(
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "clue/frugal",
"description": "Lightweight microframework for fast, event-driven and async-first web applications, built on top of ReactPHP.",
"keywords": ["microframework", "web", "event-driven", "async", "ReactPHP"],
"homepage": "https://github.com/clue/frugalphp-incubator",
"name": "clue/framework-x",
"description": "Framework X – the simple and fast micro framework for building reactive web applications that run anywhere.",
"keywords": ["microframework", "micro", "framework", "web", "http", "event-driven", "async", "ReactPHP"],
"homepage": "https://framework-x.clue.engineering/",
"license": "MIT",
"authors": [
{
Expand All @@ -21,12 +21,12 @@
},
"autoload": {
"psr-4": {
"Frugal\\": "src/"
"FrameworkX\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Frugal\\Tests\\": "tests/"
"FrameworkX\\Tests\\": "tests/"
}
}
}
4 changes: 2 additions & 2 deletions docs/api/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ to do its magic, hence you have to create it like this:
require __DIR__ . '/vendor/autoload.php';

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

// Register routes here, see routing…

Expand All @@ -30,7 +30,7 @@ $loop->run();
>
> require __DIR__ . '/vendor/autoload.php';
>
> $app = 🚀🚀🚀\App();
> $app = FrameworkX\App();
>
> // Register routes here, see routing…
>
Expand Down
2 changes: 1 addition & 1 deletion docs/api/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ use Acme\Todo\AdminMiddleware;
use Acme\Todo\UserController;

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

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

Expand Down
4 changes: 2 additions & 2 deletions docs/best-practices/controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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 Frugal\App($loop);
$app = new FrameworkX\App($loop);

$app->get('/', function () {
return new React\Http\Message\Response(
Expand Down Expand Up @@ -50,7 +50,7 @@ definition into three even simpler files:
require __DIR__ . '/vendor/autoload.php';

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

$app->get('/', new Acme\Todo\HelloController());
$app->get('/users/{name}', new Acme\Todo\UserController());
Expand Down
6 changes: 3 additions & 3 deletions docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,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 Frugal\App($loop);
$app = new FrameworkX\App($loop);

$app->get('/', function () {
return new React\Http\Message\Response(
Expand Down Expand Up @@ -57,7 +57,7 @@ Next, we need to install X and its dependencies to actually run this project.
> "repositories": [
> {
> "type": "vcs",
> "url": "https://github.com/clue-engineering/frugal"
> "url": "https://github.com/clue-access/framework-x"
> }
> ]
> }
Expand All @@ -79,7 +79,7 @@ Thanks to [Composer](https://getcomposer.org/), this installation only requires
In your project directory, simply run the following command:

```bash
$ composer require clue/frugal:dev-main
$ composer require clue/framework-x:-main
```

This isn't NPM, so this should only take a moment or two.
Expand Down
6 changes: 3 additions & 3 deletions examples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require __DIR__ . '/../vendor/autoload.php';

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

$app->get('/', function () {
return new React\Http\Message\Response(
Expand Down Expand Up @@ -101,8 +101,8 @@

//$app->cgi('/adminer.php', __DIR__ . '/adminer.php');

$app->get('/LICENSE', new Frugal\FilesystemHandler(dirname(__DIR__) . '/LICENSE'));
$app->get('/source/{path:.*}', new Frugal\FilesystemHandler(dirname(__DIR__)));
$app->get('/LICENSE', new FrameworkX\FilesystemHandler(dirname(__DIR__) . '/LICENSE'));
$app->get('/source/{path:.*}', new FrameworkX\FilesystemHandler(dirname(__DIR__)));
$app->redirect('/source', '/source/');

$app->any('/method', function (ServerRequestInterface $request) {
Expand Down
2 changes: 1 addition & 1 deletion examples/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server {
root /home/frugal/examples/nginx/public;
root /home/framework-x/examples/nginx/public;
index index.php index.html;

location / {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
colors="true"
cacheResult="false">
<testsuites>
<testsuite name="Frugal test suite">
<testsuite name="Framework X test suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.legacy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="Frugal test suite">
<testsuite name="Framework X test suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand Down
2 changes: 1 addition & 1 deletion src/App.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Frugal;
namespace FrameworkX;

use FastRoute\Dispatcher;
use FastRoute\RouteCollector;
Expand Down
2 changes: 1 addition & 1 deletion src/FilesystemHandler.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Frugal;
namespace FrameworkX;

use Psr\Http\Message\ServerRequestInterface;
use React\Http\Message\Response;
Expand Down
12 changes: 6 additions & 6 deletions tests/AppTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

namespace Frugal\Tests;
namespace FrameworkX\Tests;

use FastRoute\Dispatcher;
use FastRoute\RouteCollector;
use Frugal\App;
use FrameworkX\App;
use FrameworkX\Tests\Stub\InvalidHandlerStub;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand All @@ -14,7 +15,6 @@
use React\Promise\PromiseInterface;
use ReflectionMethod;
use ReflectionProperty;
use Frugal\Tests\Stub\InvalidHandlerStub;

class AppTest extends TestCase
{
Expand Down Expand Up @@ -712,7 +712,7 @@ public function testHandleRequestWithDispatcherWithRouteFoundReturnsInternalServ
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals(500, $response->getStatusCode());
$this->assertEquals('text/html', $response->getHeaderLine('Content-Type'));
$this->assertEquals("500 (Internal Server Error): <code>Frugal\Tests\Stub\InvalidHandlerStub</code> (<code title=\"See " . __DIR__ . DIRECTORY_SEPARATOR . "Stub" . DIRECTORY_SEPARATOR . "InvalidHandlerStub.php line $line\">InvalidHandlerStub.php:$line</code>) returned invalid value (<code>null</code>)\n", (string) $response->getBody());
$this->assertEquals("500 (Internal Server Error): <code>FrameworkX\Tests\Stub\InvalidHandlerStub</code> (<code title=\"See " . __DIR__ . DIRECTORY_SEPARATOR . "Stub" . DIRECTORY_SEPARATOR . "InvalidHandlerStub.php line $line\">InvalidHandlerStub.php:$line</code>) returned invalid value (<code>null</code>)\n", (string) $response->getBody());
}

public function testHandleRequestWithDispatcherWithRouteFoundReturnsInternalServerErrorResponseWhenClassMethodHandlerReturnsStringValue()
Expand All @@ -737,7 +737,7 @@ public function testHandleRequestWithDispatcherWithRouteFoundReturnsInternalServ
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals(500, $response->getStatusCode());
$this->assertEquals('text/html', $response->getHeaderLine('Content-Type'));
$this->assertEquals("500 (Internal Server Error): <code>Frugal\Tests\Stub\InvalidHandlerStub::index()</code> (<code title=\"See " . __DIR__ . DIRECTORY_SEPARATOR . "Stub" . DIRECTORY_SEPARATOR . "InvalidHandlerStub.php line $line\">InvalidHandlerStub.php:$line</code>) returned invalid value (<code>null</code>)\n", (string) $response->getBody());
$this->assertEquals("500 (Internal Server Error): <code>FrameworkX\Tests\Stub\InvalidHandlerStub::index()</code> (<code title=\"See " . __DIR__ . DIRECTORY_SEPARATOR . "Stub" . DIRECTORY_SEPARATOR . "InvalidHandlerStub.php line $line\">InvalidHandlerStub.php:$line</code>) returned invalid value (<code>null</code>)\n", (string) $response->getBody());
}

public function testHandleRequestWithDispatcherWithRouteFoundReturnsInternalServerErrorResponseWhenStaticClassMethodHandlerReturnsStringValue()
Expand All @@ -762,7 +762,7 @@ public function testHandleRequestWithDispatcherWithRouteFoundReturnsInternalServ
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals(500, $response->getStatusCode());
$this->assertEquals('text/html', $response->getHeaderLine('Content-Type'));
$this->assertEquals("500 (Internal Server Error): <code>Frugal\Tests\Stub\InvalidHandlerStub::static()</code> (<code title=\"See " . __DIR__ . DIRECTORY_SEPARATOR . "Stub" . DIRECTORY_SEPARATOR . "InvalidHandlerStub.php line $line\">InvalidHandlerStub.php:$line</code>) returned invalid value (<code>null</code>)\n", (string) $response->getBody());
$this->assertEquals("500 (Internal Server Error): <code>FrameworkX\Tests\Stub\InvalidHandlerStub::static()</code> (<code title=\"See " . __DIR__ . DIRECTORY_SEPARATOR . "Stub" . DIRECTORY_SEPARATOR . "InvalidHandlerStub.php line $line\">InvalidHandlerStub.php:$line</code>) returned invalid value (<code>null</code>)\n", (string) $response->getBody());
}

public function testHandleRequestWithDispatcherWithRouteFoundReturnsInternalServerErrorResponseWhenGlobalFunctionHandlerReturnsStringValue()
Expand Down
4 changes: 2 additions & 2 deletions tests/FilesystemHandlerTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Frugal\Tests;
namespace FrameworkX\Tests;

use Frugal\FilesystemHandler;
use FrameworkX\FilesystemHandler;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ResponseInterface;
use React\Http\Message\ServerRequest;
Expand Down
2 changes: 1 addition & 1 deletion tests/Stub/InvalidHandlerStub.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Frugal\Tests\Stub;
namespace FrameworkX\Tests\Stub;

class InvalidHandlerStub
{
Expand Down