Download the PHP package salesrender/plugin-core-macros without Composer

On this page you can find all versions of the php package salesrender/plugin-core-macros. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package plugin-core-macros

Plugin Core Macros

Type-specific core framework for SalesRender macros plugins

Overview

salesrender/plugin-core-macros is the core package for building MACROS type plugins on the SalesRender platform. Macros plugins perform bulk operations on orders -- they process orders in batches, enabling mass data export, import, field manipulation, status changes, and other automated workflows.

The key distinction of macros plugins from other types is batch processing: the ability to iterate over a set of orders (defined by filters, sort, and pagination) and apply operations to each one, tracking progress, errors, and results.

This package extends the base salesrender/plugin-core by:

Installation

Requirements:

Dependencies:

Architecture

How This Core Extends plugin-core

plugin-core-macros provides two factory classes in the SalesRender\Plugin\Core\Macros\Factories namespace:

WebAppFactory

The macros WebAppFactory automatically adds two feature sets before building:

  1. CORS support (addCors()) -- enables cross-origin requests for all routes
  2. Batch actions (addBatchActions()) -- registers all batch-related HTTP routes

The addBatchActions() method (defined in the parent WebAppFactory) registers the following routes:

Method Path Action Description
POST /protected/batch/prepare BatchPrepareAction Creates a new batch with filters, sort, and arguments
GET /protected/forms/batch/{number} GetBatchFormAction Returns batch step form (1-10)
PUT /protected/data/batch/{number} PutBatchOptionsAction Saves batch step options
POST /protected/batch/run BatchRunAction Starts batch execution
GET /process ProcessAction Returns batch process status
GET /protected/autocomplete/{name} AutocompleteAction Autocomplete suggestions
GET /protected/preview/table/{name} TablePreviewAction Table preview data
GET /protected/preview/markdown/{name} MarkdownPreviewAction Markdown preview

ConsoleAppFactory

The macros ConsoleAppFactory adds batch processing commands via addBatchCommands():

Command Class Description
batch:queue BatchQueueCommand Picks up queued batches and spawns handler processes
batch:handle BatchHandleCommand Executes the batch handler for a specific batch

These commands are also automatically registered as cron tasks (every minute) by the base ConsoleAppFactory when a BatchContainer handler is configured.

Batch Processing Flow

The batch processing lifecycle in a macros plugin follows these steps:

What the Developer Must Implement

  1. BatchHandlerInterface -- the core processing logic that iterates over orders and performs operations
  2. Settings Form -- a class extending Form for plugin configuration
  3. Batch Option Forms -- one or more Form classes for batch step configuration (up to 10 steps)
  4. bootstrap.php -- configuration file wiring everything together

Getting Started: Creating a Macros Plugin

Step 1: Project Setup

Set up PSR-4 autoloading in composer.json:

Create the project directory structure:

Step 2: Bootstrap Configuration

Create bootstrap.php in the project root:

Key points:

Step 3: Implement BatchHandlerInterface

Create src/Components/MyHandler.php:

The BatchHandlerInterface has a single method:

Process lifecycle methods:

Method Description
$process->initialize(?int $count) Set total order count (null for unknown). Transitions state to STATE_PROCESSING
$process->handle() Increment the handled counter
$process->skip() Increment the skipped counter
$process->addError(Error $error) Record an error (increments failed counter, stores last 20 errors)
$process->setState(string $state) Set process state (STATE_PROCESSING, STATE_POST_PROCESSING)
$process->finish($value) Mark as complete. true = success, false = error, string = result URL
$process->terminate(Error $error) Terminate with a fatal error
$process->save() Persist current state to database

Process states: STATE_SCHEDULED -> STATE_PROCESSING -> STATE_POST_PROCESSING -> STATE_ENDED

Batch provides:

Method Description
$batch->getApiClient() Returns the API client for querying SalesRender
$batch->getFsp() Returns Filters, Sort, Pagination configuration
$batch->getOptions(int $number) Returns form data for batch step N

