Code Monkey home page Code Monkey logo

bear.sunday's Introduction

Logo

BEAR.Sunday

A resource-oriented application framework

Scrutinizer Code Quality codecov Type Coverage Continuous Integration

What's BEAR.Sunday

This resource orientated framework has both externally and internally a REST centric architecture, implementing Dependency Injection and Aspect Orientated Programming heavily to offer you surprising simplicity, order and flexibility in your application. With very few components of its own, it is a fantastic example of how a framework can be built using existing components and libraries from other frameworks, yet offer even further benefit and beauty.

Because everything is a resource

In BEAR.Sunday everything is a REST resource which leads to far simpler design and extensibility. Interactions with your database, services and even pages and sections of your app all sit comfortably in a resource which can be consumed or rendered at will.

Documentation

Related project

bear.sunday's People

Contributors

fivestar avatar harikt avatar hkano avatar kaepapa avatar kalibora avatar kawanamiyuu avatar kenjis avatar koriym avatar kumamidori avatar mackstar avatar madapaja avatar mugeso avatar ryo88c avatar sasezaki avatar sosuke-ito avatar yuki777 avatar zukimochi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bear.sunday's Issues

rfc: new feature "Signal Parameter"

Overview

通常、メソッドの引き数は呼び出す側が指定するか、メソッドシグネチャーでデフォルト値を指定します。どちらの指定も無いときは通常エラーになりますが、このような場合に引き数を用意するる機構が"Signal Parameter"です。

Normally, an argument is provided by caller or method signature's default value. None of argument provided cause 'Warning: Missing argument' error. "Signal Parameter" function provides argument in this case.

引き数の用意の責任を、メソッド自身、メソッドの利用者から分離してボイラプレートコードの削減やテスタビリティの向上に役立てます。

We expected to reduce boiler plate code and increase testability by removing the responsibility for argument provide from the caller or the method itself.

Example

例)$now引き数を必要とするページリソース

class Param extends Page
{
    public function onGet($now)
    {
        $this->body['now'] = $now;
        return $this;
    }
}

引き数を用意するパラメータープロバイダーを定義します。

Parameter Provider

現在時刻を用意するパラメータープロバイダー

namespace Sandbox\Params;

use BEAR\Resource\ParamProviderInterface;
use BEAR\Resource\Param;

class CurrentTime implements ParamProviderInterface
{
    public function __invoke(Param $param)
    {
        $time = date("Y-m-d H:i:s", time());
        return $param->inject($time);
    }
}

ParamProviderInterfaceを実装したメソッドでは引き数に様々なアクセスができるParam型変数を受け取ります。プロバイダーからはメソッドや対象オブジェクトにアクセスできるので、他の引き数やメソッドにつけられたアノテーションによって引き数の準備を変える事ができます。ex) $endOfDayは他の引き数$monthを見て28/30/31を選択して注入

$args = $param->getArg(); // メソッドの引き数を全てを取得します
$paramReflection = $param->getParameter(); // パラメーターのリフレクションを取得します
$param->getMethodInvocation()->getMethod() // メソッドのリフレクションを取得します
$param->getMethodInvocation()->getThis(); // メソッドのオブジェクトを取得します。

引き数が 用意できるとき$param->inject()で注入します。出来ない時はそのままreturnします。

Binding

引き数名と引き数プロバイダーを登録することで利用可能になります。1つの変数に対して登録が複数できます。引き数プロバイダーは変数が用意されるまで順番にコールされます。

We need to bind 'variable name' and 'variable provider' to use this 'Signal Parameter' functionality. Parameter provider will be called till argument is provided.

 $signalParam->attachParamProvider('now', new CurrentTime);

Idea

Pull Architecture

For example, "Calendar" helper in view template needs $year and $month to render calendar. 'Signal Parameter' enables every controller does no need to assign $year and $month in every controller which has calendar view.

loginId

Login ID is provider by "SessionLoginIdProvider" or "CookieIdProvider", but "TestLoginIdProvider" will provide in "test" mode. Caller and method changed nothing.

Overide

(not implemented yet) Regardless how do you call, Specified arguments by name or caller are overridden. Main use is for the test.

Actual code

 $this->install(new SignalParamModule($this, $this->params));

