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

php replace paragraph to newline
Completely hide form input value from non-admins without removing form data
Bootstrap sign in button does not redirect to login page
How to get lineItem information in email receipt using Authorize.net (CIM XML)
Unable scrap an element that still available in 'view source code'
how to pass custom validation message to cviebrock/image-validator in laravel?
How to get the week slot of activity in Moodle?
Yii:: File not Uploading
I want to send a json value as a parameter to php page
Upstart a Yii console gives me error
How to upgrade joomla 1.5.22 to latest version(3.x)?
Jquery Chosen Select plugin doesn't Work in PHP Ajax response
Will Ajax be aborted after the request is done and the browser is closed?
Multidimensional array update
Rewrite URL (folder name to custom URL with folder name as variable value) in .htaccess
About SimpleXML's foreach

Categories

HOME
apple-push-notifications
dotnetnuke
postgresql-9.4
amp
navigation
gprs
timber
tup
jpa-criteria
yahoo
locationmanager
alljoyn
mailmerge
jquery-select2-4
powermock
stimulsoft
asp.net-core-1.0
parceler
weex
acl
animated-gif
pyopencl
data-collection
tracing
points
amazon-cloudtrail
materialize
tightvnc
nsmutablearray
xcrun
redgate
bluemixtools
python-sounddevice
slideshow
newtons-method
virtual-memory
reverse-dns
jenkins-slave
common-table-expression
scala-breeze
aurelia-fetch-client
dtd
glimpse
kendo-editor
sidewaffle
elastic4s
xcode6.4
system.web.optimization
data-management
wininet
between
xcode8-beta4
oci
qpixmap
distributed-cache
gulp-uglify
teamviewer
gwt-syncproxy
okta-api
flask-security
outlook.com
lowercase
directx-9
mixins
sequence-sql
relational-model
actionpack
baseadapter
fasterxml
nesper
preorder
accountmanager
jchartfx
code39
cloo
iirf
sql-view
disjoint-union
ember-table
xs
flv
oscilloscope
jbox2d
asp.net-mvc-3-areas
taskkill
sigar
groovy-console
upshot
ixmldomdocument
spring-modules
downcasting
stretchblt
comment-conventions

Resources

Encrypt Message