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

Deleting a video using YouTube API v3 PHP
Multiset MySQL query with complex count
Dumping PHP echo in jQuery
Where is ApiTester.php for Codeception?
Parsing php code conditionally to avoid parse errors on older php versions
Azure web.config restricting IP Addresses page refresh exception
Symfony2: how to implement custom user login & registration - get rid of FOSUSerBundle
removing duplicate rows if one of the columns are the same Sql-server
The need to check whether a sql query was successful or not?
Laravel 4 under Nginx Proxy Reverse
how to use 2 database connection in one page in php
Difference between $table->string('some_text'); & $table->text('some_text'); in Laravel? [closed]
Wordpress admin dashboard works very slow with many pages
index.php returning a blank web page on openshift host
CodeIgniter multiple database query
Array can not be displayed

Categories

HOME
hpoo
elasticsearch
magento2
mod-rewrite
biztalk
openfoam
google-search-console
wagtail
mutation-testing
msmq
siesta
bootstrap-switch
jquery-file-upload
xbox360
android-5.1.1-lollipop
string-formatting
infrared
jest
error-logging
stackexchange.redis
sipp
unordered-multimap
ipa
morris.js
window-managers
social-networking
location-services
epplus
cucumber-junit
kendo-listview
restful-architecture
redgate
identify
mv
python-jira
vb.net-to-c#
optionaldataexception
type-inference
docker-ucp
windows-media-player
return-type
amazon-elastic-beanstalk
sonatype
embedded-v8
android-mediarecorder
stateless-session-bean
dtd
dex
fitbit
oid
nunit-console
between
wolfram-language
jsr363
voronoi
phpquery
stack-smash
arbre
360-degrees
fuseesb
lifetime
string.format
configurable-product
wicket-1.5
iplimage
berkeley-db-xml
two.js
zend-search-lucene
strcmp
delphi-xe4
android-authenticator
smartfox
thejit
netstream
background-repeat
qtextbrowser
motodev-studio
firefly-mv
kext
anonymous-types
tessellation
pinax
self-tracking-entities
.net-services
stretchblt

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile