Laravel 报错增加 百度搜索

最近的新项目都是使用laravel开发的,因为它号称“Laravel – 为 WEB 艺术家创造的 PHP 框架”。相比ThinkPHP5,优势还是很大的,ThinkPHP很多东西还需要自己造轮子,laravel直接拿来轮子装上就可以。

特别是报错的处理(好像也是用的社区的,不是laravel官方维护的),比ThinkPHP强太多了。不仅提供了错误位置和调用者,还贴心的增加了 google、stackoverflow的搜索图标,一点既可以搜索相关错误。这个对我们这些 “面向搜索引擎”的开发者来太方便了,如图:

非常可惜的是,只又国内不可以用的谷歌搜索,没有百度。百度搜索了下也没有找到添加方法,自己分析了下,终于找到了对应的文件。

不仅增加了百度搜索,还增加了国内人气比较高的segmentfault,最终报错效果如下:

文件位置在:vendor\filp\whoops\src\Whoops\Resources\views\header.html.php,添加以下代码就可以了:

<!--自定义搜索开始-->
      <li>
        <a rel="noopener noreferrer" target="_blank" href="https://www.baidu.com/s?wd=<?php echo urlencode(implode('\\', $name) . ' ' . $message) ?>" title="Search for help on Baidu.">
          <svg preserveAspectRatio="xMidYMid" width="14" height="14" viewBox="0 0 28 30">
            <path d="M24.779,17.826 C21.142,17.903 20.991,15.410 20.991,13.622 C20.991,11.750 21.377,9.099 24.306,9.099 C27.228,9.099 28.013,11.908 28.013,12.839 C28.013,13.777 28.411,17.746 24.779,17.826 ZM18.303,9.567 C15.854,9.258 15.301,7.080 15.539,4.896 C15.735,3.110 17.906,0.373 19.645,0.766 C21.377,1.154 22.961,3.417 22.640,5.363 C22.326,7.311 20.755,9.882 18.303,9.567 ZM18.303,15.021 C20.515,18.137 24.305,21.019 24.305,21.019 C24.305,21.019 27.145,23.203 25.330,27.408 C23.517,31.616 16.882,29.429 16.882,29.429 C16.882,29.429 14.435,28.653 11.590,29.276 C8.752,29.900 6.304,29.665 6.304,29.665 C6.304,29.665 2.984,29.743 2.037,25.616 C1.091,21.485 5.350,19.223 5.669,18.839 C5.985,18.447 8.193,16.970 9.614,14.631 C11.038,12.298 15.300,10.427 18.303,15.021 ZM10.408,9.261 C8.575,9.261 7.091,7.187 7.091,4.624 C7.091,2.060 8.575,-0.011 10.408,-0.011 C12.239,-0.011 13.719,2.060 13.719,4.624 C13.719,7.187 12.239,9.261 10.408,9.261 ZM4.246,15.803 C0.933,16.505 -0.299,12.735 0.066,10.968 C0.066,10.968 0.457,7.154 3.144,6.919 C5.278,6.736 6.850,9.032 7.013,10.347 C7.111,11.199 7.563,15.102 4.246,15.803 Z" class="cls-1"/>
          </svg>
        </a>
      </li>
      <li>
        <a rel="noopener noreferrer" target="_blank" href="https://segmentfault.com/search?q=<?php echo urlencode(implode('\\', $name) . ' ' . $message) ?>" title="Search for help on Segmentfault.">
          <svg height="16" viewBox="0 0 176 33">
            <path d="M1.422 20.994c1.084.993 2.642 1.884 4.132 1.884 1.083 0 2.302-.48 2.302-1.781 0-1.44-1.659-1.679-3.522-2.502-2.1-.925-3.86-2.056-3.86-4.763 0-3.529 2.81-5.037 6.298-5.037 1.896 0 3.928.445 5.384 1.404v.411l-1.354 2.707c-.948-.72-2.235-1.2-3.657-1.2-1.253 0-2.032.515-2.032 1.508 0 1.303 1.49 1.577 3.352 2.296 2.574.993 4.131 2.09 4.131 4.865 0 3.632-2.81 5.209-6.535 5.209-2.37 0-4.267-.651-6.062-2.022v-.41l1.423-2.57zm20.014 5.003c-5.52 0-7.755-3.872-7.755-8.703 0-4.763 2.066-8.498 7.518-8.498 5.25 0 7.112 3.427 7.112 7.881 0 .514-.136 1.44-.34 1.988-1.286 0-9.176-.068-9.515-.068.034 1.815.813 4.214 3.522 4.214 1.388 0 2.54-.72 3.556-1.816l1.93 2.193v.411c-1.626 1.439-3.522 2.398-6.028 2.398zm-.238-13.843c-1.659 0-2.607 1.302-2.708 4.01.372 0 5.079-.104 5.249-.104-.001-2.57-.746-3.906-2.54-3.906zm23.298.206v13.876c0 4.729-3.522 6.716-7.383 6.716-2.167 0-4.504-.582-6.332-1.679L32 28.223h.406c1.219.823 2.743 1.371 4.2 1.371 1.997 0 3.114-1.028 3.114-2.81 0-.274.102-1.85.17-2.81l-.136-.068c-1.152 1.063-2.54 2.056-4.436 2.056-4.639 0-5.756-4.283-5.756-8.67 0-4.282 1.727-8.497 5.858-8.497 1.829 0 3.285.823 4.504 1.954l.102-.069.338-1.2.373-.342 3.86.103c-.033.343-.101 2.09-.101 3.118zm-4.741 1.37c-.746-.857-1.761-1.37-2.675-1.37-2.27 0-2.54 3.083-2.54 4.934 0 2.021.102 5.413 2.235 5.413.948 0 2.133-.788 2.912-1.781 0-.343.068-6.82.068-7.196zm25.058 11.821c0-.308.136-10.485.136-10.793 0-1.713-.44-2.365-1.49-2.365-.779 0-1.862.446-2.709 1.13v12.028h-4.673c0-.308.068-10.485.068-10.793 0-1.713-.406-2.365-1.388-2.365-.812 0-1.93.48-2.776 1.166l.033 11.992h-4.808V13.456c0-1.166-.068-3.495-.102-4.215l3.996-.103.372.343.238 1.337.067.034c1.456-1.2 3.488-2.022 5.215-2.022 1.354 0 2.641.617 3.285 2.09 1.658-1.302 3.793-2.09 5.52-2.09 2.2 0 3.928 1.37 3.928 4.866 0 .343-.102 11.513-.102 11.855h-4.81zm14.629.446c-5.52 0-7.754-3.872-7.754-8.703 0-4.763 2.066-8.498 7.517-8.498 5.25 0 7.112 3.427 7.112 7.881 0 .514-.135 1.44-.339 1.988-1.287 0-9.177-.068-9.516-.068.034 1.815.813 4.214 3.522 4.214 1.389 0 2.54-.72 3.556-1.816l1.93 2.193v.411c-1.626 1.439-3.522 2.398-6.028 2.398zm-.237-13.843c-1.66 0-2.608 1.302-2.709 4.01.373 0 5.08-.104 5.25-.104-.002-2.57-.746-3.906-2.541-3.906zm18.15 13.397c0-.308.135-10.485.135-10.793 0-1.748-.406-2.365-1.558-2.365-.846 0-2.066.549-2.98 1.166l.034 11.992h-4.809V13.456c0-1.2-.067-3.495-.101-4.215l3.995-.103.373.343.237 1.337.068.034c1.524-1.13 3.725-2.022 5.52-2.022 2.268 0 3.995 1.37 3.995 4.866 0 .343-.102 11.513-.102 11.855h-4.807zm12.935 0c-4.232 0-4.537-2.467-4.537-4.865 0-.343 0-4.798.068-8.019-1.05.035-1.727.035-2.065.035l.034-3.461c.339 0 .982 0 2.031.034a635.539 635.539 0 0 1-.068-4.626l.34-.343h4.47c0 .309 0 2.365-.068 4.969 1.185-.034 2.777-.034 3.115-.034l-.067 3.46c-.34 0-1.863 0-3.048-.034.034 3.118.034 7.127.034 7.436 0 1.713.033 2.055 1.523 2.055h1.32l.069 3.05-.339.343h-2.811z" fill="#fff"/>
            <path d="M117.62 25.551c0-.343.069-9.663.103-12.884-.915.035-1.863.035-2.134.035l.034-3.461c.27 0 1.185 0 2.066.034 0-.137-.068-2.981-.068-3.084 0-3.872 2.235-5.311 5.147-5.311 1.253 0 2.54.206 3.827.754v.514l-.982 2.74c-.542-.307-1.151-.48-1.693-.48-.948 0-1.558.48-1.558 2.296 0 .617.034 2.433.034 2.57 1.016-.034 2.946-.034 3.216-.034l-.033 3.46c-.271 0-2.202 0-3.217-.033.068 3.22.068 12.54.068 12.883h-4.81v.001zm18.964 0l-.339-.343-.406-1.302-.135-.034c-1.457 1.336-3.082 2.124-5.08 2.124-3.623 0-4.266-3.152-4.266-5.002 0-5.277 4.47-5.586 9.143-5.86v-1.062c0-1.507-.982-1.885-2.167-1.885-2.1 0-4.03.686-5.181 1.13l-1.05-2.74v-.411a22.039 22.039 0 0 1 7.619-1.37c3.352 0 5.553 1.404 5.553 5.07v7.745c0 1.336.068 3.255.102 3.94h-3.793zm-1.05-7.846c-3.183.068-4.57.103-4.57 2.672 0 1.2.304 2.33 1.59 2.33.813 0 1.931-.445 2.947-1.507 0-.206.068-3.255.068-3.461l-.035-.034zm17.88 7.846l-.34-.343-.406-1.37-.135-.035c-1.794 1.714-3.658 2.193-5.52 2.193-2.472 0-4.267-1.37-4.267-4.865 0-.343.102-11.547.102-11.89h4.47l.34.343c0 .377-.103 10.21-.103 10.656 0 1.233.407 2.398 1.626 2.398 1.016 0 2.37-.685 3.183-1.541l-.068-11.856h4.47l.339.343v12.027c0 1.337.068 3.255.101 3.94h-3.792zm11.14-3.941c0 1.303.069 3.256.136 3.941h-4.808c-.069-.685-.136-2.639-.136-3.94V5.403c0-1.302-.034-3.254-.102-3.94l4.572-.137.338.343v19.942zm8.128 3.941c-4.233 0-4.537-2.467-4.537-4.865 0-.343 0-4.798.068-8.019-1.05.035-1.727.035-2.066.035l.034-3.461c.34 0 .982 0 2.032.034a635.519 635.519 0 0 1-.068-4.626l.339-.343h4.47c0 .309 0 2.365-.068 4.969 1.186-.034 2.777-.034 3.115-.034l-.067 3.46c-.339 0-1.862 0-3.048-.034.034 3.118.034 7.127.034 7.436 0 1.713.034 2.055 1.524 2.055h1.32l.068 3.05-.339.343h-2.81z" fill="#009A61"/>
          </svg>
        </a>
      </li>
<!--自定义搜索结束-->
我来评几句
登录后评论

已发表评论数()

相关站点

热门文章