PHPackages                             salesrender/plugin-core - 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. salesrender/plugin-core

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

salesrender/plugin-core
=======================

SalesRender plugin core component

0.4.8(1y ago)01.2k16proprietaryPHPPHP &gt;=7.4.0

Since Dec 2Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/SalesRender/plugin-core)[ Packagist](https://packagist.org/packages/salesrender/plugin-core)[ RSS](/packages/salesrender-plugin-core/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (17)Versions (57)Used By (6)

Plugin Core
===========

[](#plugin-core)

> Base framework for all SalesRender plugins

Overview
--------

[](#overview)

`salesrender/plugin-core` is the foundational framework upon which every SalesRender plugin is built. It provides two application entry points:

- **Web Application** (Slim 4) -- handles all HTTP requests to the plugin (registration, settings, batch operations, file uploads, info, autocomplete, etc.)
- **Console Application** (Symfony Console) -- runs CLI tasks such as cron scheduling, batch queue processing, database management, translations, and special request dispatching.

The package establishes a standardized bootstrap configuration pattern so that every plugin, regardless of type (macros, logistic, chat, PBX, geocoder, etc.), follows the same initialization sequence and exposes a uniform HTTP/CLI interface to the SalesRender platform.

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

[](#installation)

```
composer require salesrender/plugin-core
```

**Requirements:**

- PHP &gt;= 7.4
- Extensions: `ext-json`

> **Note:** In practice, plugins do not depend on `plugin-core` directly. Instead, they depend on a type-specific core package (e.g. `salesrender/plugin-core-macros`, `salesrender/plugin-core-logistic`, `salesrender/plugin-core-chat`, `salesrender/plugin-core-pbx`) which itself depends on `plugin-core`. Those type-specific packages extend `WebAppFactory` and `ConsoleAppFactory` from this package with routes and commands specific to each plugin type.

Architecture
------------

[](#architecture)

### Two Application Types

[](#two-application-types)

ApplicationBase classFrameworkEntry pointWeb (HTTP)`WebAppFactory`Slim 4`public/index.php`Console (CLI)`ConsoleAppFactory`Symfony Console`console.php`Both factories extend the abstract `AppFactory`, which is responsible for:

1. Loading environment variables from the `.env` file (via `vlucas/phpdotenv`)
2. Validating required environment variables (`LV_PLUGIN_PHP_BINARY`, `LV_PLUGIN_DEBUG`, `LV_PLUGIN_QUEUE_LIMIT`, `LV_PLUGIN_SELF_URI`)
3. Including `bootstrap.php` from the project root -- the central configuration file for every plugin

### Namespace

[](#namespace)

All classes reside under the `SalesRender\Plugin\Core\` namespace:

```
SalesRender\Plugin\Core\
    Actions\             -- HTTP request handlers (ActionInterface implementations)
        Batch\           -- batch preparation, running, forms, options
        Settings\        -- settings read/write, access middleware
        Upload\          -- file upload handling
    Commands\            -- Symfony Console commands (CronCommand, MutexCommand)
    Components\          -- ErrorHandler
    Factories\           -- AppFactory, WebAppFactory, ConsoleAppFactory
    Helpers\             -- PathHelper (temp, public, upload directories)
    Middleware\           -- ProtectedMiddleware (JWT), LanguageMiddleware

```

Getting Started
---------------

[](#getting-started)

### Project Structure

[](#project-structure)

A typical SalesRender plugin has this directory layout:

```
my-plugin/
    bootstrap.php          # Plugin configuration (DB, translations, info, settings, batch, etc.)
    console.php            # CLI entry point
    .env                   # Environment variables
    cron.txt               # (optional) Additional cron tasks
    composer.json
    db/
        database.db        # SQLite database (auto-created)
    public/
        index.php          # Web entry point
        icon.png           # Plugin icon (128x128 px, transparent background, required)
        uploaded/          # Uploaded files directory
        output/            # Output files directory
    runtime/
        *.mutex            # Mutex lock files
    lang/                  # Translation files
    src/                   # Plugin source code
    vendor/

```

### Bootstrap Configuration

[](#bootstrap-configuration)

Every plugin must create a `bootstrap.php` file in the project root. This file is automatically included by `AppFactory` when either the web or console application starts. The bootstrap file configures all plugin components in a standardized sequence.

Here is the canonical template from `bootstrap.example.php`:

```
