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

Can others see contents of variables in PHP?
Confirming Markdown Files
PHP SimpleXMLElement XPath Selection
PHP Unexpected T_encapsed [closed]
How to echo this specific value from a Database
Embedding a php function within a php form template variable
Yii - PHP error after content saying that LogDetailFilter couldn’t be found
mysql query , gives me wrong number of rows am after
How do I include a range of lines of a file in php?
How to display and manipulate visual objects in a web app?
Please help me with my comment sections sql query
How to extract data from this JSON ? [closed]
Image cropping and thumb creation
How to draw a name in a database [duplicate]
PHP: Generating category/subcategory UL list from array?
wikipedia servers gzip content

Categories

HOME
functional-programming
focus
paypal-ipn
transactions
systemd
dry
code-formatting
theano
iverilog
mongoid
gallery
elisp
greasemonkey
linker
impala
joomla3.2
kurento
msmq
fbloginview
phpstorm-2017.1
jodatime
c#-7.0
hidden
pfobject
raima
multi-dimensional-scaling
onchange
php-5.3
basic-authentication
audit
microsoft-certifications
om-next
android-collapsingtoolbar
autoencoder
bluemixtools
eclipse-gmf
cloudera-quickstart-vm
strapi
llvm-ir
aurelia-http-client
iscroll
selenide
assemblies
grails3.2.0
robust
dagger
xcode8.2
qvtkwidget
directwrite
sony-future-lab-n
uiautomatorviewer
simple-schema
line-intersection
mura
google-news
dynamics-crm-4
oid
streamwriter
msbuild-4.0
raw-sockets
qtcpsocket
oci
static-methods
odp.net-managed
distributed-cache
gravatar
univocity
android-expansion-files
canopy
supersocket.net
replicaset
python-curses
lifetime
device-admin
multivariate-testing
jquery-mobile-flipswitch
communicate
accountmanager
armv6
strcmp
codahale-metrics
libxml-js
red-system
dojo-1.9
linkbutton
cgrectmake
onconfigurationchanged
android-dialog
word-frequency
navigationcontroller
drawimage
net-use
css-friendly
dip
bass
mygeneration
rational-unified-process

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App