PHPackages                             daikazu/welcome-bar - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. daikazu/welcome-bar

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

daikazu/welcome-bar
===================

Add a welcome bar for the top of your website updatable via API

v1.1.3(1y ago)01.0kMITPHPPHP ^8.3CI passing

Since Jan 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/daikazu/welcome-bar)[ Packagist](https://packagist.org/packages/daikazu/welcome-bar)[ Docs](https://github.com/daikazu/welcome-bar)[ GitHub Sponsors](https://github.com/Daikazu)[ RSS](/packages/daikazu-welcome-bar/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (14)Versions (6)Used By (0)

Add a welcome bar to the top of your website updatable via API
==============================================================

[](#add-a-welcome-bar-to-the-top-of-your-website-updatable-via-api)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d3bdb43d45884ced031cd139ac2da797e20db48ce32850fd534a7d046d47f4a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461696b617a752f77656c636f6d652d6261722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/daikazu/welcome-bar)[![GitHub Tests Action Status](https://camo.githubusercontent.com/cb02185ce9dab4bfbaba3c81b00aeebc35b2603c544abfb1a62f112b324d4da0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6461696b617a752f77656c636f6d652d6261722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/daikazu/welcome-bar/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/9cd8fc4b685ba3b4ab7b10a7f2d23d3fc51121056db684bfb8b8e4e2362147ad/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6461696b617a752f77656c636f6d652d6261722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/daikazu/welcome-bar/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/6c145f626258843a2488783b64a86e17ba131303b9aeb08431ea87c4fcff9627/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6461696b617a752f77656c636f6d652d6261722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/daikazu/welcome-bar)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require daikazu/welcome-bar
```

You can publish the config file with:

```
php artisan vendor:publish --tag="welcome-bar-config"
```

This is the contents of the published config file:

```
return [
    /*
      |--------------------------------------------------------------------------
      | Storage Path
      |--------------------------------------------------------------------------
      */
    'storage_path' => storage_path('app/welcome-bar.json'),

    /*
    |--------------------------------------------------------------------------
    | Route Middlewares or Security
    |--------------------------------------------------------------------------
    |
    | For example, you could specify a route middleware group here that your
    | "update" route uses for authentication or token checking.
    |
    */
    'middleware' => [
        'update' => ['api'], // Or anything your app uses, e.g. 'auth:api', or a custom 'welcome-bar-auth'
        'fetch'  => ['web'], // Or 'api'
    ],
];
```

Optionally, you can publish the views using

```
php artisan vendor:publish --tag="welcome-bar-views"
```

Usage
-----

[](#usage)

Add this to your layout file (e.g., `resources/views/layouts/app.blade.php`) after the opening body tag:

```

```

or alternatively you can use the blade directive

```
 @include('welcome-bar::welcome-bar')
```

Schedule the cleanup command to run in your console routes file

```
Schedule::command('welcome-bar:prune')->daily();
```

Data Structure
--------------

[](#data-structure)

This package uses a JSON array of “message objects” to display one or more stacked bars at the top of your webpage. The order of the array determines the vertical stacking order: the first element in the array appears at the very top, the second beneath it, and so on.

```
[
    {
        "message": "Random Message 1",
        "cta": {
            "label": "More info",
            "url": "http://google.com",
            "target": "_blank"
        },
        "schedule": {
            "start": "2025-01-01T00:00:00",
            "end": "2025-01-05T23:59:59"
        },
        "behavior": {
            "closable": true,
            "autoHide": false,
            "autoHideDelay": 5000
        },
        "theme": {
            "variant": "prominent",
            "background": "#0099ff",
            "text": "#ffffff",
            "button": {
                "background": "#ffffff",
                "text": "#82ff38",
                "contrastStrategy": "auto"
            }
        }
    },
    {
        "message": "Random Message 2",
        "cta": {
            "label": "Another link",
            "url": "https://example.com",
            "target": "_self"
        },
        "schedule": {
            "start": "2025-01-02T00:00:00",
            "end": "2025-02-01T23:59:59"
        },
        "behavior": {
            "closable": false,
            "autoHide": true,
            "autoHideDelay": 10000
        },
        "theme": {
            "variant": "subtle",
            "background": "#0066cc",
            "text": "#ffffff",
            "button": {
                "background": "#ffffff",
                "text": "#000000",
                "contrastStrategy": "manual"
            }
        }
    }
]
```

**Field Explanations**

**message**

• **Type:** string

• **Description:** The main text shown on the bar. This is **required**.

**cta**

• **Type:** object (optional fields)

• **label** (string): The text on the button.

• **url** (string): The link destination.

• **target** (string): \_blank or \_self. Defaults to \_self if omitted.

If cta.label and cta.url are both provided, a button will appear.

**schedule**

• **Type:** object

• **start** (string, ISO datetime): When this message first becomes visible.

• **end** (string, ISO datetime): When this message stops being visible.

Messages are only displayed **while** the current date/time falls between start and end. If you omit these fields, the message is always considered valid.

**behavior**

• **Type:** object

• **closable** (boolean): Whether to show a close (×) button.

• **autoHide** (boolean): Whether the bar should automatically hide itself after some time.

• **autoHideDelay** (number): The duration in milliseconds (e.g., 5000 = 5 seconds) before the bar hides if autoHide is true.

**theme**

• **Type:** object

• **variant** (string): Arbitrary descriptor for the style theme (e.g., "prominent", "subtle").

• **background** (string): Hex code for the bar’s background color.

• **text** (string): Hex code for the bar’s text color.

• **button** (object): Further styles for the CTA button.

• **background** (string): Button background color.

• **text** (string): Button text color.

• **contrastStrategy** (string, "auto" or "manual"):

• If "auto", the bar can compute the best contrasting text color based on background.

• If "manual", the text color is taken as-is from text.

**How to Update the Data**

You can **update** this JSON array via:

• **A POST request** to your application’s update route (e.g. POST /welcome-bar/update), or

• **Directly saving** a JSON file in the configured temporary storage location (depending on your setup).

**How Data is Rendered**

Each entry in the array is displayed as a stacked bar at the top of the page, in the order provided. The package checks:

1. **Is** now() **between** schedule.start **and** schedule.end\*\*?\*\*
2. **Is the data valid?** (e.g., do we have a message?)

If valid, the bar is rendered with the specified colors, CTA button, and behavior rules.

**Tip:** If you want to hide all existing bars, simply remove (or empty) this JSON array.

API Routes
----------

[](#api-routes)

### Fetch Current Bar Data

[](#fetch-current-bar-data)

**Endpoint:** `GET /api/welcome-bar/data`

**Description:** Fetches the current welcome bar data.

**Middleware:** Uses the middleware specified in `welcome-bar.middleware.fetch`.

**Response:**

- **200 OK:** Returns the current welcome bar data in JSON format.

### Update Bar Data

[](#update-bar-data)

**Endpoint:** `POST /api/welcome-bar/update`

**Description:** Updates the welcome bar data from an external source.

**Middleware:** Uses the middleware specified in `welcome-bar.middleware.update`.

**Request Body:**

- **Content-Type:** `application/json`
- **Body:** JSON array of message objects.

**Response:**

- **200 OK:** Returns a success message.
- **400 Bad Request:** Returns an error message if the request is invalid.

### Ping

[](#ping)

**Endpoint:** `GET /api/welcome-bar/ping`

**Description:** Pings the site to check if the welcome bar is installed.

**Middleware:** Uses the middleware specified in `welcome-bar.middleware.fetch`.

**Response:**

- **200 OK:** Returns a success message indicating the welcome bar is installed.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Mike Wall](https://github.com/daikazu)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance45

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~13 days

Total

5

Last Release

433d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/00a5aa701f964455918b2e454e7b460fe2ef729639337a059d5bac12e162027e?d=identicon)[daikazu](/maintainers/daikazu)

---

Top Contributors

[![daikazu](https://avatars.githubusercontent.com/u/4039367?v=4)](https://github.com/daikazu "daikazu (19 commits)")

---

Tags

laraveldaikazuwelcome-bar

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/daikazu-welcome-bar/health.svg)

```
[![Health](https://phpackages.com/badges/daikazu-welcome-bar/health.svg)](https://phpackages.com/packages/daikazu-welcome-bar)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M626](/packages/spatie-laravel-data)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
