Skip to content

Placeholders

Placeholder provide necessary configuration for Email Builder frontend. If you are working with Laravel and have ran php artisan email-builder:install, you will see placeholders in data location specified in config file. Default is App\EmailBuilder\Placeholders namespace. Placeholders are grouped by group name.

Following are the some placeholders which you can customize further to your requirement.

Default Placeholders

  • BusinessInfoPlaceholders: This class provide information about the business.
php
<?php

namespace App\EmailBuilder\Placeholders;

class BusinessInfoPlaceholders extends BasePlaceholders
{
    public function placeholders(): array
    {
        return $this->data();
    }

    public function data(): array
    {
        return [
            'order' => 1,
            'visible' => true,
            'label' => 'Business Info Placeholders',
            'description' => 'Placeholders related to business identity, contact details, website, and social media links.',
            'userSelectable' => true,
            'group' => [
                'id' => 'businessInfo',
                'label' => 'Business Info',
            ],
            'items' => [
                '__BUSINESS_INDUSTRY__' => [
                    'label' => 'Industry',
                    'value' => 'Software',
                    'description' => 'The business sector or industry',
                ],
                '__BUSINESS_TYPE__' => [
                    'label' => 'Type',
                    'value' => 'Email Builder Web App',
                    'description' => 'The nature or category of the business',
                ],
                '__BUSINESS_INTRO__' => [
                    'label' => 'Intro',
                    'value' => 'Integrate drag and drop email builder to your web app.',
                    'description' => 'A brief introduction about the business',
                ],
                '__BUSINESS_LOGO_DARK__' => [
                    'label' => 'Logo Dark',
                    'value' => '<logo-dark-url>',
                    'description' => 'Main logo URL (use in front of light background)',
                ],
                '__BUSINESS_LOGO_LIGHT__' => [
                    'label' => 'Logo Light',
                    'value' => '<logo-light-url>',
                    'description' => 'Light version of the logo (for dark backgrounds)',
                ],
                '__BUSINESS_NAME__' => [
                    'label' => 'Name',
                    'value' => 'Email Builder',
                    'description' => 'Full name of the business',
                ],
                // '__BUSINESS_ADDRESS__' => [
                //     'label' => 'Address',
                //     'value' => '123 Some St., Toronto ON',
                //     'description' => 'Physical business address',
                // ],
                // '__BUSINESS_PHONE__' => [
                //     'label' => 'Phone',
                //     'value' => '11231231234',
                //     'description' => 'Customer service or main phone number',
                // ],
                // '__BUSINESS_PHONE_LINK__' => [
                //     'label' => 'Phone Link',
                //     'value' => '11231231234',
                //     'description' => 'Phone number formatted for tel: links',
                // ],
                '__BUSINESS_EMAIL__' => [
                    'label' => 'Email',
                    'value' => 'info@emailbuilder.dev',
                    'description' => 'Support or contact email address',
                ],
                '__BUSINESS_WEBSITE__' => [
                    'label' => 'Website Url',
                    'value' => 'https://emailbuilder.dev',
                    'description' => 'Official website URL',
                ],
                // '__BUSINESS_GOOGLE_MAP_URL__' => [
                //     'label' => 'Google Map Link',
                //     'value' => 'https://www.google.com/maps/@43.6425662,-79.3870568,17z',
                //     'description' => 'Link to the business on Google Maps',
                // ],
                '__BUSINESS_PRIVACY_POLICY_URL__' => [
                    'label' => 'Privacy Policy Link',
                    'value' => '<privacy-page-url>',
                    'description' => 'Link to the business\'s privacy policy page',
                ],
                '__BUSINESS_TERMS_OF_USE_URL__' => [
                    'label' => 'Terms Of Use Link',
                    'value' => '<terms-and-condition-page-url>',
                    'description' => 'Link to the terms of use page',
                ],
                '__BUSINESS_SOCIAL_MEDIA_YOUTUBE_URL__' => [
                    'label' => 'Youtube Link',
                    'value' => '<youtube-url>',
                    'description' => 'Social media Youtube URL',
                ],
                '__BUSINESS_SOCIAL_MEDIA_YOUTUBE_ICON__' => [
                    'label' => 'Youtube Icon',
                    'value' => 'default',
                    'description' => 'Social media Youtube icon image',
                ],
                '__BUSINESS_SOCIAL_MEDIA_X_URL__' => [
                    'label' => 'X Link',
                    'value' => '<x-url>',
                    'description' => 'Social media X URL',
                ],
                '__BUSINESS_SOCIAL_MEDIA_X_ICON__' => [
                    'label' => 'X Icon',
                    'value' => 'default',
                    'description' => 'Social media X icon image',
                ],
                '__BUSINESS_FOOTER_COPYRIGHT_TEXT__' => [
                    'label' => 'Footer Copyright',
                    'value' => '© (:year:) Apsonex Inc. All Rights Reserved.',
                    'description' => 'Business copyright notice text',
                ]
            ],
        ];
    }
}
  • UserPlaceholders: User information placeholders. User will be available through $user variable.
php
<?php
namespace App\EmailBuilder\Placeholders;

use App\EmailBuilder\Enums\EmailBuilderContextKey;

class UserPlaceholders extends BasePlaceholders
{
    protected $user = null;

    public function onContext(): void
    {
        $this->user = $this->context[EmailBuilderContextKey::User->value] ?? null;
    }

    public function placeholders(): array
    {
        return $this->data();
    }

    public function data(): array
    {
        return [
            'order' => 2,
            'addToPrompt' => true,
            'visible' => true,
            'label' => 'User Placeholders',
            'description' => 'Placeholders related to a User entity.',
            'userSelectable' => true,
            'group' => [
                'id' => 'user',
                'label' => 'User',
            ],
            'items' => [
                '__USER_NAME__' => [
                    'label' => 'User Name',
                    'value' => $this->user?->name ?: '__USER_NAME__',
                    'description' => 'The full name of the user (potential customer).',
                ],
                '__USER_EMAIL__' => [
                    'label' => 'User Email',
                    'value' => $this->user?->email ?: '__USER_EMAIL__',
                    'description' => 'The email address associated with the user.',
                ],
                '__USER_EMAIL_VERIFY_LINK__' => [
                    'label' => 'Email Verify Link',
                    'value' => $this->user && method_exists($this->user, 'emailVerifyLink') ? $this->user->emailVerifyLink  () : '__USER_EMAIL_VERIFY_LINK__',
                    'description' => 'Link to verify new user email address',
                ],
                '__USER_UNSUBSCRIBE_LINK__' => [
                    'label' => 'Unsubscribe Link',
                    'value' => $this->user && method_exists($this->user, 'unsubscribeLink') ? $this->user->unsubscribeLink() : '__USER_UNSUBSCRIBE_LINK__',
                    'description' => 'Link to unsubscribe from newsletter or other email services',
                ]
            ],
        ];
    }
}
  • StylePlaceholders: Your business / website brand or style information.
php
<?php
namespace App\EmailBuilder\Placeholders;

class StylePlaceholders extends BasePlaceholders
{
    public function placeholders(): array
    {
        return $this->data();
    }

    public function data(): array
    {
        return [
            'order'          => 3,
            'visible'        => true,
            'label'          => 'Style Placeholders',
            'description'    => 'Design-related style placeholders including brand colors, button styles, and text formatting used throughout the email.',
            'userSelectable' => false,
            'group'          => [
                'id'    => 'styles',
                'label' => 'Style',
            ],
            'items'          => [
                '__STYLE_LOGO_WIDTH__'                 => [
                    'label'       => 'Logo width style',
                    'value'       => '170px',
                    'description' => 'Width of the logo (in px only)',
                ],
                '__STYLE_TEXT_COLOR__'                 => [
                    'label'       => 'Text color style',
                    'value'       => '#1e293b',
                    'description' => 'Default text color used in the design',
                ],
                '__STYLE_LINK_COLOR__'                 => [
                    'label'       => 'Link color style',
                    'value'       => '#f43f5e',
                    'description' => 'Color applied to hyperlinks',
                ],
                '__STYLE_PRIMARY_BRAND_COLOR__'        => [
                    'label'       => 'Primary brand color style',
                    'value'       => '#f43f5e',
                    'description' => 'Main branding color (primary)',
                ],
                '__STYLE_PRIMARY_BRAND_COLOR_ALT__'    => [
                    'label'       => 'Primary brand color alt style',
                    'value'       => '#ffffff',
                    'description' => 'Alternate or lighter shade of the primary color',
                ],
                '__STYLE_SECONDARY_BRAND_COLOR__'      => [
                    'label'       => 'Secondary brand color style',
                    'value'       => '#1e293b',
                    'description' => 'Secondary branding color',
                ],
                '__STYLE_SECONDARY_BRAND_COLOR_ALT__'  => [
                    'label'       => 'Secondary brand color alt style',
                    'value'       => '#ffffff',
                    'description' => 'Alternate or lighter shade of the secondary color',
                ],
                '__STYLE_BTN_PRIMARY_BG_COLOR__'       => [
                    'label'       => 'Btn primary bg color style',
                    'value'       => '#f43f5e',
                    'description' => 'Background color of primary buttons',
                ],
                '__STYLE_BTN_PRIMARY_BG_COLOR_ALT__'   => [
                    'label'       => 'Btn primary bg color alt style',
                    'value'       => '#ffffff',
                    'description' => 'Hover or alternate color for primary buttons',
                ],
                '__STYLE_BTN_SECONDARY_BG_COLOR__'     => [
                    'label'       => 'Btn secondary bg color style',
                    'value'       => '#1e293b',
                    'description' => 'Background color of secondary buttons',
                ],
                '__STYLE_BTN_SECONDARY_BG_COLOR_ALT__' => [
                    'label'       => 'Btn secondary bg color alt style',
                    'value'       => '#ffffff',
                    'description' => 'Hover or alternate color for secondary buttons',
                ],
            ],
        ];
    }
}
  • SystemPlaceholders: System placeholders provide system wide config options.
php
<?php

namespace App\EmailBuilder\Placeholders;

class SystemPlaceholders extends BasePlaceholders
{
    public function placeholders(): array
    {
        return $this->data();
    }

    public function data(): array
    {
        return [
            'order'          => 4,
            'visible'        => true,
            'label'          => 'System Placeholders',
            'description'    => 'Automatically generated placeholders based on the system context, such as date and time.',
            'userSelectable' => true,
            'group'          => [
                'id'    => 'system',
                'label' => 'System',
            ],
            'items'          => [
                '__CURRENT_DATE_TIME__' => [
                    'label'           => 'Current date time',
                    'value' => now($this->context['tz'] ?? null)->toDayDateTimeString(),
                    'description'     => 'Current date with time.',
                ],
                '__CURRENT_YEAR__'      => [
                    'label'       => 'Current year',
                    'value' => now($this->context['tz'] ?? null)->format('Y'),
                    'description' => 'Current Year.',
                ],
            ],
        ];
    }
}
  • TypographyPlaceholders: Customize typography to represent your brand.
php
<?php
namespace App\EmailBuilder\Placeholders;

class TypographyPlaceholders extends BasePlaceholders
{
    public function placeholders(): array
    {
        return $this->data();
    }

    public function data(): array
    {
        /**
         * You can choose any scale. Some of the standard modular (typographic) scales are as follows:
         *
         * - 1.067  (Minor Second)         – Subtle, very tight spacing between steps.
         * - 1.125  (Major Second)         – Slightly larger, still compact and balanced.
         * - 1.200  (Minor Third)          – Common in modern, readable layouts.
         * - 1.250  (Major Third)          – Balanced and versatile; works well for body → heading hierarchies.
         * - 1.333  (Perfect Fourth)       – Classic book and web typography scale.
         * - 1.414  (Augmented Fourth)     – Also known as the "square root of 2" scale; geometric and pleasing.
         * - 1.500  (Perfect Fifth)        – Dramatic but still harmonious for strong visual hierarchy.
         * - 1.618  (Golden Ratio)         – Natural and elegant; large jumps between sizes.
         * - 1.667  (Minor Sixth)          – Bolder hierarchy, good for artistic designs.
         * - 1.778  (Major Sixth)          – Very bold and expressive.
         * - 2.000  (Octave)               – Doubles each step; often used for strong contrast or display typography.
         *
         * Reference: https://type-scale.com/
         */
        $scale        = 1.125;
        $baseFontSize = 14;
        $sizes        = [];
        $lineHeights  = [];
        $current      = $baseFontSize;

        for ($i = 0; $i < 6; $i++) {
            $fontSize      = round($current);
            $lineHeight    = round(($fontSize * (1.2 + $i * 0.05)) / $fontSize, 2);
            $sizes[]       = $fontSize;
            $lineHeights[] = $lineHeight;
            $current *= $scale;
        }

        return [
            'order'          => 5,
            'visible'        => true,
            'label'          => 'Typography Placeholders',
            'description'    => 'Typography-related placeholders used to control font sizes, line heights, families, and weights across headings and body text.',
            'userSelectable' => false,
            'group'          => [
                'id'    => 'typography',
                'label' => 'Typography',
            ],
            'items'          => [
                // Body
                '__TYPO_BODY_FONT_SIZE__'         => [
                    'label'       => 'Typo body font size',
                    'description' => 'Typo body font size',
                    'value'       => $baseFontSize . 'px',
                ],
                // Heading Font Sizes
                '__TYPO_HEADING_FONT_SIZE_H1__'   => [
                    'label'       => 'Typo heading font size h1',
                    'description' => 'Typo heading font size h1',
                    'value'       => $sizes[5] . 'px',
                ],
                '__TYPO_HEADING_FONT_SIZE_H2__'   => [
                    'label'       => 'Typo heading font size h2',
                    'description' => 'Typo heading font size h2',
                    'value'       => $sizes[4] . 'px',
                ],
                '__TYPO_HEADING_FONT_SIZE_H3__'   => [
                    'label'       => 'Typo heading font size h3',
                    'description' => 'Typo heading font size h3',
                    'value'       => $sizes[3] . 'px',
                ],
                '__TYPO_HEADING_FONT_SIZE_H4__'   => [
                    'label'       => 'Typo heading font size h4',
                    'description' => 'Typo heading font size h4',
                    'value'       => $sizes[2] . 'px',
                ],
                '__TYPO_HEADING_FONT_SIZE_H5__'   => [
                    'label'       => 'Typo heading font size h5',
                    'description' => 'Typo heading font size h5',
                    'value'       => $sizes[1] . 'px',
                ],
                '__TYPO_HEADING_FONT_SIZE_H6__'   => [
                    'label'       => 'Typo heading font size h6',
                    'description' => 'Typo heading font size h6',
                    'value'       => $sizes[0] . 'px',
                ],
                // line-heights
                '__TYPO_BODY_LINE_HEIGHT__'       => [
                    'label'       => 'Typo body line height',
                    'description' => 'Typo body line height',
                    'value'       => round((float) $lineHeights[1], 3),
                ],
                '__TYPO_HEADING_LINE_HEIGHT_H1__' => [
                    'label'       => 'Typo heading line height h1',
                    'description' => 'Typo heading line height h1',
                    'value'       => round((float) $lineHeights[5], 3),
                ],
                '__TYPO_HEADING_LINE_HEIGHT_H2__' => [
                    'label'       => 'Typo heading line height h2',
                    'description' => 'Typo heading line height h2',
                    'value'       => round((float) $lineHeights[4], 3),
                ],
                '__TYPO_HEADING_LINE_HEIGHT_H3__' => [
                    'label'       => 'Typo heading line height h3',
                    'description' => 'Typo heading line height h3',
                    'value'       => round((float) $lineHeights[3], 3),
                ],
                '__TYPO_HEADING_LINE_HEIGHT_H4__' => [
                    'label'       => 'Typo heading line height h4',
                    'description' => 'Typo heading line height h4',
                    'value'       => round((float) $lineHeights[2], 3),
                ],
                '__TYPO_HEADING_LINE_HEIGHT_H5__' => [
                    'label'       => 'Typo heading line height h5',
                    'description' => 'Typo heading line height h5',
                    'value'       => round((float) $lineHeights[1], 3),
                ],
                '__TYPO_HEADING_LINE_HEIGHT_H6__' => [
                    'label'       => 'Typo heading line height h6',
                    'description' => 'Typo heading line height h6',
                    'value'       => round((float) $lineHeights[0], 3),
                ],
                // font-family
                '__TYPO_HEADING_FONT_FAMILY__'    => [
                    'label'       => 'Typo heading font family',
                    'description' => 'Typo heading font family',
                    'value'       => 'poppins',
                ],
                '__TYPO_BODY_FONT_FAMILY__'       => [
                    'label'       => 'Typo body font family',
                    'description' => 'Typo body font family',
                    'value'       => 'open-sans',
                ],
                // font-weight
                '__TYPO_BODY_FONT_WEIGHT__'       => [
                    'label'       => 'Typo body font weight',
                    'description' => 'Typo body font weight',
                    'value'       => '400',
                ],
                '__TYPO_HEADING_FONT_WEIGHT__'    => [
                    'label'       => 'Typo heading font weight',
                    'description' => 'Typo heading font weight',
                    'value'       => '700',
                ],
                '__FONT_FAMILY_TYPE_POPPINS__'    => [
                    'label'       => 'Font family',
                    'description' => 'Font family',
                    'value'       => [
                        "key"       => "poppins",
                        "provider"  => "bunny",
                        "category"  => "sans-serif",
                        "family"    => "Poppins",
                        "urlString" => "poppins:100,200,300,400,500,600,700,800,900,100i,200i,300i,400i,500i,600i,700i,800i,900i",
                    ],
                ],
                '__FONT_FAMILY_TYPE_OPEN_SANS__'  => [
                    'label'       => 'Font family',
                    'description' => 'Font family',
                    'value'       => [
                        "key"       => "open-sans",
                        "provider"  => "bunny",
                        "category"  => "sans-serif",
                        "family"    => "Open Sans",
                        "urlString" => "open-sans:300,400,500,600,700,800,300i,400i,500i,600i,700i,800i",
                    ],
                ],
            ],
        ];
    }
}

