• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Http\Response类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Illuminate\Http\Response的典型用法代码示例。如果您正苦于以下问题:PHP Response类的具体用法?PHP Response怎么用?PHP Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Response类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getQr

 public function getQr(Request $req)
 {
     $qrCode = new QrCode();
     $qrCode->setText("http://10.0.20.55:8001/index/wel#/sys/activities/one")->setSize(300)->setPadding(10)->setErrorCorrection('high')->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0));
     $response = new Response($qrCode->get(), 200);
     $response->header('content-type', 'image/png');
     return $response;
 }
开发者ID:vimac,项目名称:hackathon2015,代码行数:8,代码来源:CommonController.php


示例2: getIndex

 public function getIndex(Request $request)
 {
     $data = [];
     $userControllerObj = new UserController();
     $cookie = $userControllerObj->checkCookie($request);
     $data['categories'] = Categories::getCategories();
     if ($cookie === 0) {
         return View::make('index', $data);
     } else {
         if ($cookie === -1) {
             $response = new Response('Your cookie is invalid, We have cleared it for you, Refresh to re-login to NEUP-Channel');
             return $response->withCookie('neupchan', "", -1);
         } else {
             if ($cookie->shortCookie === NULL) {
                 $shortCookie = $cookie->short_cookie;
                 $data['firstLogin'] = true;
             } else {
                 $shortCookie = $cookie->shortCookie;
                 $data['lastLoginIP'] = $cookie->last_login_ip;
             }
         }
     }
     $data['shortCookie'] = $shortCookie;
     //return View::make('index', $data)->withCookie(cookie('neupchan', $cookie, 90 * 24 * 60));
     $response = new Response(view('index', $data));
     if (isset($data['firstLogin'])) {
         return $response->withCookie('neupchan', $cookie, 90 * 24 * 60);
     } else {
         return $response;
     }
 }
开发者ID:VOID001,项目名称:NEUP-channel,代码行数:31,代码来源:ContentController.php


示例3: makeMessageFromResponse

 protected function makeMessageFromResponse(Response $response)
 {
     $message['original_content'] = $response->getOriginalContent();
     $message['content'] = $response->getContent();
     $message['status_code'] = $response->getStatusCode();
     return json_encode($message, JSON_PRETTY_PRINT);
 }
开发者ID:alfred-nutile-inc,项目名称:incomings-client,代码行数:7,代码来源:IncomingsMiddleWare.php


示例4: handle

 public function handle($request, Closure $next)
 {
     $response = new Response();
     if (Auth::check() === false) {
         $request->request->set('roleId', $this->retrieveRoleIdByName('Customer'));
         return $next($request);
     }
     $user = Auth::user();
     if ($user === null) {
         $response->header(Constants::RESPONSE_HEADER, "Failed to retrieve authenticated user.");
         $response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
         return $response;
     }
     $role = Roles::where('id', $user->role_id)->firstOrFail();
     if ($role->name !== "Administrator") {
         $response->header(Constants::RESPONSE_HEADER, "Permission are required for performing registration operation.");
         $response->setStatusCode(Response::HTTP_FORBIDDEN);
         return $response;
     }
     try {
         $roleName = $request->get('roleName');
         if ($roleName === null) {
             $request->request->set('roleId', $this->retrieveRoleIdByName('Customer'));
         } else {
             $request->request->set('roleId', $this->retrieveRoleIdByName($roleName));
         }
     } catch (Exception $exception) {
         $response->header(Constants::RESPONSE_HEADER, $exception->getMessage());
         $response->setStatusCode(Response::HTTP_BAD_REQUEST);
         return $response;
     }
     return $next($request);
 }
开发者ID:JulietaGosheva,项目名称:truck-shop,代码行数:33,代码来源:RegistrationMiddleware.php


示例5: setResponse

 /**
  * Preparing Response
  *
  * @return Response
  */
 protected function setResponse()
 {
     $response = new Response();
     $response->setStatusCode($this->content['http_code']);
     $response->setContent($this->content);
     return $response;
 }
