当前位置: 首页 > 软件库 > Web应用开发 > Web框架 >

laravel-robots-middleware

Enable or disable the indexing of your app
授权协议 MIT License
开发语言 PHP
所属分类 Web应用开发、 Web框架
软件类型 开源软件
地区 不详
投 递 者 寇夜洛
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Enable or disable the indexing of your app

Check & fix styling

A tiny, opinionated package to enable or disable indexing your site via a middleware in Laravel.

More on the Robots meta tag: https://developers.google.com/webmasters/control-crawl-index/docs/robots_meta_tag

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

$ composer require spatie/laravel-robots-middleware

Usage

By default, the middleware enables indexing on all pages. You'll probably want to inherit your own class containing you application's indexing rule handler.

// app/Http/Middleware/MyRobotsMiddleware.php

use Illuminate\Http\Request;
use Spatie\RobotsMiddleware\RobotsMiddleware;

class MyRobotsMiddleware extends RobotsMiddleware
{
    /**
     * @return string|bool
     */
    protected function shouldIndex(Request $request)
    {
        return $request->segment(1) !== 'admin';
    }
}

Next, simply register the newly created class in your middleware stack.

// app/Http/Kernel.php

class Kernel extends HttpKernel
{
    protected $middleware = [
        // ...
        \App\Http\Middleware\MyRobotsMiddleware::class,
    ];
    
    // ...
}

That's it! Responses will now always have an x-robots-tag in their headers, containing an all or none value.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details. Due to nature of this package, there's a fair chance features won't be accepted to keep it light and opinionated.

Security

If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

  • laravel-api 项目目录 ├─app 应用目录 │ ├─Console 注册自定义Artisan命令和你定义的计划任务 │ ├─Events Events 目录存放了 事件类 │ ├─Exceptions 应用的异常处理器,也是应用抛出异常的地方 │ ├─Http 控制器、中间件和表单请求 │ │ ├─Controller 控制器目录 │ │ │ ├─v1 版本1目录 | | | ├─v2

  • ## Laravel学习笔记汇总——Laravel的目录结构 // 使用下面语句查看当前版本: // php artisan --version      # Laravel Framework 7.30.1 . ├── app  # 存放我们所开发应用的核心代码 │   ├── Broadcasting  # 通过 php artisan make:channel产生,存放所有broadcast

  • 开始 本地网址 5.5 jwt 使用 包括 vue 使用 5.5 jwt 使用通过 laravel 官方用户可以使用 jwt 开发环境部署 Laravel-Modules Laravel 模块化开发 社区 跨域 通过 jwt 自定义 数据表 区别于 auth 中的 users 表 url  修改jwt配置文件中  'user' => 'App\Models\ApiUser',  在认证的时候

  • laravel框架入坑回顾 官方网站:https://laravel.com/ 中文官网:https://laravel-china.org/docs/laravel/5.4 composer工具 官网网址:https://getcomposer.org/ 中文网址:http://www.phpcomposer.com/ composer资源仓库或应用市场 网址:https://packagist

  • ■ PHP(Laravel框架)从入门到入土(杨定远老师) https://www.bilibili.com/video/BV1Wt411Q72f?p=1 PHP是一种开源脚本语言,主要适用于Web开发领域. 用PHP做出的动态页面与其他的编程语言相比,PHP是将程序嵌入到HTML文档中去执行,执行效率高。 ▲简介 https://www.bilibili.com/video/BV1Wt4

  • 一、laravel框架: 官网: https://laravel.com/ 中文网: http://laravelacademy.org https://laravel-china.org/ 二、laravel框架的安装,在文档中,已经解释了好多。我这里直接使用git从github上安装了下,具体操作,包括操作中出现的问题,总结下面几步: 1.下载5.2版本: 先fork官

  • 前后端分离的工作模式于今是非常流行了,前后端工作的对接,就离开不了API文档的辅助。   根据自己以往的工作经历,以及了解的一些资讯,API文档的建立,无非以下几种方式: 1. word文档模板 2. 第三方平台,类如postman、showdoc等 3. 框架内单独自定义一套绑定路由的结构,再解析成html页面 4. 在框架内每个路由的方法的注释块里按照规则写注释,再解析生成api文档 5. 框

  • 安装 composer create-project laravel/laravel learnlaravel5 --prefer-dist v5.3.* 安装成功之后会自动生成一个key > Illuminate\Foundation\ComposerScripts::postUpdate > php artisan optimize Generating optimized class lo

 相关资料
  • 什么是robots文件 Robots是站点与spider沟通的重要渠道,站点通过robots文件声明本网站中不想被搜索引擎收录的部分或者指定搜索引擎只收录特定的部分。 搜索引擎使用spider程序自动访问互联网上的网页并获取网页信息。spider在访问一个网站时,会首先会检查该网站的根域下是否有一个叫做 robots.txt的纯文本文件,这个文件用于指定spider在您网站上的抓取范围。您可以在您

  • �� Arguing robots �� Arguing robots is a simple CLI utility for macOS that allow the wonderfully expressive PlainTalk voices of macOS (including beloved whisper voice of Lain's Navi) to come to life i

  • Laravel 是一套简洁、优雅的PHP Web开发框架(PHP Web Framework)。它可以让你从面条一样杂乱的代码中解脱出来;它可以帮你构建一个完美的网络APP,而且每行代码都可以简洁、富于表达力。 功能特点 1、语法更富有表现力 你知道下面这行代码里 “true” 代表什么意思么? $uri = Uri::create(‘some/uri’, array(), array(), tr

  • 我需要空间/Laravel权限的帮助。当我试图分配它给我错误哎呀,看起来像出了问题。 错误 Connection.php第761行中的QueryExcema:SQLSTATE[23000]:完整性约束冲突:1048列role_id不能为空(SQL:插入到(,)值(9,))

  • Laravel 作为现在最流行的 PHP 框架,其中的知识较多,所以单独拿出来写一篇。 简述 Laravel 的生命周期 Laravel 采用了单一入口模式,应用的所有请求入口都是 public/index.php 文件。 注册类文件自动加载器 : Laravel通过 composer 进行依赖管理,无需开发者手动导入各种类文件,而由自动加载器自行导入。 创建服务容器:从 bootstrap/ap

  • 简介 Laravel Scout 为 Eloquent 模型 全文搜索提供了简单的,基于驱动的解决方案。通过使用模型观察者,Scout 会自动同步 Eloquent 记录的搜索索引。 目前,Scout 自带一个 Algolia 驱动;不过,编写自定义驱动很简单, 你可以轻松的通过自己的搜索实现来扩展 Scout。 安装 首先,通过 Composer 包管理器来安装 Scout: composer