in https://github.com/koriym/BEAR.Package/blob/e08cf8ebf39f539b605daab03315d4222f57b810/apps/Sandbox/Module/App/AppModule.php

rfc: README

READMEをfeature/readmeブランチで準備してます。
https://github.com/koriym/BEAR.Sunday/tree/feature/readme

数分でさらっとみて、楽しそうだったり、良さそうに思えたり、興味が出て印象を残せるようなREADMEが目標です。詳しい使い方が分かる必要はありませんが、初見で何だか分からないものだけのものが並んでいたら問題です。

現在のものでどのような印象を受けられるでしょうか?
あるいは、良いREADMEを持つ他のフレームワークはどれでしょうか?

rfc: @ResourceGraph annotation

機能

@ResourceGraph アノテーションはリソースグラフ(リソース間の関係性)を記述するためのアノテーションです。$bodyで指定されたURIがリソースリクエストに変換されます。

目的

単にボイラプレートコードを削減するだけではなく、リソースが何によって構成されているかをより明らかにします。

Install ( in AppModule)

 $this->install(new ResourceGraphModule($this));

通常の方法 (standard)

    public $body = [
        'greeting' => ''
    ];

    /**
     * @param string $name
     */
    public function onGet()
    {
        $this['greeting'] = $this
            ->resource
            ->get
            ->uri('app://self/first/greeting')
            ->request();

        return $this;
    }

@ResourceGraphを使った方法。$bodyに格納したURIが に リソースリクエスト に変換されます。

    public $body = [
        'greeting' => 'app://self/first/greeting'
    ];

    /**
     * @param string $name
     *
     * @ResourceGraph
     */
    public function onGet()
    {
        return $this;
    }

引き数の用意は 1)?クエリーで直接指定 2)パラメータープロバイダーによる補完 3)以下のようにonGet内で補完 のいずれかになります。 

    public $body = [
        'greeting' => 'app://self/first/greeting'
    ];

    /**
     * @param string $name
     *
     * @ResourceGraph
     */
    public function onGet($name)
    {
        $this['greeting'] = $this->body['greeting']->withQuery(['name' => $name]);
        return $this;
    }

※ インターセプターとして実装されているのでonGet()アクセスの直前にその処理が行われます。
※ 格納されるのはリソースリクエストであって、リソースレクエストの結果でないことに注意してください。テンプレートで現れた段階でリクエストが行われます。

Aura Form

Aura form in BEAR.Sunday

Aura.Input / Aura.View ライブラリを用いたフォームです。

BEAR.Sundayではフォームやバリデーションはアスペクトとして実装します。インターセプターではフォームの名称と属性、ルールを登録します。(バリデーションやその分岐などの定型処理はtraitが行うので通常記述不要です)

In BEAR.Sunday, A form or validation is considered as an aspect. (Code the form object in the method interceptor, not in the page method. )

Installation

$this->install(new AuraFormModule);

Method interceptor (form)

class AuraContact implements MethodInterceptor
{
    use AuraFormTrait;

    /**
     * Set form
     *
     * @param FilterInterface $filter
     */
    private function setForm(FilterInterface $filter)
    {
        $this->form
            ->setField('name')
            ->setAttribs(
                [
                    'id' => 'name',
                    'size' => 20,
                    'maxlength' => 20
                ]
            );
        $this->form
            ->setField('email')
            ->setAttribs([
                    'size' => 20,
                    'maxlength' => 20,
                ]);
        $this->form
            ->setField('url')
            ->setAttribs([
                    'size' => 20,
                    'maxlength' => 20,
                ]);
        $this->form
            ->setField('message', 'textarea')
            ->setAttribs([
                    'cols' => 40,
                    'rows' => 5,
                ]);

        $filter->setRule(
            'name',
            'Name must be alphabetic only.',
            function ($value) {
                return ctype_alpha($value);
            }
        );

        $filter->setRule(
            'email',
            'Enter a valid email address',
            function ($value) {
                return filter_var($value, FILTER_VALIDATE_EMAIL);
            }
        );

        $filter->setRule(
            'url',
            'Enter a valid url',
            function ($value) {
                return filter_var($value, FILTER_VALIDATE_URL);
            }
        );

        $filter->setRule(
            'message',
            'Message should be more than 7 characters',
            function ($value) {
                return (strlen($value) > 7) ? true : false;
            }
        );

        $this->form
            ->setField('submit', 'submit')
            ->setAttribs(['value' => 'send']);
    }
}