开发者ID:Baasify,项目名称:Baasify,代码行数:12,代码来源:MainController.php


示例6: deleteMemberFund

 /**
  * Deletes members funds and recalculates total
  *
  * @param $incomeServiceId
  * @param $memberId
  * @return \Illuminate\Http\JsonResponse
  */
 public function deleteMemberFund($incomeServiceId, $memberId, Response $response, Gate $gate)
 {
     if (!$gate->check('putPostDelete', new IncomeServiceMemberFund())) {
         return $response->setContent('Unauthorized')->setStatusCode(401);
     }
     return response()->json($this->dispatch(new DeleteIncomeServiceMemberFundTotal($incomeServiceId, $memberId)));
 }
开发者ID:jraymundoyrockdev,项目名称:api-gfccm-systems,代码行数:14,代码来源:IncomeServiceMemberFundsController.php


示例7: responseFactory

 public function responseFactory($content, $code = 200)
 {
     $response = new Response();
     $response->setContent($content);
     $response->setStatusCode($code);
     return $response;
 }
开发者ID:helpscout,项目名称:specter,代码行数:7,代码来源:IlluminateHttpFactory.php


示例8: postRegister

 public function postRegister(Request $request)
 {
     $errors = [];
     // Validate all fields have been received.
     $validator = \Validator::make($request->all(), array('email' => 'required|email|max:128|unique:users,email', 'username' => 'required|min:1|max:20|unique:users,name', 'password' => 'required|min:6|max:255', 'g-recaptcha-response' => 'recaptcha'));
     if ($validator->fails()) {
         // Validator detected some problems.
         foreach ($validator->errors()->getMessages() as $error) {
             $errors[] = $error;
         }
     }
     if (count($errors) > 0) {
         // Errors detected, generate response
         $response = new Response(json_encode(['status' => false, 'errors' => $errors]), 200);
         $response->header('Content-Type', 'application/json');
         return $response;
     }
     // Get input
     $email = $request->input('email');
     $username = $request->input('username');
     $password = $request->input('password');
     // Register user
     $user = User::register($email, $username, $password);
     // Login
     Auth::login($user);
     // Generate response
     $response = new Response(json_encode(['status' => true]), 200);
     $response->header('Content-Type', 'application/json');
     return $response;
 }
开发者ID:harmjanhaisma,项目名称:clearboard,代码行数:30,代码来源:LoginController.php


示例9: addRateLimitToResponse

 /**
  * Add the RateLimit to the response cookies.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Illuminate\Http\Response $response
  * @return \Illuminate\Http\Response
  */
 protected function addRateLimitToResponse($request, $response, $limit)
 {
     $throttle = $this->throttle->get($request);
     $response->header('x-rate-limit-limit', $limit);
     $response->header('x-rate-limit-remaining', $limit - $throttle->count());
     return $response;
 }
开发者ID:sonoftheweb,项目名称:laravel-angular-cms,代码行数:14,代码来源:ThrottleMiddleware.php


示例10: put

 public function put(Route $route, Request $request, Response $response)
 {
     $key = $this->makeCacheKey($request->url());
     if (!Cache::has($key)) {
         Cache::put($key, $response->getContent(), 10);
     }
 }
开发者ID:RichJones22,项目名称:TimeTrax,代码行数:7,代码来源:CacheFilters.php


示例11: serialize

 /**
  * Serialize a response.
  *
  * @param \Illuminate\Http\Response $response
  *
  * @return string
  */
 public function serialize(Response $response)
 {
     $content = $response->getContent();
     $statusCode = $response->getStatusCode();
     $headers = $response->headers;
     return serialize(compact('content', 'statusCode', 'headers'));
 }
开发者ID:sdebacker,项目名称:laravel-responsecache,代码行数:14,代码来源:ResponseSerializer.php