Generate Placeholder

You can add more placeholder as needed. Simple run php artisan email-builder:placeholder-scaffold and it will guide you to add placeholder.

sh
php artisan email-builder:placeholder-scaffold

Default Placeholder Casts

Placeholder casts is useful when you want to replace content inside email programmatically. Cast can be defined in data directory defined in config. Default location for placeholder casts is App\EmailBuilder\PlaceholderCasts.

Following are the default casts comes with package.

  • :date: Date cast will insert current date into the email.
php
<?php

namespace App\EmailBuilder\PlaceholderCasts;

use Carbon\Carbon;
use Apsonex\EmailBuilderPhp\EmailBuilderPHP;
use Apsonex\EmailBuilderPhp\Contracts\PlaceholderCastContract;

class Date implements PlaceholderCastContract
{
    public function key(): string
    {
        return ':date:';
    }

    public function handle(string $value, EmailBuilderPHP $builder, array $props = [])
    {
        $now = Carbon::now($props['tz'] ?? null);
        return $now->format($props['php-format'] ?? 'M d, Y');
    }
}
  • :year: Year cast will insert current year into the email.
php
<?php

namespace App\EmailBuilder\PlaceholderCasts;

use Carbon\Carbon;
use Apsonex\EmailBuilderPhp\EmailBuilderPHP;
use Apsonex\EmailBuilderPhp\Contracts\PlaceholderCastContract;

class Year implements PlaceholderCastContract
{
    public function key(): string
    {
        return ':year:';
    }

    public function handle(string $value, EmailBuilderPHP $builder, array $props = [])
    {
        $now = Carbon::now($props['tz'] ?? null);
        return $now->format('Y');
    }
}

Generate Placeholder Cast

You can scaffold new placeholder cast by running php artisan email-builder:placeholder-cast-scaffold command.

sh
php artisan email-builder:placeholder-cast-scaffold