zend-expressive

Zend expressive - Layout

丶灬走出姿态 提交于 2020-01-16 18:25:13
问题 In my layout (Twig), i'd like to retrieve a value from a Middleware authentication. If i put, in templates.global.pĥp: 'twig' => [ 'globals' => [ // Variables to pass to all twig templates 'auth' => (new \Zend\Authentication\AuthenticationService())->hasIdentity(), ], ], And in layout default.html.twig {% if auth %} Connect {% else %} Not connect {% endif %} This code works, but, is it a good method ? Thank you :) 回答1: It's not a good method. First of all, using the config files to set global

PSR-7 “attributes” on Response object

≡放荡痞女 提交于 2020-01-02 21:19:29
问题 I'm developing using PSR-7 (with Zend Expressive). I figured out the method ServerRequestInterface::withAttribute() and I was wondering why the object Response doesn't have one. I'd like to pass metadata through middlewares after processing, on "response side". Is there somehow to pass "attributes" on Response for post-processing? What's is the best way, following the architecture guidelines, to achieve that? 回答1: The PSR-7 specification defines attributes only for server requests. They are

Zend expressive - php error reporting

故事扮演 提交于 2020-01-02 13:51:42
问题 I'm trying out zend expressive and this is my config/autoload/zend-expressive.global.php and when I tried to do a request to a path which will go to an action class it returned the error page but I can't see any php error in the apache error log. So I can't tell what's the issue. Is there a way in zend-expressive to have those php error log? Also any good documentation for zend expressive? It seems the official documentation doesn't really have much examples. return [ 'debug' => true, 'config

How can I set up Lazy Loading with ZF3 (no ServiceLocator pattern from anywhere)

 ̄綄美尐妖づ 提交于 2019-12-23 12:59:54
问题 I am writing a new ZF2 app. I have noticed that ServiceLocator usage pattern of calling services "from anywhere" has been deprecated from ZF3. I want to write code in mind for ZF3. I was able to set up my Controller to call all dependencies at constructor time. But that means loading i.e. Doctrine object upfront before I need it. Question How do I set it up so that it is only loaded when I need it immediately? (lazy-loaded). I understand that ZF3 moves loading to Controller construction,

How to get matched route name in View - Zend Expressive

大憨熊 提交于 2019-12-08 02:16:59
问题 I know that I can generate URL passing the route name <?php echo $this->url('route-name') #in view file ?> But can I get information in opposite direction? From current URL/URI, I need to get route name. Real case is: I have layout.phtml where is the top menu (html). Current link in the menu need to be marked with css class. So, example what I need is: <?php // in layout.phtml file $index_css = $this->getRouteName() == 'home-page' ? 'active' : 'none'; $about_css = $this->getRouteName() ==

PSR-7 “attributes” on Response object

隐身守侯 提交于 2019-12-06 19:54:28
I'm developing using PSR-7 (with Zend Expressive). I figured out the method ServerRequestInterface::withAttribute() and I was wondering why the object Response doesn't have one. I'd like to pass metadata through middlewares after processing, on "response side". Is there somehow to pass "attributes" on Response for post-processing? What's is the best way, following the architecture guidelines, to achieve that? The PSR-7 specification defines attributes only for server requests. They are mainly use to store metadata deduced from the incoming request so that they could be used later when you

Zend expressive - php error reporting

徘徊边缘 提交于 2019-12-06 06:20:21
I'm trying out zend expressive and this is my config/autoload/zend-expressive.global.php and when I tried to do a request to a path which will go to an action class it returned the error page but I can't see any php error in the apache error log. So I can't tell what's the issue. Is there a way in zend-expressive to have those php error log? Also any good documentation for zend expressive? It seems the official documentation doesn't really have much examples. return [ 'debug' => true, 'config_cache_enabled' => false, 'zend-expressive' => [ 'error_handler' => [ 'template_404' => 'error::404',