示例12: store

 /**
  * Create new Income Service
  *
  * @param IncomeServiceRequest $request
  * @param Guard $guard
  * @param Response $response
  * @param Gate $gate
  * @return ItemResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function store(IncomeServiceRequest $request, Guard $guard, Response $response, Gate $gate)
 {
     if (!$gate->check('putPostDelete', new IncomeService())) {
         return $response->setContent('Unauthorized')->setStatusCode(401);
     }
     return new ItemResponse($this->dispatch(new CreateIncomeServiceCommand($request->get('service_id'), $request->get('service_date'), $guard->user()->id, 3, 'status')));
 }
开发者ID:jraymundoyrockdev,项目名称:api-gfccm-systems,代码行数:16,代码来源:IncomeServicesController.php


示例13: addCookieConsentScriptToResponse

 /**
  * @param \Illuminate\Http\Response $response
  *
  * @return $this
  */
 protected function addCookieConsentScriptToResponse(Response $response)
 {
     $content = $response->getContent();
     $closingBodyTagPosition = $this->getLastClosingBodyTagPosition($content);
     $content = '' . substr($content, 0, $closingBodyTagPosition) . view('cookieConsent::index')->render() . substr($content, $closingBodyTagPosition);
     return $response->setContent($content);
 }
开发者ID:spatie,项目名称:laravel-cookie-consent,代码行数:12,代码来源:CookieConsentMiddleware.php


示例14: appendDisqusScript

    /**
     * Append disqus script on the end of the page.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Illuminate\Http\Response $response
     * @return mixed
     */
    protected function appendDisqusScript($request, $response)
    {
        $content = $response->getContent();
        if (!Str::contains($content, '<div id="disqus_thread"></div>')) {
            return;
        }
        $uri = $request->getRequestUri();
        $pageUrl = url($uri);
        $pageId = 'route' . implode('.', explode('/', $uri));
        $username = config('disqus.username');
        $disqusHtml = <<<CDATA
<script>
     var disqus_config = function () {
         this.page.url = '{$pageUrl}';
         this.page.identifier = '{$pageId}';
     };

    (function() {  // DON'T EDIT BELOW THIS LINE
        var d = document, s = d.createElement('script');

        s.src = '//{$username}.disqus.com/embed.js';

        s.setAttribute('data-timestamp', +new Date());
        (d.head || d.body).appendChild(s);
    })();
</script>
<noscript>Please enable JavaScript to view the <a href=\\"https://disqus.com/?ref_noscript\\" rel=\\"nofollow\\">comments powered by Disqus.</a></noscript>
CDATA;
        $bodyPosition = strripos($content, '</body>');
        if (false !== $bodyPosition) {
            $content = substr($content, 0, $bodyPosition) . $disqusHtml . substr($content, $bodyPosition);
        }
        $response->setContent($content);
    }
开发者ID:yajra,项目名称:laravel-disqus,代码行数:41,代码来源:DisqusMiddleware.php


示例15: store

 public function store()
 {
     $preferences = Request::all();
     $response = new Response('OK');
     $response->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_AMOUNT, $preferences['amount'], PreferencesVO::PREFERENCES_LIFESPAN))->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_PERIOD, $preferences['period'], PreferencesVO::PREFERENCES_LIFESPAN))->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_TAXCDB, $preferences['taxcdb'], PreferencesVO::PREFERENCES_LIFESPAN))->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_TAXLCI, $preferences['taxlci'], PreferencesVO::PREFERENCES_LIFESPAN));
     return $response;
 }
开发者ID:nielsonsantana,项目名称:rendafixa,代码行数:7,代码来源:PreferencesController.php


示例16: render

 /**
  * Render an exception into a response.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Exception $exception
  * @return \Illuminate\Http\Response
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function render($request, Exception $exception)
 {
     $response = (new SymfonyExceptionHandler(env('APP_DEBUG', false)))->createResponse($exception);
     $response = new Response($response->getContent(), $response->getStatusCode(), $response->headers->all());
     $response->exception = $exception;
     return $response;
 }
开发者ID:hrslash,项目名称:luminous,代码行数:16,代码来源:Handler.php


示例17: newThread

 /**
  * New thread (not the create thread page)
  * @param Request $request
  * @return string
  */
 public function newThread(Request $request)
 {
     // Validate input
     $this->validate($request, ['title' => 'required|max:255', 'forum' => 'required|numeric', 'body' => 'required|max:30000']);
     // Verify forum is a valid forum that can be posted in
     $forum = null;
     try {
         $forum = Forum::findOrFail($request->input('forum'));
     } catch (ModelNotFoundException $e) {
         abort(400);
         // 400 Bad Request - invalid forum id
     }
     if ($forum->type != 0) {
         abort(400);
         // 400 Bad Request - not correct forum type
     }
     // Create thread
     $thread = Thread::newThread($request->input('title'), $request->input('forum'));
     // Create opening post
     $post = post::newPost($request->input('body'), $thread->id);
     // Generate response
     $resp = new Response(json_encode(['status' => true, 'link' => $thread->getUserFriendlyURL()]), 200);
     $resp->header('Content-Type', 'application/json');
     return $resp;
 }
开发者ID:harmjanhaisma,项目名称:clearboard,代码行数:30,代码来源:ThreadController.php


示例18: setVisitor

 /**
  * [nextDate description]
  * @return [type] [description]
  */
 public function setVisitor(Request $request)
 {
     // Fetch cookie
     $cvuid_val = $request->cookie('CVUID');
     // Check if cookie exists
     if (isset($cvuid_val)) {
         $u = Visitor::where('session', '=', $cvuid_val)->first();
         // Check if user is alive
         if ($u != Null && $u->count() > 0) {
             $uid = $cvuid_val;
             $u->touch();
             //touch user to keep alive
         } else {
             // Create new user cause seems dead
             $uid = uniqid('_csnvaka', true);
             $v = new Visitor();
             $v->session = $uid;
             $v->save();
         }
     } else {
         // Create new user, cause totaly new :)
         $uid = uniqid('_csnvaka', true);
         $v = new Visitor();
         $v->session = $uid;
         $v->save();
     }
     // Create response with cookie
     $response = new Response($uid);
     $response->withCookie(cookie('CVUID', $uid, 720));
     return $response;
 }
开发者ID:Kodagrux,项目名称:CSNvaka.nu,代码行数:35,代码来源:visitorController.php


示例19: cacheResponse

 /**
  * Cache the response 1 year (31536000 sec)
  */
 protected function cacheResponse(Response $response)
 {
     $response->setSharedMaxAge(31536000);
     $response->setMaxAge(31536000);
     $response->setExpires(new \DateTime('+1 year'));
     return $response;
 }
开发者ID:focuslife,项目名称:v0.1,代码行数:10,代码来源:AssetController.php


示例20: saveUser

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function saveUser(Response $response, Request $request)
 {
     $despo = new Valentine();
     $Userexists = Valentine::getExistingUser($request->input('id'));
     if (is_object($Userexists)) {
         if (!is_null($Userexists->interests)) {
             $response->setContent('/findlove');
             $response->withCookie(cookie()->forever('shy_first_college', $Userexists->college));
         } else {
             $response->setContent('/profile/complete');
         }
         $response->withCookie(cookie()->forever('shy_first_id', $Userexists->id));
         $response->withCookie(cookie()->forever('shy_first_sex', $Userexists->sex));
     } else {
         $despo->name = $request->input('name');
         $despo->age = $request->input('birthday', '');
         $despo->sex = $request->input('gender');
         $despo->userId = $request->input('id');
         $despo->tel = $request->input('name');
         $despo->social = $request->input('social');
         $despo->url = $request->input('link');
         $despo->email = $request->input('email');
         if ($despo->save()) {
             $response->setContent('/profile/complete');
             $response->withCookie(cookie()->forever('shy_first_id', $despo->id));
             $response->withCookie(cookie()->forever('shy_first_sex', $request->input('sex')));
         }
     }
     return $response;
 }
开发者ID:niksrc,项目名称:SF,代码行数:35,代码来源:HomepageController.php



注:本文中的Illuminate\Http\Response类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Log\Writer类代码示例发布时间:2022-05-23
下一篇:
PHP Http\Request类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap