├── composer.json ├── .github └── FUNDING.yml ├── app └── Http │ └── Middleware │ └── FaviconInterceptor.php ├── LICENSE └── README.md /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "genealabs/laravel-appleseed", 3 | "description": "Prevent the pesky missing-favicon error log entries, and return 404 if they don't exist.", 4 | "license": "MIT", 5 | "authors": [ 6 | { 7 | "name": "Mike Bronner", 8 | "email": "hello@genealabs.com" 9 | } 10 | ], 11 | "autoload": { 12 | "psr-4": { 13 | "GeneaLabs\\LaravelAppleseed\\": "app/" 14 | } 15 | }, 16 | "require": { 17 | "php": ">=5.5.9", 18 | "illuminate/support": "~5.1" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: mikebronner 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /app/Http/Middleware/FaviconInterceptor.php: -------------------------------------------------------------------------------- 1 | getUri()); 18 | preg_match_all('/(apple-touch-icon.*?\.png|favicon(?:.*?)\.(?:png|ico)|android-chrome.*?.png|manifest.json|safari-pinned-tab.svg|mstile.*?.png)/', $file['basename'], $matches); 19 | $matches = array_filter($matches); 20 | 21 | if ((count($matches) > 1) && (! file_exists(public_path($file['basename'])))) { 22 | abort(404); 23 | } 24 | 25 | return $next($request); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 GeneaLabs, LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Appleseed for Laravel 2 | 3 | ![Appleseed for Laravel masthead image.](https://repository-images.githubusercontent.com/46007656/88c36100-f297-11e9-8bb9-c0917e799f0f) 4 | 5 | [![Join the chat at https://gitter.im/GeneaLabs/laravel-appleseed](https://badges.gitter.im/GeneaLabs/laravel-appleseed.svg)](https://gitter.im/GeneaLabs/laravel-appleseed?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 6 | [![Build Status](https://travis-ci.org/GeneaLabs/laravel-appleseed-tests.svg)](https://travis-ci.org/GeneaLabs/laravel-appleseed-tests) [![Coverage Status](https://coveralls.io/repos/GeneaLabs/laravel-appleseed-tests/badge.svg?branch=master&service=github)](https://coveralls.io/github/GeneaLabs/laravel-appleseed-tests?branch=master) 7 | 8 | ## Reasoning 9 | Eliminate error and server log entries that get thrown by missing favicons, especially the apple-touch-icon.png errors. 10 | 11 | ## Considerations 12 | If you are seeing errors in your server logs, its for a reason: favicons are custom representations of your site, and 13 | its probably good to implemented them. This just provides a better user experience for the various devices and browsers 14 | that want them. 15 | 16 | However, there are times when we just don't want to deal with this, and are spinning up in-house or small experimental 17 | projects that won't be used publicly like that. That's what this package is for. Simply add it via composer, and add 18 | middleware entry as describe below, and it will return 404s for the missing favicons without cluttering your logs. 19 | 20 | ### Dependencies 21 | - Your project should be running Laravel 5+. 22 | 23 | ## Installation 24 | 1. Install Laravel Appleseed via composer: 25 | ```sh 26 | composer require genealabs/laravel-appleseed 27 | ``` 28 | 29 | 2. Add the middleware entry in `app/Http/Kernel.php` directly after the maintenance mode middleware: 30 | ```php 31 | /* 32 | protected $middleware = [ 33 | \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, 34 | */ 35 | \GeneaLabs\LaravelAppleseed\Http\Middleware\FaviconInterceptor::class, 36 | /* 37 | [...] 38 | ]; 39 | */ 40 | ``` 41 | 42 | ## Usage 43 | That was it! It will inspect each route for favicon requests and handle it appropriately. 44 | 45 | ## Credits 46 | Jesse Leite (@jesseleite85) provided lots of ideas and input on making this happen. Thanks! 47 | --------------------------------------------------------------------------------