當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ServerRequestInterface::getParam方法代碼示例

本文整理匯總了PHP中Psr\Http\Message\ServerRequestInterface::getParam方法的典型用法代碼示例。如果您正苦於以下問題:PHP ServerRequestInterface::getParam方法的具體用法?PHP ServerRequestInterface::getParam怎麽用?PHP ServerRequestInterface::getParam使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Psr\Http\Message\ServerRequestInterface的用法示例。


在下文中一共展示了ServerRequestInterface::getParam方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createPost

 public function createPost(Request $request, Response $response)
 {
     $title = $request->getParam('title');
     $content = $request->getParam('content');
     $slug = trim($title);
     $slug = str_replace(' ', '-', $slug);
     $post = new Post();
     $post->setTitle($title);
     $post->setContent($content);
     $post->setSlug($slug);
     $this->em->persist($post);
     $this->em->flush();
     echo "Da them bai viet moi thanh cong";
 }
開發者ID:hak2c,項目名稱:slim-doctrine-mvc,代碼行數:14,代碼來源:PostController.php

示例2: __invoke

 public function __invoke(Request $req, Response $res, $args = [])
 {
     $vaultName = $args['vaultName'];
     if (!($vault = Vault::get($vaultName))) {
         return $res->withStatus(404);
     }
     $operation = $req->getParam('operation');
     $postData = file_get_contents('php://input');
     $params = json_decode($postData, true);
     try {
         if ($operation === 'add') {
             if (empty($params['Tags'])) {
                 return $res->withStatus(400);
             }
             $vault->addTags($params['Tags']);
             return $res->withStatus(204);
         } elseif ($operation === 'remove') {
             if (empty($params['TagKeys'])) {
                 return $res->withStatus(204);
             }
             $vault->removeTags($params['TagKeys']);
             return $res->withStatus(204);
         }
         return $res->withStatus(400);
     } catch (\Gsandbox\Model\LimitExceededException $e) {
         return $res->limitExceededException();
     }
 }
開發者ID:sebcode,項目名稱:gsandbox,代碼行數:28,代碼來源:SetTagsAction.php

示例3: signinUser

 public function signinUser(Request $request, Response $response)
 {
     $username = $request->getParam('username');
     $password = $request->getParam('password');
     $u = $this->em->getRepository('App\\Model\\User')->findOneBy(array('username' => $username));
     if ($u == []) {
         echo "Username nay khong ton tai";
     } else {
         if ($u->getPassword() != $password) {
             echo "Ban nhap sai password";
         } else {
             echo "Ban da dang nhap thanh cong";
         }
     }
     return $response;
 }
開發者ID:hak2c,項目名稱:slim-doctrine-mvc,代碼行數:16,代碼來源:UserController.php

示例4: __invoke

 public function __invoke(ServerRequestInterface $requestInterface, ResponseInterface $responseInterface, callable $next)
 {
     $valid = $this->verify($requestInterface->getParam('g-recaptcha-response'), $requestInterface->getServerParams()['REMOTE_ADDR']);
     if ($valid) {
         return $next($requestInterface, $responseInterface);
     } else {
         throw new \Exception("Captcha Failed");
     }
 }
開發者ID:geggleto,項目名稱:psr7-recaptcha,代碼行數:9,代碼來源:Captcha.php

示例5: authenticate

 public function authenticate(ServerRequestInterface $request, ResponseInterface $response)
 {
     if (empty($username = $request->getParam('username')) || empty($password = $request->getParam('password')) || empty($grant = $request->getParam('grant_type')) || $grant !== 'password') {
         throw (new OAuth2Exception('Invalid parameters supplied for authentication'))->displayMessage(OAuth2Exception::BAD_CREDENTIALS)->response($response->withStatus(401));
     }
     $result = $this->authRepo->validateCredentials($username, $password);
     if (empty($result)) {
         throw (new OAuth2Exception('Wrong username or password'))->displayMessage(OAuth2Exception::BAD_CREDENTIALS)->response($response->withStatus(401));
     }
     $address = $this->getAddress();
     $expiration = $this->getExpiration($this->config['expiration']);
     $builder = (new Builder())->setIssuer($address)->setAudience($address)->setId(md5(uniqid(mt_rand(), true)), true)->setIssuedAt(time())->setNotBefore(time() + 60)->setExpiration($expiration)->setSubject($result['id']);
     $customClaims = [];
     foreach ($result as $claim => $value) {
         if ($claim !== 'id') {
             $customClaims[] = $claim;
             $builder->set($claim, $value);
         }
     }
     $token = $builder->set('cc', implode(',', $customClaims))->sign(new Sha256(), new Key($this->config['private-key']))->getToken();
     // Retrieves the generated token
     return $response->withHeader(\HTTP\Header\CacheControl::name(), \HTTP\Header\CacheControl::values([\HTTP\Header\CacheControl::NO_CACHE, \HTTP\Header\CacheControl::REVALIDATE]))->writeJson(['token' => sprintf('%s', $token), 'type' => 'Bearer', 'expires' => $expiration]);
 }
開發者ID:marcoazn89,項目名稱:oauth2-password-grant,代碼行數:23,代碼來源:OAuth2.php


注:本文中的Psr\Http\Message\ServerRequestInterface::getParam方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。