Download the PHP package stacktrace/laravel-builder without Composer
On this page you can find all versions of the php package stacktrace/laravel-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stacktrace/laravel-builder
More information about stacktrace/laravel-builder
Files in stacktrace/laravel-builder
Package laravel-builder
Short Description Builder.io integration for Laravel.
License MIT
Informations about the package laravel-builder
Laravel Builder.io
Laravel package for Builder.io integration for rendering content on your own, instead of using Builder.io API and CDN.
While it is completely possible to leverage just Visual Editor of the Builder.io and render content without relying on Builder.io API, the functionality is limited. When using Builder.io API, they take care of targeting, localization and utilization of other features such as symbols, content data etc. When rendering content on your own, you have to take care of targeting, symbol resolution and content preparation for rendering.
This package helps a with retrieving content from Builder.io and storing it in the database for later rendering directly by just reading the database and not querying Builder.io API on each page render.
Features
- store Builder.io content in the database
- automatically update database content as soon as something changes in Builder.io, utilizing Builder.io global webhooks
- download image and video assets to Laravel Storage without need to use CDN
- Symbol support when retrieving content
Installation
To install the package, just run:
After installing, configure following environment variables:
Then on Builder.io side, you have to configure webhook. Open Space Settings and within Integrations section, click on "Edit" next to Global Webhooks. Register the following webhook:
Set the Authorization header value to the BUILDER_WEBHOOK_TOKEN
env variable.
Usage
Rendering pages
To render a page, first you have to prepare a controller. The package supports simple path targeting, so you can use single path target on your pages.
First, create controller for resolving content from current request:
Then in web.php
register this controller as fallback controller, since we want to dynamically render page based on path targeting:
In the Builder.io, set targeting of your page to something like urlPath is /test
. Provided that you do not have a route registered
on the /test
path, the fallback controller will engage, and Builder::resolvePageFromRequest
will search for a page on /test
path.
You can now render the content directly using Builder.io SDK like following:
Builder editor
To be able to edit pages, within Builder.io on your site, create separate controller for handling editor requests:
Register controller in web.php
:
Then render editor content using Builder.io SDK:
Note that we now we are using fetchOneEntry
to render content using Builder.io API. This is however necessary for editor to work.
Then in your model settings, use a dynamic editor URL. Enter the following URL:
The editor will now use your app instead of Builder.io preview page.
Localization
While localization is a premium feature in Builder.io, you can use simple field to store locale of your content. Just define a field in your model
settings named locale
. When receiving webhooks, the package looks for fields and if it finds a field named locale
, it will store it in local
column.
The Builder::resolveEditorFromRequest
will respect locale settings with following rules:
- first retrieve content where
locale
is matchingApp:getLocale()
- if the
locale
is not matchingApp::getLocale()
, the content wherelocale
matchesApp::getFallbackLocale()
is retrieved - if content fallback locale does not exist either, the content where
locale
is not set is retrieved
All versions of laravel-builder with dependencies
illuminate/contracts Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
illuminate/database Version ^10.0|^11.0