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

Call to undefined method Illuminate\Auth\GenericUser::hasFriendRequestPending()
Remove divs for each sentence inside paragraph
Add text to bottom footer area of Woocommerce Category Page Template
what permissions to set for SuiteCRM to load files correctly?
Is json_token better/safer/faster then a session? What means tampered, thus unusable?
Need of billing account in Google Speech API
PDO Connection as class affecting construct of other classes [duplicate]
Query to get column names and values in result?
(Undefined index: driver) Why I am obtaining this error message when I try to perform a database query on a Laravel application?
multiple tags with same metatag value PHP
Divide two variables in Twig/PHP
Firebase notification is replacing previous one
language can not change in grocery crud
Redirect a website link to an IP address on the VPN server
jQuery datatable button works only on first click
connecting php to mysqli database error

Categories

HOME
protocol-buffers
operating-system
embedded-resource
risk-management
tabs
portable-class-library
cryptography
mirc
video-streaming
openfoam
native-base
polymer-2.x
jpa-criteria
twitter-oauth
colors
game-maker
bootstrap-switch
createjs
pushdown-automaton
c#-7.0
l20n
rpmbuild
susy-sass
varnish-vcl
gitkraken
bsd
mime-types
ratio
marquee
django-import-export
splunk-query
nic
instructions
steam-web-api
publishing
delayed-job
nsmutablearray
epplus
gsp
ms-solver-foundation
djcelery
swfupload
netapp
oauth2-playground
spooler
transparency
permission-denied
qvtkwidget
viewmodel
libreoffice-writer
nothing
maven-jaxb2-plugin
mura
kendo-editor
dymola
rustdoc
yargs
e
logical
data-management
zynq
right-to-left
rails-engines
vaadin4spring
vimperator
lovefield
outlook.com
helm
srv-record
auto-generate
gluon-desktop
wlanapi
roxygen2
componentart
erlog
operands
sunos
lifetime
dc
loginview
.htpasswd
sql-function
nodeload
proxy-server
strcmp
saga
apportable
gprof
arrow
cakeyframeanimation
mmc3
drawimage
principles
raw-data
tso
community-server
word-automation

Resources

Encrypt Message