Contact form page

class Auraform extends Page
{
    use ResourceInject;

    public $body = ['code' => 200];

    /**
     * @Form
     */
    public function onGet()
    {
        return $this;
    }

    /**
     * @Form
     */
    public function onPost(
        $name,
        $email,
        $url,
        $message
    ) {
        $this['name'] = $name;
        $this['email'] = $email;
        $this['url'] = $url;
        $this['message'] = $message;
        $this['code'] = 201;

        return $this;
    }
}

Page template

    {if $code === 201}
        Name:{$name}<br>
        Email:{$email}<br>
        URL:{$url}<br>
        Message:{$message}<br>
    {else}
        <form action="/demo/form/auraform" method="POST" enctype="multipart/form-data">
            <input name="X-HTTP-Method-Override" type="hidden" value="POST"/>

                <div class="control-group {if $form.name.error}error{/if}">
                    <label class="control-label" for="title">Name</label>
                    <div class="controls">
                        {form type="field" name=$name}
                        <p class="help-inline">{$form.name.error}</p>
                    </div>
                </div>

                <div class="control-group {if $form.email.error}error{/if}">
                    <label class="control-label" for="title">Email</label>
                    <div class="controls">
                        {form type="field" name=$email}
                        <p class="help-inline">{$form.email.error}</p>
                    </div>
                </div>

                <div class="control-group {if $form.url.error}error{/if}">
                    <label class="control-label" for="title">URL</label>
                    <div class="controls">
                        {form type="field" name=$url}
                        <p class="help-inline">{$form.url.error}</p>
                    </div>
                </div>

                <div class="control-group {if $form.message.error}error{/if}">
                    <label class="control-label" for="title">Message</label>
                    <div class="controls">
                        {form type="field" name=$message}
                        <p class="help-inline">{$form.message.error}</p>
                    </div>
                </div>

            <input type="submit" name="submit" value="send" />
        </form>
    {/if}

Binding (method and form)

    private function installAuraContactForm()
    {
        $auraContact = $this->requestInjection('Sandbox\Interceptor\Form\AuraContact');
        $this->bindInterceptor(
            $this->matcher->subclassesOf('Sandbox\Resource\Page\Demo\Form\Auraform'), // class
            $this->matcher->annotatedWith('BEAR\Sunday\Annotation\Form'), // method
            [$auraContact] // interceptor
        );
    }

Result

2013-05-28 19 46 46

source

@harikt Standalone Form for PHP

素で記述してあります。

MySQLのrootにパスワードが設定されている時phpunitの実行でFatal error

$ php -r 'echo $_ENV["BEAR_DB_ID"];'
root

$ php -r 'echo $_ENV["BEAR_DB_PASSWORD"];'
hoge

$ php -i | grep variables_order
variables_order => EGPCS => EGPCS

$ phpunit
PHPUnit 3.6.11 by Sebastian Bergmann.

Configuration read from /home/shige/BEAR/BEAR.Sunday/phpunit.xml.dist

