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

Parsing Rome2Rio json file with PHP
Cannot connect Yii with local SQL Server 2012
How to use google cloud storage as Laravel 5 filesystem?
Travis could not find source file
Table Pagination Incorrect and Not limiting records - Bootstrap Datatable
Mcrypt PHP extension required in Mac OS X El Capitan
Using PHP namespaces on a subnamespace
Cache IP from GeoPlugin PHP result
Send POST request with csv file without storing the file
The php-mapscript does not work on Opensuse 13.1
CSV file column (empty string values to NULL)
Prevent encoding of existing HTML entities (convert & to & but not & to &)
Dynamic link and post with php
How to decode PHP serialized Redis response with Golang
web.config not working in IIS8.0
Zend\Stdlib\Hydrator\ArraySerializable::extract expects the provided object to implement getArrayCopy()

Categories

HOME
qt
rust
nam
android-espresso
powerbi
windows-8.1
clearcase
schema.org
opencv-python
transactions
devexpress
iverilog
sentry
ui-automation
mithril.js
polymer-2.x
azure-logic-apps
eddystone
migrate
xamarin-zebble
slide
locationmanager
csrf
vimeo
outlook-restapi
spring-jpa
c#-7.0
exe
string-formatting
cmake-gui
jest
akka-persistence
channel
ratio
ipa
crud
npoi
django-import-export
laravel-4.2
basic-authentication
intune
location-services
reporting
caesar-cipher
osx-lion
devtools
polyml
express-session
runtimeexception
django-smart-selects
widestring
microkernel
get-event-store
system-on-chip
word-cloud
yoast
contactless-smartcard
web-inspector
intellij-lombok-plugin
cordova-ios
sonatype
android-webservice
mongodb-aggregation
glimpse
haraka
nclam
eclemma
processor
jeasyui
seadragon
ioctl
servicestack-bsd
json-spirit
directx-9
canopy
compositetype
relational-model
prism-4
nesper
rails-api
miglayout
jms-serializer
sql-view
sly-scroller
notin
web-frameworks
background-thread
django-filebrowser
significant-digits
system-requirements
xalan
multiple-dispatch
spark-view-engine
nsmutablestring
arrow
uploading
type-safety
snackjs
play2-mini
office-automation
fragment-identifier
webresponse
principles
rawcontacts
twitter-feed
objectinstantiation
jvm-bytecode

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile