承接 vanchelo/laravel-custom-responses 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vanchelo/laravel-custom-responses

最新稳定版本:1.0.0

Composer 安装命令:

composer require vanchelo/laravel-custom-responses

包简介

Laravel Custom Responses

README 文档

README

#Laravel Custom Responses

Описание на русском

##Install

Require this package with composer:

composer require "vanchelo/laravel-custom-responses dev-master"

After updating composer, add the ServiceProvider to the providers array in app/config/app.php

'Vanchelo\CustomResponses\ResponsesServiceProvider'

Create responses folder in app/views and three blade templates: defult.blade.php, 403.blade.php, 404.blade.php

##How to use

In controller:

class PageController extends Controller
{
    public function index($id)
    {
        if ( ! $page = Page::find($id)) App::abort(404);
        // or
        if ( ! $page = Page::find($id)) return App::make(404);
        
        return View::make('page', compact('page'));
    }
}

##Create you own custom response

For example we will create custom response for 401 (Unauthorized) status code.

  1. Create class and put it on your app folder
<?php namespace Acme\Responses;

// app/Acme/Responses/Unauthorized.php

class Unauthorized extends Response
{
    protected $view = 'responses.401';
    protected $defaultCode = 401;
}
  1. Create blade template 401.blade.php and put it on app/views/responses

  2. Put this code in app/start/gobal.php:

App::bind('401', 'Acme\Responses\Unauthorized'); 
  1. That's all

统计信息

  • 总下载量: 51
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: GPLv2
  • 更新时间: 2014-12-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固