PHPackages                             jacksleight/laravel-omni - 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. [API Development](/categories/api)
4. /
5. jacksleight/laravel-omni

ActiveLibrary[API Development](/categories/api)

jacksleight/laravel-omni
========================

168PHP

Since Aug 3Pushed 9mo agoCompare

[ Source](https://github.com/jacksleight/laravel-omni)[ Packagist](https://packagist.org/packages/jacksleight/laravel-omni)[ RSS](/packages/jacksleight-laravel-omni/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Omni
====

[](#omni)

Omni is a Laravel package and Vite plugin for building universal Blade and Livewire components.

Note

I'm rewriting this for Livewire 4! ⚡️🥳

Warning

This is an experiment and could change. See known [differences](#known-differences) and [issues](#known-issues).

The core goals of Omni are:

- A single type of view, everything’s a component
- A single API for defining all components
- A single syntax for including all components
- A single directory structure for all components
- A single file for all component concerns (logic, template, bundled styles and scripts)

All Omni components can:

- Be standard Blade or Livewire components
- Be mounted to a route as a full-page component
- Be rendered from a controller
- Be rendered in a template using `x-` syntax
- Pull layouts into their templates
- Include styles and scripts that are bundled by Vite
- Extend other Omni components
- Use other Omni trait components
- Live in any view directory

This package will happily work alongside all normal views/components, it doesn't interfere with anything that's not an Omni component.

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

[](#installation)

Install the package via Composer:

```
composer require jacksleight/laravel-omni:dev-main
```

Creating Components
-------------------

[](#creating-components)

You can create Omni components manually or using the `make:omni` command.

### Manual Creation

[](#manual-creation)

To create an Omni component manually, simply create a new view file anywhere in the views directory. They look like this:

```
@omni(class
{
    public int $count = 0;
})

    {{ $count }}

    /* ... */

    /* ... */

```

Or for a Livewire component with a layout:

```
@omni(class
{
    public int $count = 0;

    public function increment()
    {
        $this->count++;
    }
})

    @wire

            {{ $count }}
            +

    @endwire

```

Omni also supports array syntax just like the `@props` directive:

```
@omni([
    'count' => 0,
])

    {{ $count }}

```

### Using the Make Command

[](#using-the-make-command)

You can also create a new Omni component using the `make:omni` Artisan command:

```
php artisan make:omni
php artisan make:omni counter
php artisan make:omni counter --wire
```

### Lifecycle

[](#lifecycle)

Livewire components are handled by Livewire and run through the usual [lifecycle](https://livewire.laravel.com/docs/lifecycle-hooks), standard components support `mount` and `rendering` lifecycle hooks:

```
public function mount($value)
{
    // ...
}

public function rendering($view)
{
    // ...
}
```

### With

[](#with)

To pass additional variables to the template use the `with` method:

```
protected function with()
{
    return [
        // ...
    ];
}
```

Extending Components
--------------------

[](#extending-components)

You can extend components just like any other class, and include their templates using the `@omni` directive.

```
@omni(class extends Button
{
    public $variant = 'primary';
})

@mount('#parent')
```

Trait Components
----------------

[](#trait-components)

You can define components as traits and include their templates using the `@omni` directive. This is useful if you need reusable component parts with the logic and template bundled together, or just want to break a large Livewire component up into more manageable chunks without actually mounting multiple separate components.

```
@omni(trait
{
    public function saveContact()
    {
        // ...
    }
})

@wire

        ...
        Save

@endwire
```

```
@omni(class
{
    use Contact;
    use Notifications;
    use Preferences;
})

@wire

        @mount('#contact')
        @mount('#notifications')
        @mount('#preferences')

@endwire
```

Rendering Components
--------------------

[](#rendering-components)

### Blade Templates

[](#blade-templates)

To render a component in a Blade template use the `x-` syntax or `@mount` directive:

```

    Content

@mount('counter', ['count' => 4])
```

### Controllers

[](#controllers)

To render a component from a controller action use the `mount` view macro:

```
use App\Omni\Counter;
use JackSleight\LaravelOmni\Omni;

return view()->mount('counter', ['count' => 4]);
return view()->mount(Counter::class, ['count' => 4]);
```

### Routes

[](#routes)

To mount a component to a route use the class directly:

```
use App\Omni\Counter;

Route::get('counter/{count}', Counter::class);
```

You can also mount a component and then call one of it's actions directly from a route:

```
use App\Omni\Auth\Logout;

Route::post('logout', [Logout::class, 'logout']);
```

Component Modes
---------------

[](#component-modes)

Omni components run in one of three modes depending on the template structure.

- **Standard Mode**
    Components that don't use the `@wire` directive run in standard mode. They support `mount` and `rendering` lifecycle hooks.
- **Livewire Mode**
    Components that use the `@wire` directive and have no code outside of it run in Livewire mode. They are handled by Livewire and through the usual [lifecycle](https://livewire.laravel.com/docs/lifecycle-hooks).
- **Combined Mode**
    Components that use the `@wire` directive and have code outside of it run in combined mode. Combined components are actually two instances of the same component. The part of the template outside the `@wire` directive runs in standard mode, and then the part of the template inside the `@wire` directive runs in Livewire mode.

Bundling Scripts &amp; Styles
-----------------------------

[](#bundling-scripts--styles)

Any Omni `` and `` blocks will be excluded from the templates and can instead be included in your JS and CSS bundles using the provided Vite plugin. To set that up add the Omni package as a dependency in `package.json`:

```
{
    "dependencies": {
        "omni": "file:./vendor/jacksleight/laravel-omni"
    }
}
```

Then add the plugin in `vite.config.js`:

```
import omni from 'omni/plugins/vite';

export default defineConfig({
    plugins: [
        omni({ views: [
            __dirname + '/resources/views',
        ] }),
    ],
});
```

And finally import the Omni scripts and styles into your `app.js` and `app.css` files:

```
import 'omni/scripts';
```

```
@import 'omni/styles';
```

Differences &amp; Issues
------------------------

[](#differences--issues)

### Known Differences

[](#known-differences)

These are intentional differences in the way Omni components behave compared to normal Blade or Livewire components.

- Individual attributes are not set as variables in the template scope.
- Conditionally rendering components by implementing `shouldRender` is not supported.

### Known Issues

[](#known-issues)

- None?

### Unknown Differences &amp; Issues

[](#unknown-differences--issues)

- Almost definitely.

Troubleshooting
---------------

[](#troubleshooting)

- **Error:** `Using $this when not in object context`
    You may be trying to use a computed Livewire property in a standard mode render.
- **Error:** `Property [$...] not found on component`
    You may be trying to use a computed Livewire property in a standard mode lifecycle hook. Use `$this->getId()` to check whether the component is running in Livewire mode (standard mode will have no ID).

Credits
-------

[](#credits)

While Omni does not depend on [Livewire Volt](https://github.com/livewire/volt) and doesn't support any of its functional syntax, it is obviously heavily inspired by Volt's single-file approach. This package would not exist if it wasn't for Volt, so a huge thanks to the Volt team. ❤️

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance41

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b1acb404d9801e5f633e31efa3403a4735e43ea93c798e3f895ba3264c92c6e?d=identicon)[jacksleight](/maintainers/jacksleight)

---

Top Contributors

[![jacksleight](https://avatars.githubusercontent.com/u/126740?v=4)](https://github.com/jacksleight "jacksleight (129 commits)")

### Embed Badge

![Health badge](/badges/jacksleight-laravel-omni/health.svg)

```
[![Health](https://phpackages.com/badges/jacksleight-laravel-omni/health.svg)](https://phpackages.com/packages/jacksleight-laravel-omni)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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