PHPackages                             axn/laravel-view-components - 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. [Templating &amp; Views](/categories/templating)
4. /
5. axn/laravel-view-components

AbandonedArchivedLibrary[Templating &amp; Views](/categories/templating)

axn/laravel-view-components
===========================

Provide a simple but effective view components system to Laravel.

1.3.0(7y ago)0181MITPHP

Since Jul 20Pushed 7y ago1 watchersCompare

[ Source](https://github.com/AXN-Informatique/laravel-view-components)[ Packagist](https://packagist.org/packages/axn/laravel-view-components)[ Docs](https://github.com/AXN-Informatique/laravel-view-components)[ RSS](/packages/axn-laravel-view-components/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

Laravel View Components
=======================

[](#laravel-view-components)

Provide a simple but effective view components system to Laravel, similar to [view composers](https://laravel.com/docs/5.6/views#view-composers)but in a different way : while a composer is called when the view is rendered, with view component, the view is rendered by the component itself. So, the logic is more tied to the view.

- [Installation](#installation)
- [Usage](#usage)

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

[](#installation)

With Composer:

```
composer require axn/laravel-view-components
```

In Laravel 5.5 the service provider is automatically included. In older versions of the framework, simply add this service provider to the array of providers in `config/app.php`:

```
// config/app.php

'provider' => [
    //...
    Axn\ViewComponents\ServiceProvider::class,
    //...
];
```

Usage
-----

[](#usage)

Create a class that extends `Axn\ViewComponents\ViewComponent` and write the logic of your component in the `compose()` method. The `compose()` method must return the view contents.

Example:

```
namespace App\ViewComponents;

use Axn\ViewComponents\ViewComponent;
use App\Models\User;
use LaravelCollective\FormFacade as Form;

class UsersSelect extends ViewComponent
{
    protected function compose()
    {
        $users = User::pluck('username', 'id');

        return Form::select('user_id', $users, null, [
            'class' => 'form-control'
        ]);
    }
}
```

Then use the `@render` directive to render the component in a view:

```

    {!! Form::label('user_id', 'Select a user:') !!}
    @render(App\ViewComponents\UsersSelect::class)

```

Or the `render()` helper to render the component elsewhere than in a view:

```
$content = render(App\ViewComponents\UsersSelect::class);
```

If you need to pass data to the component:

```

    {!! Form::label('user_id', 'Select a user:') !!}
    @render(App\ViewComponents\UsersSelect::class, [
        'selectedUser' => old('user_id', $currentUser->id)
    ])

```

```
$content = render(App\ViewComponents\UsersSelect::class, [
    'selectedUser' => old('user_id', $currentUser->id)
]);
```

And in the component:

```
//...

class UsersSelect extends ViewComponent
{
    protected function compose()
    {
        $users = User::pluck('username', 'id');

        // $this->selectedUser value comes from the parent view
        return Form::select('user_id', $users, $this->selectedUser, [
            'class' => 'form-control'
        ]);
    }
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~76 days

Total

4

Last Release

2622d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/121384f0b2f969c933a358bb40d5cf97c85558c328e9778cb9bb60f3c6302379?d=identicon)[axn](/maintainers/axn)

---

Top Contributors

[![lgtaxn](https://avatars.githubusercontent.com/u/23211553?v=4)](https://github.com/lgtaxn "lgtaxn (4 commits)")[![forxer](https://avatars.githubusercontent.com/u/407917?v=4)](https://github.com/forxer "forxer (2 commits)")

### Embed Badge

![Health badge](/badges/axn-laravel-view-components/health.svg)

```
[![Health](https://phpackages.com/badges/axn-laravel-view-components/health.svg)](https://phpackages.com/packages/axn-laravel-view-components)
```

###  Alternatives

[cagilo/cagilo

A set of open-source Blade components for the Laravel Framework

172996.5k](/packages/cagilo-cagilo)[orchid/blade-icons

An easy way inline SVG images in your Blade templates.

223.4M9](/packages/orchid-blade-icons)[wireui/heroicons

The Tailwind Heroicons for laravel blade by WireUI

43390.8k5](/packages/wireui-heroicons)[stillat/antlers-components

2656.0k1](/packages/stillat-antlers-components)[itstructure/laravel-grid-view

Grid view for laravel framework

2546.6k2](/packages/itstructure-laravel-grid-view)[ycs77/inertia-laravel-ssr-head

Simple SSR Head for Inertia Laravel

3211.5k](/packages/ycs77-inertia-laravel-ssr-head)

PHPackages © 2026

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