Step 4: Create the Web Entry Point

Create public/index.php:

Note: Unlike integration plugins, macros plugins typically do not need to add custom routes. The WebAppFactory automatically registers all necessary batch routes.

Step 5: Create the Console Entry Point

Create console.php:

Step 6: Create the Settings Form

Create src/Forms/SettingsForm.php:

Step 7: Create Batch Options Form

Create src/Forms/BatchOptionsForm.php:

Batch option forms are displayed before running the batch (steps 1-10). Return null from the BatchContainer::config callable for steps that do not require configuration.

Step 8: Create the .env File

Create .env:

Step 9: Initialize and Deploy

The cron system is essential for macros plugins because batch processing runs asynchronously via the batch:queue and batch:handle commands, which are automatically scheduled every minute.

HTTP Routes

Routes Added by Macros WebAppFactory

These routes are added by the macros WebAppFactory in addition to the base plugin-core routes:

Method Path Auth Description
POST /protected/batch/prepare JWT Create a new batch with FSP. Returns 409 if batch already exists
GET /protected/forms/batch/{number} JWT Get batch step form (1-10). Returns 425 if previous step incomplete
PUT /protected/data/batch/{number} JWT Save batch step options. Returns 400 on validation errors
POST /protected/batch/run JWT Start batch execution (sync in debug mode, async otherwise)
GET /process No Get batch process status by ?id={processId}

Routes Inherited from Base plugin-core

Method Path Auth Description
GET /info No Plugin metadata
PUT /registration No Plugin registration
GET /robots.txt No Robots exclusion
GET /protected/forms/settings JWT Settings form definition
GET /protected/data/settings JWT Current settings data
PUT /protected/data/settings JWT Save settings data
GET /protected/autocomplete/{name} JWT Autocomplete handler
GET /protected/preview/table/{name} JWT Table preview
GET /protected/preview/markdown/{name} JWT Markdown preview
POST /protected/upload JWT File upload

CORS headers are enabled on all routes by default.

CLI Commands

Commands Added by Macros ConsoleAppFactory

Command Description
batch:queue Picks up queued batches and spawns handler processes (runs every minute via cron)
batch:handle Executes the BatchHandlerInterface for a specific batch

Commands Inherited from Base plugin-core

Command Description
cron:run Runs all scheduled cron tasks
directory:clean Cleans temporary directories
db:create-tables Creates database tables
db:clean-tables Cleans old database records
lang:add Adds a new language
lang:update Updates translations
specialRequest:queue Processes special request queue
specialRequest:handle Handles a special request

Auto-registered Cron Tasks

The macros ConsoleAppFactory automatically registers these cron tasks (every minute):

Key Interfaces

BatchHandlerInterface

This is the central interface every macros plugin must implement. The handler receives:

The handler must:

  1. Call $process->initialize($count) to set the total order count
  2. Iterate over orders, calling $process->handle(), $process->skip(), or $process->addError() for each
  3. Call $process->save() after processing each order to persist progress
  4. Call $process->finish($result) when done

Process

Batch

BatchContainer

PluginPurpose

MacrosPluginClass values:

PluginEntity values:

ActionInterface

Used for custom HTTP action handlers (not typically needed in macros plugins, but available).

Example Plugin

The plugin-macros-example is a comprehensive example demonstrating all features of a macros plugin.

Example Project Structure

How the Example Plugin's BatchHandler Works

From ExampleHandler.php:

Dependencies

Package Version Purpose
salesrender/plugin-core ^0.4.1 Base plugin framework (Slim 4 + Symfony Console)
salesrender/plugin-component-purpose ^2.0 Plugin purpose/class/entity definitions

All transitive dependencies (Slim, Symfony Console, Medoo, batch components, etc.) come from plugin-core.

See Also


All versions of plugin-core-macros with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4.0
ext-json Version *
salesrender/plugin-core Version ^0.4.1
salesrender/plugin-component-purpose Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package salesrender/plugin-core-macros contains the following files

Loading the files please wait ...