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

MySql COUNT() as field returns only one entry
Passing on optional parameters in PHP
conditional insert column values
How to change nav links color according to page when using PHP
500 Internal Server Error while using mail() function in PHP
PHP Multi dimensional array sort with key
Compare two JSON in PHP
Removing Switch Statement Smell from a Websocket Server [closed]
dynamic menu with php and i18n doesn't work
Ajax request from overridden component of joomla template
MySQL GROUP_CONCAT & PHP parsing
how to use 2 mod_rewrites in single .htaccess file
Yii2 how to include a php file in a Controller
How to open two files concurrently with fopen ? [closed]
When writing a Twig Extension in Symfony, why must you provide a getName()?
extracting data using php preg_match [duplicate]

Categories

HOME
freeradius
jms
livecode
opencv-python
softlayer
foaf
websocket
twitter-fabric
gentelella
phpseclib
amazon-emr
jquery-select2-4
playframework-2.0
google-sites
gravity
tfsbuild
spyder
angular2-highcharts
pst
kamailio
maven-surefire-plugin
mime-types
ratio
environment
morris.js
onchange
basex
copy-protection
locks
premake
opnet
db2-luw
rails-postgresql
buildforge
stackpanel
nsuserdefaults
ms-dos
mv
ng-repeat
utf
get-event-store
data-uri
expandablelistview
permission-denied
moinmoin
bit-shift
sigsegv
sesame
word-2016
perl-data-structures
yargs
deviare
nclam
mathjs
qtcpsocket
vimperator
i2b2
flipclock
smart-tv
hmisc
alwayson
physicsjs
deque
encryption-symmetric
jquery-mobile-flipswitch
squeezebox
windows-messages
miglayout
bittorrent-sync
tabletools
armv6
jmenubar
vlab
oscilloscope
tfs-sdk
email-verification
system-requirements
prefuse
kobold2d
snackjs
winsxs
kohana-auth
mygeneration
mysqli-multi-query
main-method
motif
isapi-redirect

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App