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

Redirect to custom error page if there is error in the page
PhoneGap/Cordova Push GeoLocation from localStorage vars to MySQL
Regex match the double quote in BBCode attribute
Sort array by sub-values from JSON data [closed]
unwanted semicolon in output (php heredoc sytax)
PHP Regex fetch groups SQL like queries
PHP Session not carrying over to protected pages
style css doesent affect the images i put using .php
order database tables by creation time
Using a function in another function both within the same class in PHP
phpmyadmin sso doesn't remove existing session in logout
How to change paths of img sources
Count duplicate records
how to add product inside a php page when after executing the insert query
Can not scan a directory in another server
Strange JSON behaviour with accentuated characters

Categories

HOME
orientdb
knockout.js
lambda
xcode
tomcat
apple-push-notifications
hdfs
whmcs
ag-grid
phpmqtt
onvif
responsive-design
fbloginview
mpu6050
django-rq
xbox360
android-custom-view
mime-types
rxjs5
sybase-ase
objectmapper
commonsware-cwac
redgate
bluemixtools
telephonymanager
sbjson
fluid-mac-app-engine
moinmoin
cloudwatch
roracle
photoswipe
jgrapht
solr-query-syntax
nivo-slider
case-when
oracle-fusion-apps
bigdecimal
openquery
nsrunloop
gcloud-node
traversable
adjacency-list
webgrind
boost-proto
opencyc
nastran
asp.net-web-api-helppages
hmisc
supercomputers
ngcordova
vdm-sl
relational-model
nsmutabledata
comctl32
n-tier-architecture
rebar
utf8-decode
global-scope
dmake
coding-efficiency
neo4jphp
sqlbindparameter
preorder
hotswap
smips
pbkdf2
unrealscript
notifyjs
mp4parser
semicolon
background-thread
gitx
clrprofiler
voice-recording
server-name
image-scanner
monocross
type-safety
navigationcontroller
delphi-prism
boost-foreach
firefly-mv
database-deadlocks
rtd
django-pagination
suphp
chunking
principles
self-tracking-entities
google-translator-toolkit
accumulator
server-load

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