So, I thought I have correctly registered zend-expressive-session and zend-expressive-session-ext in my application but I can’t seem to get it running properly.
I’m getting an InvalidMiddlewareException with this message “Lazy-loaded middleware “Zend\Expressive\Session\SessionMiddleware” is neither invokable nor implements Interop\Http\ServerMiddleware\MiddlewareInterface”.
I began with the skeleton application and included both packages via Composer. During the installation I chose to aggregate their configuration. I can narrow it down to the class “Zend\Expressive\Session\SessionMiddleware” that is being considered not callable.
These are the package versions that Composer loaded starting from the skeleton application. Up until adding the session packages it worked.
You are mixing up a few versions here. zendframework/zend-expressive-session 1.0.0 has support for PSR-15
Psr\Http\Server\MiddlewareInterface. It doesn’t support
Interop\Http\ServerMiddleware\MiddlewareInterface anymore. I think you need zendframework/zend-expressive-session 0.1 for that.
When did you create the new project and what command did you use? As of march 15, it should install zend-expressive 3.
To all of you: Thanks for dedicating your time to this issue! You are amazing!
@xtreamwayz I was thinking into this direction. I just recently started the project from scratch but I somehow ended up not using the latest Expressive version. As an Expressive noob I just thought that I fetched the latest stable using the Skeleton application. If I remember correctly I was following the instructions given on the Expressive docs startpage, i.e. this command:
This yields this output:
netbrothers-tr@themachine:~/projects$ composer create-project zendframework/zend-expressive-skeleton expressive
Installing zendframework/zend-expressive-skeleton (2.2.0)
- Installing zendframework/zend-expressive-skeleton (2.2.0): Loading from cache
- Installing zendframework/zend-expressive (2.2.1): Loading from cache
Created project in expressive
Setting up optional packages
Setup data and cache dir
Removing installer development dependencies
What type of installation would you like?
 Minimal (no default middleware, templates, or assets; configuration only)
 Flat (flat source code structure; default selection)
 Modular (modular source code structure; recommended)
Make your selection (2): ^C
So, without giving any additional arguments, this instruction from the original documentation leads to an older Expressive version.
@samsonasik Thank you for the link to your blog post!
My conclusion is, that I will try to ugprade the whole project to Expressive 3 and then write my findings here for others who will run into the same blind alley.
There is something wrong with your composer installation.
~\projects\sandbox> composer create-project zendframework/zend-expressive-skeleton test
Installing zendframework/zend-expressive-skeleton (3.1.0)
- Installing zendframework/zend-expressive-skeleton (3.1.0): Loading from cache
Be sure to work with the latest version of composer by running
Try clearing Composer’s cache by running
@xtreamwayz I did, what you proposed. I even downloaded and used the very latest composer binary (version 1.6.5). I used all the defaults (flat, Zend ServiceManager, FastRoute, no template engine, Whoops) proposed in the installer script and got versions zend-expressive-skeleton (2.2.0) and zendframework/zend-expressive (2.2.1). I tried several non-defaults in the hope this would change anything, but it didn’t. Is there any else, I can do? Are you using the standard packagist repository or an enterprise version?
@netbrothers-tr What PHP version are you using? Expressive 3 requires PHP version 7.1.
That has been the problem! I’m on Ubuntu 16.04 with PHP 7.0.8. Time to upgrade! Thanks @xtreamwayz!