run:sandbox mode=Dev cahce=enable
.........................ESSESE.........PHP Fatal error: Method BEAR\Resource\Request::__toString() must not throw an exception in /home/shige/BEAR/BEAR.Sunday/apps/sandbox/tmp/smarty/template_c/7b6a9f730f42594db0bc013b98b57567110676b3.file.Posts.tpl.php on line 52
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:192
PHP 5. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/TextUI/TestRunner.php:325
PHP 6. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:705
PHP 7. PHPUnit_Framework_TestSuite->runTest() /usr/share/php/PHPUnit/Framework/TestSuite.php:745
PHP 8. PHPUnit_Framework_TestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:772
PHP 9. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:751
PHP 10. PHP_Invoker->invoke() /usr/share/php/PHPUnit/Framework/TestResult.php:647
PHP 11. call_user_func_array() /usr/share/php/PHP/Invoker.php:93
PHP 12. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHP/Invoker.php:93
PHP 13. PHPUnit_Framework_TestCase->runTest() /usr/share/php/PHPUnit/Framework/TestCase.php:804
PHP 14. ReflectionMethod->invokeArgs() /usr/share/php/PHPUnit/Framework/TestCase.php:942
PHP 15. sandbox\tests\Resource\Page\Blog\PostsTest->test_Render() /usr/share/php/PHPUnit/Framework/TestCase.php:942
PHP 16. BEAR\Resource\AbstractObject->__toString() /usr/share/php/PHPUnit/Framework/TestCase.php:92
PHP 17. BEAR\Framework\Resource\View\DevRenderer->render() /home/shige/BEAR/BEAR.Sunday/vendor/BEAR/Resource/src/BEAR/Resource/AbstractObject.php:94
PHP 18. BEAR\Framework\Resource\View\Renderer->render() /home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Resource/View/DevRenderer.php:72
PHP 19. BEAR\Framework\Module\TemplateEngine\SmartyModule\SmartyAdapter->fetch() /home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Resource/View/Renderer.php:60
PHP 20. Smarty_Internal_TemplateBase->fetch() /home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Module/TemplateEngine/SmartyModule/SmartyAdapter.php:80
PHP 21. content_4ffe5b5238a3d8_84063996() /home/shige/BEAR/BEAR.Sunday/vendor/smarty/smarty/distribution/libs/sysplugins/smarty_internal_templatebase.php:180

Ubunt12.04、Fedora17環境で同じように発生しています。
ユニットテストで失敗すると発生するようでMySQLのrootパスワードが未設定の場合は起こりません。
sandboxアプリの方でユニットテストが通らないのはまた別の問題かと思われますがまだ原因を追いきれていません。

The script tried to execute a method or access a property of an incomplete object error.

I am getting this error when making requests in succession via the API in a JS application.

The request is fine when made in isolation. Could this be a timing issue where the file system is taking to long to finish saving files before the next request is made? If so it is likely this could cause problems in production?

Stack trace is below.

