forked from bearsunday/BEAR.Sunday
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request bearsunday#112 from koriym/refactor
Refactor
- Loading branch information
Showing
60 changed files
with
241 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ cache.properties | |
composer.phar | ||
composer.lock | ||
.DS_Store | ||
.php_cs.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,50 @@ | ||
{ | ||
"name": "bear/sunday", | ||
"description": "A resource-oriented application framework", | ||
"keywords": [ | ||
"framework", | ||
"DI", | ||
"AOP", | ||
"REST", | ||
"Hypermedia" | ||
], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Akihito Koriyama", | ||
"email": "akihito.koriyama@gmail.com", | ||
"homepage": "https://github.com/koriym" | ||
}, | ||
{ | ||
"name": "BEAR.Sunday Contributors", | ||
"homepage": "http://bearsunday.github.io/contributors.html" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.0.0", | ||
"bear/resource": "^1.6", | ||
"psr/log": "^1.0.2" | ||
}, | ||
"name": "bear/sunday", | ||
"description": "A resource-oriented application framework", | ||
"keywords": [ | ||
"framework", | ||
"DI", | ||
"AOP", | ||
"REST", | ||
"Hypermedia" | ||
], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Akihito Koriyama", | ||
"email": "akihito.koriyama@gmail.com", | ||
"homepage": "http://koriym.github.io/about/" | ||
}, | ||
{ | ||
"name": "BEAR.Sunday Contributors", | ||
"homepage": "http://bearsunday.github.io/contributors.html" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.0.0", | ||
"bear/resource": "^1.9.2", | ||
"psr/log": "^1.0.2" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^6.2" | ||
"phpunit/phpunit": "^6.2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"psr-4": { | ||
"BEAR\\Sunday\\": "src/" | ||
}, | ||
"exclude-from-classmap": ["/example/", "/tests/"] | ||
}, | ||
"autoload-dev": { | ||
"files": ["tests/functions.php"] | ||
}, | ||
"scripts" :{ | ||
"test": [ | ||
"phpmd src text ./phpmd.xml", | ||
"phpcs src tests", | ||
"phpunit" | ||
], | ||
"cs-fix": [ | ||
"php-cs-fixer fix --config-file=./.php_cs", | ||
"phpcbf src" | ||
], | ||
"build": [ | ||
"rm -rf ./build; mkdir -p ./build/logs ./build/pdepend ./build/api", | ||
"pdepend --jdepend-xml=./build/logs/jdepend.xml --jdepend-chart=./build/pdepend/dependencies.svg --overview-pyramid=./build/pdepend/overview-pyramid.svg src", | ||
"phploc --log-csv ./build/logs/phploc.csv src", | ||
"phpcs --report=checkstyle --report-file=./build/logs/checkstyle.xml --standard=phpcs.xml src", | ||
"apigen generate -s src -d build/api", | ||
"@test" | ||
] | ||
} | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"BEAR\\Sunday\\": ["tests/", "tests/Fake/"], | ||
"FakeVendor\\HelloWorld\\": "tests/Fake/Apps/FakeVendor/HelloWorld/", | ||
"FakeVendor\\HelloWorldX\\": "tests/Fake/Apps/FakeVendor/HelloWorldX/" | ||
}, | ||
"files": ["tests/functions.php"] | ||
}, | ||
"scripts" :{ | ||
"test": ["@cs", "phpunit", "phpstan analyse -l max src tests -c phpstan.neon --no-progress"], | ||
"coverage": ["php -dzend_extension=xdebug.so ./vendor/bin/phpunit --coverage-text --coverage-html=build/coverage"], | ||
"cs": ["php-cs-fixer fix -v --dry-run", "phpcs --standard=./phpcs.xml src"], | ||
"cs-fix": ["php-cs-fixer fix -v", "phpcbf src"] | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of the BEAR.Sunday package. | ||
* | ||
* @license http://opensource.org/licenses/MIT MIT | ||
*/ | ||
use BEAR\Resource\Exception\BadRequestException; | ||
use BEAR\Resource\Exception\ResourceNotFoundException; | ||
use BEAR\Sunday\Extension\Application\AbstractApp; | ||
use BEAR\Sunday\Extension\Application\AppInterface; | ||
use MyVendor\HelloWorld\AppModule; | ||
use Ray\Di\Injector; | ||
|
||
require dirname(__DIR__) . '/vendor/autoload.php'; | ||
|
||
$app = (new Injector(new AppModule))->getInstance(AppInterface::class); | ||
/* @var $app AbstractApp */ | ||
$request = $app->router->match($GLOBALS, $_SERVER); | ||
try { | ||
$page = $app | ||
->resource | ||
->{$request->method} | ||
->uri($request->path)($request->query) | ||
->transfer($app->responder, $_SERVER); | ||
} catch (ResourceNotFoundException $e) { | ||
http_response_code(404); | ||
echo 'Not found' . PHP_EOL; | ||
} catch (BadRequestException $e) { | ||
http_response_code(400); | ||
echo 'Bad request' . PHP_EOL; | ||
} catch (\Exception $e) { | ||
http_response_code(500); | ||
echo 'Server error' . PHP_EOL; | ||
error_log($e); | ||
exit(1); | ||
} | ||
|
||
// php -S 127.0.0.1:8088 index.php | ||
|
||
//$ curl -i -X DELETE http://127.0.0.1:8088/ | ||
//HTTP/1.1 400 Bad Request | ||
//Host: 127.0.0.1:8088 | ||
//Date: Wed, 14 Mar 2018 01:10:39 +0100 | ||
//Connection: close | ||
//X-Powered-By: PHP/7.1.10 | ||
//Content-type: text/html; charset=UTF-8 | ||
// | ||
//Bad request | ||
|
||
//$ curl -i -X GET http://127.0.0.1:8088/abc | ||
//HTTP/1.1 404 Not Found | ||
//Host: 127.0.0.1:8088 | ||
//Date: Wed, 14 Mar 2018 01:09:00 +0100 | ||
//Connection: close | ||
//Content-type: text/html; charset=UTF-8 | ||
// | ||
//Not found | ||
|
||
//$ curl -i -X GET http://127.0.0.1:8088/ | ||
//HTTP/1.1 200 OK | ||
//Host: 127.0.0.1:8088 | ||
//Date: Wed, 14 Mar 2018 01:10:01 +0100 | ||
//Connection: close | ||
//content-type: application/json | ||
// | ||
//{ | ||
// "greeting": "Hello World" | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of the BEAR.Sunday package. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of the BEAR.Sunday package. | ||
* | ||
|
2 changes: 2 additions & 0 deletions
2
example/src/Resource/Page/Index.php → demo/src/Resource/Page/Index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of the BEAR.Sunday package. | ||
* | ||
|
2 changes: 2 additions & 0 deletions
2
example/tests/Resource/Page/IndexTest.php → demo/tests/Resource/Page/IndexTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of the BEAR.Sunday package. | ||
* | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,12 @@ | ||
<phpunit bootstrap="tests/bootstrap.php"> | ||
<phpunit bootstrap="vendor/autoload.php"> | ||
<testsuites> | ||
<testsuite> | ||
<directory suffix="Test.php">tests</directory> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<logging> | ||
<log type="coverage-html" target="build/coverage"/> | ||
<log type="coverage-clover" target="build/logs/clover.xml"/> | ||
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/> | ||
</logging> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src</directory> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of the BEAR.Sunday package. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of the BEAR.Sunday package. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of the BEAR.Sunday package. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of the BEAR.Sunday package. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of the BEAR.Sunday package. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of the BEAR.Sunday package. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of the BEAR.Sunday package. | ||
* | ||
|
Oops, something went wrong.