php


Slim Controller Request, response and args not available


What I need is : Use a custom class to receive a HTTP Request and deal with it.
What I have so far:
$app->group('/user', function () use ($app) {
$app->post('/login', Auth::class . ':login');
}
And in my Auth Class:
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
// also tried: use Slim\Http\Request; use Slim\Http\Response;
class Auth {
protected $container;
public function __construct(&$c) {
$this->container = $c;
}
public function login(Request $request, Response $response, $args) {
// NEED TO GET GET/POST/PUT Params here
// When I Try to print $request, $response or $args, it returns empty
}
My code shows in the function login what I need : get the http params, and the request/response/args params. ( I want to implement many functions in one class, I mean, I don't want to use __invoke())
Another thing I don't understand is, if I do something like
return $response->withJson($somearraydata,200);
the variable $response actually works. Why?
Thanks for any help!
I think I have figured it out,
$args are never set,but request and response are.
and, to get params, I could do:
$request->getParsedBody()['attribute']
Hope this helps someone. :)

Related Links

Which PHP $_SERVER variables can be reliably used for a session fingerprint?
foreach in blade template not working correctly
WooCommerce select shipping in checkout not in cart
Laravel 5 orderBy relationship count and pagination
How to install Stripe library on Yii2?
Get files from Compute Engine to process with App Engine
Separate value in array more than one (implode)
PHP syntax error for outputting value
How can i get OpenID username if user logged in on OpenID server?
Default multiple sort columns in Magento custom admin grid page
Strange thing on PHP simple IF
How to remove error “security header not valid” in paypal pro live payment?
prefill Marketo fields on Submit
localhost redirected you too many times when using header ()
Access a variable from different class
print http headers on IE with PHP after added with Fiddler

Categories

HOME
ionic2
flask
magento2
message-queue
loopbackjs
dafny
magento-2.0
celery
google-sheets-query
repair
impala
haxe
cdi
scheduler
eddystone
solution
xades4j
locationmanager
alljoyn
mailmerge
sslhandshakeexception
distributed-computing
xbox360
asciimath
hidden
salt-cloud
bazaar
akka-persistence
bsd
fido-u2f
perfino
software-packaging
react-dnd
fusetools
morris.js
window-managers
sap-lumira
running-object-table
sparkle
bitbake
social-networking
source-insight
infopath2010
vcenter
snap-framework
wdk
forms-authentication
identify
mv
selenide
nomad
xcode8.2
kitura
nusoap
jgrapht
renderman
lvalue
business-rules
jsf-2.3
perforce-integrate
jeditable
mnesia
i2b2
ioctl
django-validation
m4
odesk
cfwheels
gluon-desktop
knife
jnlp
wlanapi
ngcordova
tree-structure
microsoft-expression-web
n-tier-architecture
encryption-symmetric
global-scope
communicate
nodeload
ivalueconverter
lsa
application-blocks
sensormanager
form-for
jquery-dialog
zend-pdf
live-wallpaper
zotonic
mkannotation
sigar
differentiation
uipasteboard
ognl
nsconnection
3des
cleartype
eventaggregator
google-translator-toolkit
datagridcolumn

Resources

Encrypt Message