PHPackages                             haringsrob/laravel-page-builder - 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. haringsrob/laravel-page-builder

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

haringsrob/laravel-page-builder
===============================

A simple page builder with structured content

5461[2 issues](https://github.com/haringsrob/laravel-page-builder/issues)PHP

Since Jan 5Pushed 4y ago1 watchersCompare

[ Source](https://github.com/haringsrob/laravel-page-builder)[ Packagist](https://packagist.org/packages/haringsrob/laravel-page-builder)[ RSS](/packages/haringsrob-laravel-page-builder/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel Nova page builder
=========================

[](#laravel-nova-page-builder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/45bf92dcbddbb53e76ac7f4ed5380263869def79623f6fbbdaaea4bdb1222234/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686172696e6773726f622f6c61726176656c2d706167652d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haringsrob/laravel-page-builder)

Laravel page builder is a package for Laravel that allows you to easily construct pages using a code definition or in a custom [Laravel Nova](https://nova.laravel.com) field and Laravel Blade components.

I made this package as I like the idea of page builders, but I really dislike the idea of unstructured data or html stored in the database.

I want to have the ability to define components easily (blade) and stick with how I would make regular templates. In addition to that, I want to have the ability to modify the components I create when a visual change is needed, without needing to rebuild the page.

The contents of the page builder are stored in a structured json object.

The package provides a few example components, but components should still be added by your project.

**Disclaimer:** This package and its documentation is a prototype/under development, feel free to use it and provide feedback or pull requests to help improve it.

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

[](#installation)

You can install the package via composer:

```
composer require haringsrob/laravel-page-builder
```

And publish the migration (Only required if used together with Laravel Nova):

```
php artisan vendor:publish --provider="Haringsrob\LaravelPageBuilder\LaravelPageBuilderServiceProvider" --tag="migrations"
```

### Creating a component

[](#creating-a-component)

You can start by creating your component using the command line (provided by Laravel):

`php artisan make:component Footer`

```
namespace App\View\Components;

use Illuminate\Contracts\View\View;
use Illuminate\View\Component;

class Footer extends Component
{
    /**
     * @param \App\View\Components\ValueObjects\Link[] $links
     * @param string $facebookLink
     * @param string $instagramLink
     */
    public function __construct(
        public array $links,
        public ?string $facebookLink,
        public string $instagramLink
    ) {
    }

    public function render(): View
    {
        return view('components.footer', get_object_vars($this));
    }
}
```

#### Rendering the builder

[](#rendering-the-builder)

As the builder is simple in its form you can easily build a new page.

This can be put in your controllers and can also be dynamically constructed (Like the Nova field does).

```
$builder = new PageBuilderCollection(
    [
        new CenteredMenu(
            links: [
                new Link(href: route('bar'), label: __('Bar')),
                new Link(href: route('foo'), label: __('Foo')),
            ],
            actions: [
                new Button(href: '#beta-signup', label: __('Sign up for the beta')),
            ]
        ),
        new Footer(
            links: [
                new Link(href: route('bar'), label: __('Bar')),
                new Link(href: route('foo'), label: __('Foo')),
            ],
            facebookLink: null,
            instagramLink: '#'

        ),
    ]
);
return view('layout.app', ['content' => (new BuilderContent($builder))->render()]);
```

### Laravel Nova page builder component

[](#laravel-nova-page-builder-component)

A page builder component is an extension from a regular component.

In addition to a regular component, it also provides a form method that can be used to generate the form.

`php artisan make:component ExamplePageBuilderComponent`

After that, modify the component so that it extends a BuilderComponent:

```