Notice: BEAR\Resource\Request::toUri(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition &quot;Mackstar_Spout_Admin_Resource_App_Resources_Types_787123e35aeafccd2233450591d33004RayAop&quot; of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /Users/MackstarMBA/Sites/Mackstar.Spout/vendor/bear/resource/src/BEAR/Resource/Request.php on line 148 Call Stack Time Memory Function Location 1 0.0003 257808 {main}( ) ../api.php:0 2 1.0267 8033752 BEAR\Resource\Resource->request( ) ../api.php:81 3 1.0268 8034216 BEAR\Resource\Resource->invoke( ) ../Resource.php:259 4 1.0268 8034408 BEAR\Resource\Invoker->invoke( ) ../Resource.php:276 5 1.0269 8035976 call_user_func_array( ) ../Invoker.php:122 6 1.0269 8036312 Mackstar_Spout_Admin_Resource_App_Resources_Detail_b04ca60ab9ad9da2281fd626e6d78c28RayAop->onGet( ) ../Invoker.php:122 7 1.0272 8052000 Ray\Aop\ReflectiveMethodInvocation->proceed( ) ../Mackstar_Spout_Admin_Resource_App_Resources_Detail_b04ca60ab9ad9da2281fd626e6d78c28RayAop.php:21 8 1.0272 8052592 Mackstar\Spout\Admin\Interceptor\Tools\PagerAppender->invoke( ) ../ReflectiveMethodInvocation.php:102 9 1.0272 8052704 Ray\Aop\ReflectiveMethodInvocation->proceed( ) ../PagerAppender.php:16 10 1.0272 8052664 BEAR\Package\Module\Database\Dbal\Interceptor\DbInjector->invoke( ) ../ReflectiveMethodInvocation.php:102 11 1.0287 8318584 Ray\Aop\ReflectiveMethodInvocation->proceed( ) ../DbInjector.php:117 12 1.0287 8318544 Mackstar\Spout\Admin\Interceptor\Tools\ModelHeaderAppender->invoke( ) ../ReflectiveMethodInvocation.php:102 13 1.0287 8318696 Ray\Aop\ReflectiveMethodInvocation->proceed( ) ../ModelHeaderAppender.php:26 14 1.0287 8319048 invokeArgs( ) ../ReflectiveMethodInvocation.php:98 15 1.0287 8319080 Mackstar_Spout_Admin_Resource_App_Resources_Detail_b04ca60ab9ad9da2281fd626e6d78c28RayAop->onGet( ) ../ReflectiveMethodInvocation.php:98 16 1.0287 8319560 call_user_func_array( ) ../Mackstar_Spout_Admin_Resource_App_Resources_Detail_b04ca60ab9ad9da2281fd626e6d78c28RayAop.php:18 17 1.0287 8319592 Mackstar\Spout\Admin\Resource\App\Resources\Detail->onGet( ) ../Mackstar_Spout_Admin_Resource_App_Resources_Detail_b04ca60ab9ad9da2281fd626e6d78c28RayAop.php:18 18 1.0303 8447576 BEAR\Resource\Resource->request( ) ../Detail.php:34 19 1.0303 8447576 BEAR\Resource\Request->toUri( ) ../Resource.php:248

Notice: Illegal member variable name in /path/to//Ray/Di/Injector.php on line 675

$ composer create-project --dev bear/package ./bear
Installing bear/package (0.6.6)
  - Installing bear/package (0.6.6)

snip

Generating autoload files
php /var/www/vhosts/local.example.com/bear/vendor/classpreloader/classpreloader/classpreloader.php compile --config=/var/www/vhosts/local.example.com/bear/bin/data/loader/config.php --output=/var/www/vhosts/local.example.com/bear/scripts/preloader.php
> Loading configuration file

Notice: Illegal member variable name in /var/www/vhosts/local.example.com/bear/vendor/ray/di/src/Ray/Di/Injector.php on line 675

Instead of notice occurs only during installation, which has also been observed at the time that the application is executed.

$ php api.php get "app://self/first/greeting?name=gusagi"

Notice: Illegal member variable name in /var/www/vhosts/local.example.com/bear/vendor/ray/di/src/Ray/Di/Injector.php on line 675

snip

200 OK
date: ["Mon, 29 Apr 2013 02:45:47 GMT"]
[BODY]
Hello, gusagi

MySQLのrootにパスワードが設定されている時sandboxのphpunitが通りません。

tests/Resource/App/Blog/PostsTest.phpについては3つのEが発生し、
tests/Resource/Page/Blog/PostsTest.phpについてはFatal errorでphpunitが落ちてしまう状態です。
BEAR.Sunday本体部分のテストはrootパスありでも通っております。

$ php -r 'echo $_ENV["BEAR_DB_ID"], PHP_EOL;'
root
$ php -r 'echo $_ENV["BEAR_DB_PASSWORD"], PHP_EOL;'
hoge
$ php -i | grep variables_order
variables_order => EGPCS => EGPCS

$ phpunit tests/Resource/App/Blog/PostsTest.php
PHPUnit 3.6.11 by Sebastian Bergmann.

Configuration read from /home/shige/BEAR/BEAR.Sunday/apps/sandbox/phpunit.xml.dist

ESSESE

Time: 5 seconds, Memory: 6.25Mb

There were 3 errors:

  1. sandbox\tests\Resource\App\Blog\AppPostsTest::resource
    PDOException: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

/home/shige/BEAR/BEAR.Sunday/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:36
/home/shige/BEAR/BEAR.Sunday/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php:47
/home/shige/BEAR/BEAR.Sunday/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:350
/home/shige/BEAR/BEAR.Sunday/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:723
/home/shige/BEAR/BEAR.Sunday/apps/sandbox/Resource/App/Blog/Posts.php:76
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/ReflectiveMethodInvocation.php:97
/home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Interceptor/Logger.php:29
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/ReflectiveMethodInvocation.php:101
/home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Interceptor/CacheLoader.php:82
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/ReflectiveMethodInvocation.php:101
/home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Interceptor/DbInjector.php:77
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/ReflectiveMethodInvocation.php:101
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/Weaver.php:85
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/Weaver.php:99
/home/shige/BEAR/BEAR.Sunday/vendor/BEAR/Resource/src/BEAR/Resource/Invoker.php:111
/home/shige/BEAR/BEAR.Sunday/vendor/BEAR/Resource/src/BEAR/Resource/DevInvoker.php:70
/home/shige/BEAR/BEAR.Sunday/vendor/BEAR/Resource/src/BEAR/Resource/Resource.php:231
/home/shige/BEAR/BEAR.Sunday/apps/sandbox/tests/Resource/App/Blog/PostsTest.php:50

  1. sandbox\tests\Resource\App\Blog\AppPostsTest::post
    PDOException: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

/home/shige/BEAR/BEAR.Sunday/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:36
/home/shige/BEAR/BEAR.Sunday/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php:47
/home/shige/BEAR/BEAR.Sunday/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:350
/home/shige/BEAR/BEAR.Sunday/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:927
/home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Interceptor/Transactional.php:30
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/ReflectiveMethodInvocation.php:101
/home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Interceptor/TimeStamper.php:28
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/ReflectiveMethodInvocation.php:101
/home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Interceptor/DbInjector.php:77
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/ReflectiveMethodInvocation.php:101
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/Weaver.php:85
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/Weaver.php:99
/home/shige/BEAR/BEAR.Sunday/vendor/BEAR/Resource/src/BEAR/Resource/Invoker.php:111
/home/shige/BEAR/BEAR.Sunday/vendor/BEAR/Resource/src/BEAR/Resource/DevInvoker.php:70
/home/shige/BEAR/BEAR.Sunday/vendor/BEAR/Resource/src/BEAR/Resource/Resource.php:231
/home/shige/BEAR/BEAR.Sunday/apps/sandbox/tests/Resource/App/Blog/PostsTest.php:100

  1. sandbox\tests\Resource\App\Blog\AppPostsTest::delete
    PDOException: SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

/home/shige/BEAR/BEAR.Sunday/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:36
/home/shige/BEAR/BEAR.Sunday/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php:47
/home/shige/BEAR/BEAR.Sunday/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:350
/home/shige/BEAR/BEAR.Sunday/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:440
/home/shige/BEAR/BEAR.Sunday/apps/sandbox/Resource/App/Blog/Posts.php:142
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/ReflectiveMethodInvocation.php:97
/home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Interceptor/Logger.php:29
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/ReflectiveMethodInvocation.php:101
/home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Interceptor/DbInjector.php:77
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/ReflectiveMethodInvocation.php:101
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/Weaver.php:85
/home/shige/BEAR/BEAR.Sunday/vendor/Ray/Aop/src/Ray/Aop/Weaver.php:99
/home/shige/BEAR/BEAR.Sunday/vendor/BEAR/Resource/src/BEAR/Resource/Invoker.php:111
/home/shige/BEAR/BEAR.Sunday/vendor/BEAR/Resource/src/BEAR/Resource/DevInvoker.php:70
/home/shige/BEAR/BEAR.Sunday/vendor/BEAR/Resource/src/BEAR/Resource/Resource.php:231
/home/shige/BEAR/BEAR.Sunday/apps/sandbox/tests/Resource/App/Blog/PostsTest.php:136

There were 3 skipped tests:

  1. sandbox\tests\Resource\App\Blog\AppPostsTest::type
    This test depends on "sandbox\tests\Resource\App\Blog\AppPostsTest::resource" to pass.

  2. sandbox\tests\Resource\App\Blog\AppPostsTest::render
    This test depends on "sandbox\tests\Resource\App\Blog\AppPostsTest::resource" to pass.

  3. sandbox\tests\Resource\App\Blog\AppPostsTest::postData
    This test depends on "sandbox\tests\Resource\App\Blog\AppPostsTest::post" to pass.

FAILURES!
Tests: 3, Assertions: 0, Errors: 3, Skipped: 3.

Generating code coverage report in Clover XML format ... done

Generating code coverage report in HTML format ... done

$ phpunit tests/Resource/Page/Blog/PostsTest.php
PHPUnit 3.6.11 by Sebastian Bergmann.

Configuration read from /home/shige/BEAR/BEAR.Sunday/apps/sandbox/phpunit.xml.dist

....PHP Fatal error: Method BEAR\Resource\Request::__toString() must not throw an exception in /home/shige/BEAR/BEAR.Sunday/apps/sandbox/tmp/smarty/template_c/7b6a9f730f42594db0bc013b98b57567110676b3.file.Posts.tpl.php on line 52
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:192
PHP 5. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/TextUI/TestRunner.php:325
PHP 6. PHPUnit_Framework_TestSuite->runTest() /usr/share/php/PHPUnit/Framework/TestSuite.php:745
PHP 7. PHPUnit_Framework_TestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:772
PHP 8. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:751
PHP 9. PHP_Invoker->invoke() /usr/share/php/PHPUnit/Framework/TestResult.php:647
PHP 10. call_user_func_array() /usr/share/php/PHP/Invoker.php:93
PHP 11. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHP/Invoker.php:93
PHP 12. PHPUnit_Framework_TestCase->runTest() /usr/share/php/PHPUnit/Framework/TestCase.php:804
PHP 13. ReflectionMethod->invokeArgs() /usr/share/php/PHPUnit/Framework/TestCase.php:942
PHP 14. sandbox\tests\Resource\Page\Blog\PostsTest->test_Render() /usr/share/php/PHPUnit/Framework/TestCase.php:942
PHP 15. BEAR\Resource\AbstractObject->__toString() /usr/share/php/PHPUnit/Framework/TestCase.php:92
PHP 16. BEAR\Framework\Resource\View\DevRenderer->render() /home/shige/BEAR/BEAR.Sunday/vendor/BEAR/Resource/src/BEAR/Resource/AbstractObject.php:94
PHP 17. BEAR\Framework\Resource\View\Renderer->render() /home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Resource/View/DevRenderer.php:72
PHP 18. BEAR\Framework\Module\TemplateEngine\SmartyModule\SmartyAdapter->fetch() /home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Resource/View/Renderer.php:60
PHP 19. Smarty_Internal_TemplateBase->fetch() /home/shige/BEAR/BEAR.Sunday/package/BEAR/Framework/src/BEAR/Framework/Module/TemplateEngine/SmartyModule/SmartyAdapter.php:80
PHP 20. content_4ffe5b5238a3d8_84063996() /home/shige/BEAR/BEAR.Sunday/vendor/smarty/smarty/distribution/libs/sysplugins/smarty_internal_templatebase.php:180

Failed opening required FrameWorkModule.php

apps//script/loader.php
で定義されている、フレームワークモジュールの読み込み部分が、
require $appPath . '/Module/FrameWorkModule.php';
になっていますが、実際に存在するファイルは、
apps/
/Module/FrameworkModule.php
なため、実行に失敗します。
(frameWorkの w のケースが違います)

apc required

とりあえずご報告です。

composer create-project bear/skeleton MyVendor.MyPackage ~1.0@dev
cd MyVendor.MyPackage
composer install

で、該当のURLを開くと、

PHP Fatal error: Call to undefined function Doctrine\Common\Cache\apc_fetch() in /var/www/MyVendor.MyPackage/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php on line 40

となりました。
apt-get で apc を入れるとエラーは解消。

インストールのエラー

原因や対策は確認できていないのですが、
現状、インストールすると下記エラーが出るようです。

[RuntimeException]
Failed to clone http://github.com/auraphp/Aura.Di.git via git, https and http protocols, aborting.

ErrorException E_RECOVERABLE_ERROR: Argument 1 passed to BEAR\Package\Dev\Dev::setApp() must be an instance of BEAR\Sunday\Extension\Application\AppInterface, instance of Koriym\Work\Resource\Page\Calc given

Some of us got the error below at workshop in Nagoya.php.
https://github.com/BEARSunday/bearsunday.github.io/wiki/workshop

ErrorException
E_RECOVERABLE_ERROR: Argument 1 passed to BEAR\Package\Dev\Dev::setApp() must be an instance of BEAR\Sunday\Extension\Application\AppInterface, instance of Koriym\Work\Resource\Page\Calc given, called in .../bear-workshop/Koriym.Work/bootstrap/contexts/dev.php on line 48 and defined
in .../bear-workshop/Koriym.Work/vendor/bear/package/src-dev/Dev/Dev.php on line 81

How to reprodule:

  1. Access to http://0.0.0.0:8082/calc?a=1&b=2
  2. Reload the page

It maybe occurs on only PHP 5.5.

Introduce content negotiation feature

Motivation

Content negotiation is important feature of HTTP 1.1 and also valuable for REST.

Purpose

Allow to set up content negotiation setting via method/class annotation.

Suggestion

To achieve the purpose, I suggest following implements:

  • Add ContentType annotation, which marks a resource or a REST verb method will be render as a representation.
  • Add SimpleRendererInjector as a interceptor like DbInjector. (Package)
  • Add ContentNegotiatingRendererInjector like DbInjector. (Package)

Note: SimpleRendererInjector doesn't conetent negotiate. I'll refer the detail follow.

SimpleRendererjector

Example:

/**
 * @ContentType("text/html")
 */
class Something extends Page
{
    /**
     * @ContentType("application/hal+json")
     */
     public function onPost()
     {
         // do something...
         return $this;
     }

    /**
     * no annotation here
     */
    public function onGet()
    {
         // do something...
         return $this;
    }
}

この場合、GET,POSTリクエストごとにより異なるレンダラーがInjectされます。
GETであればhtmlをレンダリングするためのレンダラー、POSTであればHALをレンダリングするためのレンダラーです。
content-typeとレンダラーは何らかの形でマッピングして管理することを想定しています。
また、このInjectorはHTTP Acceptヘッダも確認し、指定されているcontent-typeがリストに含まれない場合、code 406 Not Acceptableを設定したリソースオブジェクトを返します。

ContentNegotiatingRendererInjector

Example:

/**
 * @ContentType("text/html, text/plain, application/json;q=0.8")
 */
class Something extends Page
{
    public function onGet()
    {
         // do something...
         return $this;
    }
}

この例に対しContentNegotiationgRendererInjectorはリクエストのAcceptヘッダに基づき、サーバー駆動コンテントネゴシエーションを行い適切なrendererをインジェクトするか、
要求を満たせない場合にはcode 406 Not Acceptableを設定したリソースオブジェクトを返します。

懸念事項

  • content-typeとレンダラーのマッピングをリソースごとに切り替えたい場合の指定方法とその実装

[RuntimeException] Failed to clone [email protected]:playmedia/Smarty.git

It seems playmedia/Smarty was removed.

$ composer create-project bear/package ./bear

  [RuntimeException]                                                           
  Failed to clone [email protected]:playmedia/Smarty.git via git, https, ssh pro  
  tocols, aborting.                                                            

  - git://github.com/playmedia/Smarty.git                                      
    Cloning into '/Users/kenji/tmp/bear/vendor/playmedia/smarty'...            
    fatal: remote error:                                                       
      Repository not found.                                                    

  - https://github.com/playmedia/Smarty.git                                    
    Cloning into '/Users/kenji/tmp/bear/vendor/playmedia/smarty'...            
    remote: Invalid username or password.                                      
    fatal: Authentication failed for 'https://github.com/playmedia/Smarty.git  
  /'                                                                           

  - [email protected]:playmedia/Smarty.git                                        
    Cloning into '/Users/kenji/tmp/bear/vendor/playmedia/smarty'...            
    ERROR: Repository not found.                                               
    fatal: Could not read from remote repository.                              

    Please make sure you have the correct access rights                        
    and the repository exists.

@Inject, @Named needed.

アノテーションはuse文のnamespaceの指定が必要。cache不使用の場合はエラーが現在出ないので注意。

index.phpがリクエストを受ける場合の実行時間について

@koriym
掲題の件、 #30 の主旨からは外れているのでissueを分離しました。

それは1リクエストにそれだけかかってるという事でしょうか??

1リクエストです。
nginx + php-fpm, built-in serverの両方で確認しましたが、index.phpがリクエストを受け付ける場合にかなり負荷と時間が掛かっているようです。
built-in serverでweb.php の場合は結構あっさり返ってきましたが、index.phpの場合は前述のスペックだと100秒前後掛かりました。

BEAR.Sunday 1.0 todo list

  • Hal
  • Read / Write separate store with @QueryRepository
  • Reverse route
  • Etag output
  • 304 Not modified
  • stdin for PUT / PATCH ..
  • Clear aop class files in dev
  • Master / Slave DB
  • HTML
  • BEAR.Skeleton
  • Documentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.