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 #252 from koriym/example
Cleanup
- Loading branch information
Showing
27 changed files
with
174 additions
and
99 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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
# Demo | ||
|
||
This is a minimal BEAR.Sunday application with BEAR.Package. | ||
|
||
## Install and Test | ||
``` | ||
composer install | ||
./vendor/bin/phpunit | ||
``` | ||
|
||
## Run | ||
|
||
|
||
console access | ||
|
||
``` | ||
php public/index get / | ||
``` | ||
|
||
web access | ||
|
||
``` | ||
php -S 127.0.0.1:8080 -t public | ||
``` | ||
|
||
batch command | ||
|
||
``` | ||
php bin/run.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* This file is part of the BEAR.Package package. | ||
* | ||
* @license http://opensource.org/licenses/MIT MIT | ||
*/ | ||
use BEAR\Package\Bootstrap; | ||
|
||
require dirname(__DIR__) . '/load.php'; | ||
|
||
$page = (new Bootstrap) | ||
->getApp('MyVendor\MyApp', 'hal-app') | ||
->resource | ||
->get | ||
->uri('page://self/api/user')(['id' => 1]); | ||
|
||
echo $page->code . PHP_EOL; | ||
echo (string) $page; |
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,17 @@ | ||
{ | ||
"name": "my-vendor/hello-package", | ||
"require": { | ||
"bear/sunday": "^1.2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"MyVendor\\HelloWorld\\": "src" | ||
} | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^6.3" | ||
}, | ||
"scripts": { | ||
"serve": "php -S 127.0.0.1:8080 -t public" | ||
} | ||
} |
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,12 @@ | ||
<?php | ||
/** | ||
* This file is part of the BEAR.Package package. | ||
* | ||
* @license http://opensource.org/licenses/MIT MIT | ||
*/ | ||
use Doctrine\Common\Annotations\AnnotationRegistry; | ||
|
||
$loader = (require dirname(__DIR__) . '/vendor/autoload.php'); | ||
/* @var $loader \Composer\Autoload\ClassLoader */ | ||
$loader->addPsr4('MyVendor\MyApp' . '\\', __DIR__ . '/src'); | ||
AnnotationRegistry::registerLoader('class_exists'); |
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,22 @@ | ||
<?php | ||
use BEAR\Package\Bootstrap; | ||
use BEAR\Sunday\Extension\Application\AbstractApp; | ||
|
||
require dirname(__DIR__) . '/load.php'; | ||
|
||
$context = PHP_SAPI === 'cli' ? 'cli-hal-app' : 'hal-app'; | ||
|
||
$app = (new Bootstrap)->getApp('MyVendor\MyApp', $context); | ||
/* @var $app AbstractApp */ | ||
$request = $app->router->match($GLOBALS, $_SERVER); | ||
try { | ||
$page = $app | ||
->resource | ||
->{$request->method} | ||
->uri($request->path)($request->query) | ||
->transfer($app->responder, $_SERVER); | ||
exit(0); | ||
} catch (\Exception $e) { | ||
$app->error->handle($e, $request)->transfer(); | ||
exit(1); | ||
} |
File renamed without changes.
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
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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
/** | ||
* This file is part of the BEAR.Package package. | ||
* | ||
* @license http://opensource.org/licenses/MIT MIT | ||
*/ | ||
namespace FakeVendor\HelloWorld\Resource\App; | ||
|
||
use BEAR\Resource\Annotation\Embed; | ||
use BEAR\Resource\ResourceObject; | ||
|
||
class Emb extends ResourceObject | ||
{ | ||
/** | ||
* @Embed(rel="user", src="/user{?id}") | ||
*/ | ||
public function onGet($id) | ||
{ | ||
return $this; | ||
} | ||
} |
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