├── LICENSE.md
├── README.md
├── composer.json
├── config
└── envicon.php
├── resources
└── favicons
│ ├── local.svg
│ ├── production.svg
│ └── staging.svg
└── src
├── Envicon.php
├── Facades
└── Envicon.php
└── ServiceProvider.php
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Nicolas Hedger
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Laravel Envicon
2 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | This package allows you to display a custom favicon depending on your
15 | runtime environment. This makes it easy to identify immediately on which
16 | environment you're browsing.
17 |
18 | ## Install
19 |
20 | Via [Composer](https://getcomposer.org/)
21 |
22 | ```shell script
23 | composer require hedger/laravel-envicon
24 | ```
25 |
26 | Once the package is installed, you'll need to **publish the configuration**
27 | to link your environments to custom favicons.
28 |
29 | ```shell script
30 | php artisan vendor:publish --tag=envicon-config
31 | ```
32 |
33 | If you want to use the default envicons provided by this package, run
34 | the following command that will copy them in your `public/favicons`
35 | folder.
36 |
37 | ```shell script
38 | php artisan vendor:publish --tag=envicon-favicons
39 | ```
40 |
41 | ## Usage
42 |
43 | Simply use the provided helper in place of your favicon's URL. This will
44 | return the favicon that matches your current **runtime environment**.
45 |
46 | ```blade
47 |
48 |
49 |
50 |
51 |
52 |
53 | ```
54 |
55 | If you need the URL of a favicon for a **specific environment**, use the
56 | following statement instead. You'll need to pass the environment's name
57 | as the first parameter.
58 |
59 | ```blade
60 |
61 |
62 |
63 |
64 |
65 |
66 | ```
67 |
68 | ## Testing
69 | Tests can be run using the following composer script.
70 | ```shell script
71 | composer test
72 | ```
73 |
74 | ## License
75 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
76 |
77 | [ico-version]: https://img.shields.io/packagist/v/hedger/laravel-envicon.svg?style=flat-square
78 | [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
79 | [ico-build]: https://img.shields.io/github/workflow/status/nhedger/laravel-envicon/Test/master?style=flat-square
80 | [screenshot]: .github/screenshot.png
81 |
82 | [link-packagist]: https://packagist.org/packages/hedger/laravel-envicon
83 |
84 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hedger/laravel-envicon",
3 | "description": "Use a different favicon depending on your current runtime environment",
4 | "homepage": "https://github.com/nhedger/envicon",
5 | "license": "MIT",
6 | "authors": [
7 | {
8 | "name": "Nicolas Hedger",
9 | "email": "nicolas@hedger.ch",
10 | "role": "Developer"
11 | }
12 | ],
13 | "minimum-stability": "stable",
14 | "require": {
15 | "php": "~8.0 || ~8.1 || ~8.2",
16 | "illuminate/support": "^9.0 || ^10.0"
17 | },
18 | "require-dev": {
19 | "orchestra/testbench": "^7.0 || ^8.0",
20 | "phpunit/phpunit": "^9.0 || ^10.0"
21 | },
22 | "autoload": {
23 | "psr-4": {
24 | "Hedger\\Envicon\\": "src"
25 | }
26 | },
27 | "autoload-dev": {
28 | "psr-4": {
29 | "Hedger\\Envicon\\Tests\\": "tests"
30 | }
31 | },
32 | "scripts": {
33 | "test": "./vendor/bin/phpunit",
34 | "test-coverage": "./vendor/bin/phpunit --coverage-html coverage"
35 | },
36 | "config": {
37 | "sort-packages": true
38 | },
39 | "extra": {
40 | "laravel": {
41 | "providers": [
42 | "Hedger\\Envicon\\ServiceProvider"
43 | ],
44 | "aliases": {
45 | "Envicon": "Hedger\\Envicon\\Facades\\Envicon"
46 | }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/config/envicon.php:
--------------------------------------------------------------------------------
1 | 'favicons/production.svg',
16 |
17 | /*
18 | |--------------------------------------------------------------------------
19 | | Environments
20 | |--------------------------------------------------------------------------
21 | |
22 | | For each of your environments, define the favicon to be used by following
23 | | the following example. The given paths must be relative to the public/
24 | | folder.
25 | |
26 | | Feel free to add or remove environments as needed.
27 | |
28 | */
29 | 'environments' => [
30 | 'local' => 'favicons/local.svg',
31 | 'staging' => 'favicons/staging.svg',
32 | 'production' => 'favicons/production.svg'
33 | ]
34 |
35 | ];
36 |
--------------------------------------------------------------------------------
/resources/favicons/local.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/resources/favicons/production.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/resources/favicons/staging.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/src/Envicon.php:
--------------------------------------------------------------------------------
1 | config = $config;
15 | }
16 |
17 | /**
18 | * Returns the URL of the favicon for the runtime environment
19 | */
20 | public function url()
21 | {
22 | return $this->for(App::environment());
23 | }
24 |
25 | /**
26 | * Returns the URL of the favicon for the given environment
27 | *
28 | * @param string $env name of the environment, as as defined in the config file
29 | * @return string URL to the favicon, or the default favicon URL if the environment does not exist
30 | */
31 | public function for($env)
32 | {
33 | return asset($this->config['environments'][$env] ?? $this->config['default_favicon']);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Facades/Envicon.php:
--------------------------------------------------------------------------------
1 | app->runningInConsole()) {
13 | $this->publishes([
14 | __DIR__ . '/../config/envicon.php' => config_path('envicon.php')
15 | ], ['envicon-config']);
16 |
17 | $this->publishes([
18 | __DIR__ . '/../resources/favicons/' => public_path('favicons')
19 | ], ['envicon-favicons']);
20 | }
21 | }
22 |
23 | /**
24 | * Register the package
25 | */
26 | public function register()
27 | {
28 | $this->mergeConfigFrom(
29 | __DIR__ . '/../config/envicon.php',
30 | 'envicon'
31 | );
32 |
33 | $this->app->bind('envicon', function () {
34 | return new Envicon(config('envicon'));
35 | });
36 | }
37 | }
38 |
--------------------------------------------------------------------------------