zend-expressive | PSR-15 middleware in minutes | Runtime Evironment library
kandi X-RAY | zend-expressive Summary
kandi X-RAY | zend-expressive Summary
PSR-15 middleware in minutes!
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Inject routes from configuration .
- Get dependencies .
- Register the JSON exception handler .
- Inject the editor
- Prepare a middleware .
- Get a middleware .
- Prepare Whoops handler .
- Prepare a stacktrace .
- Generate a response .
- Add a middleware to the pipeline .
zend-expressive Key Features
zend-expressive Examples and Code Snippets
Community Discussions
Trending Discussions on zend-expressive
QUESTION
I'm using zend-expressive (3) to build my REST APIs. The file config/routes.php contains my routes, e.g.
...ANSWER
Answered 2019-Sep-10 at 19:20There are 2 ways to add routes. The first one is by how you do it, injecting the routes. You can use a custom delegator factories to split up routes into modules.
The second is by configuration. You could created a bunch of files in a config/routes/
dir and autoload those. However if you prefer the routes within your modules, I suggest to stick with the first method.
Just be aware that using both methods at the same time might cause unwanted side effects so you should choose 1 method.
QUESTION
Based on https://github.com/DamienHarper/DoctrineAuditBundle I'm trying to develop audit module for my Zend Expressive application. But I don't know how to get the User data (id) within audit logic.
I see that $user
is passed as request attribute in
vendor/zendframework/zend-expressive-authentication/src/AuthenticationMiddleware.php
, but this doesn't make it available via
ANSWER
Answered 2019-Jun-27 at 05:36You might want to read again about the concept of middleware. In short, expressive has a middleware stack and depending on a request, it sends a the request through specific layers of middleware.
In your example the request goes through AuthenticationMiddleware. So if you have this as your pipeline:
QUESTION
I'm trying to use https://github.com/php-middleware/phpdebugbar in a clean Zend Expressive Skeleton application.
I know the instructions on this page suggest using this DI configuration (if using pimple):
...ANSWER
Answered 2019-Apr-24 at 06:45try creating an alias first and then provide it to a factory
QUESTION
I want use a route to get the complete collection and, if available, a filtered collection.
so my route:
...ANSWER
Answered 2019-Jan-16 at 08:10That's because you are using https://github.com/nikic/FastRoute router and correct syntax would be:
QUESTION
Using Zend Expressive 2.0.5, I want to log PHP errors into the PHP's error log file itself, I went through https://docs.zendframework.com/zend-expressive/features/error-handling/#handling-exceptions-and-errors
I also saw this post: Zend expressive - php error reporting. Which cleared a lot of things for me but still quite didn't solve the asked question.
Things I did: Defined my own ErrorHandlerFactory
where I attached two listeners to the Zend-stratigility's ErrorHandler
First Listener uses Zend Log to log into my application's log file.(Just thought it would be nice to have errors in my application.log too.)
In the Second Listener, I want to log into PHP's error log file, so I have used
error_log()
method from php.
Questions:
The error_log() is not printing the log the way a log appears when printed by php's error handler. What I mean:
When an error is printed by the php's error handler, it looks something like this:
[08-Feb-2018 08:22:51 US/Central] PHP Warning: array_push() expects at least 2 parameters, 1 given in C:\webserver\webroot\myapi\src\App\src\Action\PageAction.php on line 38
While when I print the log using
error_log()
it looks something like this:[08-Feb-2018 09:03:49 US/Central] array_push() expects at least 2 parameters, 1 given in C:\webserver\webroot\myapi\src\App\src\Action\PageAction.php on line 38
What am I missing here is the PHP's error type: PHP Warning, Is this the error code? The error code I get is an integer, how do I parse that code? should I map the error codes with PHP errors constants which appear in the logs, for example: WARNING, NOTICE, etc, I can even do that, but the problem is: I got the same error code of 0 both the times when php's error handler printed a WARNING and a Fatal error logs.
Is it right to log errors in PHP's error log file like this? Should I do the job of PHP's error handler? The error handler could be doing a lot of things, for example: Logging the error message for few errors but for another also logging the stack trace. If this is not right, then how else can I send the error to the PHP's error_handler?
From my understanding:
My own Error Handler prevents users to look for exceptions and stack traces but rather returns a generic message. This also means that the Error Handler consumes the error and doesn't throw it further outside, i.e. will not throw it to the PHP's error handler.
ANSWER
Answered 2018-Feb-09 at 13:15Answering question 1:
I am able to almost simulate the way PHP error handler logs PHP errors. Things I did:
- Went through the docs and this SO question. Using these I was able to attach listeners to Zend-stratigility's ErrorHandler
- Went through PHP's Error Constants and set_error_handler(), which gave me some ideas on how to find out which type of Error or Exception occured.
Below is the code for my ErrorHandlerFactory where I attach the listeners.
QUESTION
The following scenario:
I want to edit the table 'accounts' which consists of 3 fields (id, username and domain) by a Zend Framework 3 form. The field 'domain' can be selected out of a set of domainnames (here a static array to simplify things)
I have a simple entity with getters and setters 'AccountModel.php':
...ANSWER
Answered 2018-Jan-08 at 23:48The problem was caused by a simple oversight: The AccountsTableFieldset was adding the Collection of AccountFieldsets directly in the constructor. This should have been done by the init()-method. So changing my 'AccountTableFieldset.php':
QUESTION
https://github.com/zendframework/zend-expressive-twigrenderer/issues/24
Based on this question, I want to pass a variable to layout from an Action How can I try to do that?
...ANSWER
Answered 2017-Nov-28 at 08:37Did you try "addDefaultParam" method? signeture is;
QUESTION
In my ZF2 Application, I had several custom form Elements with an injected database Adapter. I put the configuration in the module.php file with a method, like this:
...ANSWER
Answered 2017-Oct-13 at 23:32Form class calls elements via 'FormElementManger'. and FormElementManager reads 'form_elements' key from config. It's basicly a container (service manager) so you have to configure it same as container (factories, invokables, aliases etc). Also, you have to register Zend/Form module to container. I didn't try it but has to be ths way;
(ps: it's too late here, if it doesn't work let me know so i can put a working example.)
QUESTION
I have a Zend Expressive project from Skeleton app. Also, the database NOT NULL is set for each of the fields that I have set nullable on. I think it might have something to do with it not reading the annotations. I had issues getting the annotations working in the first place, especially for the cli-config.php
Here's the DoctrineFactory I created loosely based on one I found as an example. I changed the way it creates the entityManager to more closely represent the Doctrine docs config example.
...ANSWER
Answered 2017-Oct-10 at 12:16So the issue, it turns out, is that Doctrine was caching my entities and probably had a hold of a stale entity. I figured this out because I added the id field but it wasn't showing up at all. I destroyed and recreated my Vagrant box, and it worked.
So I added this if statement around the cache adapter:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install zend-expressive
You can install Expressive standalone using Composer:.
a router.
a dependency injection container.
Aura.Router: composer require zendframework/zend-expressive-aurarouter
FastRoute: composer require zendframework/zend-expressive-fastroute
zend-router: composer require zendframework/zend-expressive-zendrouter
zend-servicemanager: composer require zendframework/zend-servicemanager
Pimple (see docs for more details): composer require zendframework/zend-pimple-config
Aura.Di (see docs for more details): composer require zendframework/zend-auradi-config
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page