Skip to content

phpClaw for PrestaShop

The PrestaShop adapter is a module. It adds back office pages under phpClaw, a CLI script, a REST endpoint with per-employee tokens, and 21 tools.


RequirementVersion
PHP8.1 or later
PrestaShop8.0 or later

Download phpClaw for PrestaShop (.zip)

In the back office, go to Modules → Module Manager → Upload a module and upload the ZIP. Then open phpClaw → Settings, choose a provider and enter the API key.

Need a specific version? Browse all releases →

phpClaw in a PrestaShop store

The Settings page shows when a newer version is available. The module’s compatibility ceiling is the PrestaShop version it was installed on, so after upgrading PrestaShop itself, upload the module ZIP again to refresh it.


phpClaw → Settings stores its values in PrestaShop’s configuration: provider, model, API key, Base URL (for the Custom provider; https://, or http:// on localhost, 127.0.0.1 or ::1), system prompt, Store Messages (on by default), max iterations (default 20), Remote Skill URLs, and the phpClaw Cloud key, signing secret and disabled features. Cloud boots only while Store Messages is on.

With Store Messages off, the agent stores no message content. See Memory.

The module’s config/phpclaw.php holds settings with no form field: workspace_root (default storage/phpclaw under the shop root), shell_allowlist (core’s default), tool_deny, guards, hooks, skills and events_bridge. Several can be set by defining a PHP constant before the module loads, such as PHPCLAW_SHELL_ALLOWLIST.


The module adds back office tabs. Their permissions, set under Advanced Parameters → Team → Permissions, decide who can use phpClaw:

GrantAllows
view on Chat (AdminPhpClawDebug)opening the Chat page, the REST endpoint, and every PrestaShop tool
edit on Chatsending messages from the Chat page
view on Settingsthe Settings page and Test Connection
edit on Settingssaving settings
SuperAdmin profileeverything above, seeing every employee’s conversations, issuing and revoking API tokens, and database

A fresh install grants these to SuperAdmin only.

A tool call without the grant returns a FORBIDDEN error. The CLI script skips the check.


21 tools:

GroupTools
PrestaShopps_product, ps_order, ps_customer, ps_category, ps_manufacturer, ps_cart, ps_stock, ps_coupon, ps_module, ps_report, ps_config, ps_employee, database, ps_log
Corecode_search, project_info, file_read, http_request, shell_exec, file_edit, file_write

database runs one read-only SELECT and refuses the configuration, phpclaw_conversations and phpclaw_messages tables; for configuration the refusal points to ps_config. See Tools for the core tools.

ToolDoes
ps_productsearches and inspects products with stock and pricing
ps_ordersearches and inspects orders with status and payment data
ps_customersearches and inspects customers with order history statistics
ps_categorybrowses the category hierarchy
ps_manufacturersearches and inspects manufacturers and brands
ps_cartlists carts and finds abandoned ones
ps_stockchecks stock per product and finds items out of stock
ps_couponlists cart rules and vouchers
ps_modulesearches and inspects installed modules
ps_reportrevenue and order reports
ps_configreads configuration values
ps_employeesearches and inspects back office employees
databaseruns one read-only SELECT
ps_logreads the application log, dev.log

ps_config never returns a configuration name that matches any of 17 credential patterns: asking for one returns no rows rather than an error, and meta.blocked_patterns lists the 17. Inside a structured value it withholds keys named like credentials, at any depth. It returns name, value, id_shop and id_shop_group by default, because one name can hold a global row and a per-shop row.

Every response states what it cannot catch: a credential stored as plain text under a name that matches no pattern is returned in full. Most configuration rows are plain text, so do not treat the values as scrubbed.

Tools added through the actionPhpclawExtraTools hook are placed before the built-in tools.

tool_deny in config/phpclaw.php removes tools by name or group:

GroupTools
group:commerceps_product, ps_order, ps_customer, ps_cart, ps_coupon
group:catalogps_category, ps_manufacturer, ps_stock
group:systemdatabase, ps_log, ps_config, ps_module, ps_employee, ps_report

Every agent is built with CliApprovalGate. In a terminal you are asked before a tool changes something; in the back office and the REST endpoint there is nobody to ask, so the change is refused. See Security: approval.

file_write may create .php, .phtml and .phar files when run from the CLI script.


Terminal window
php modules/phpclaw/cli/phpclaw.php send "check stock levels for low inventory"
php modules/phpclaw/cli/phpclaw.php send "summarise orders" --stream --provider=openai --model=gpt-4o
php modules/phpclaw/cli/phpclaw.php mcp-server

send takes --stream, --provider and --model. mcp-server serves the tools over stdio; see MCP.

From PHP, phpclaw_agent('message') returns the reply text. For the full response, use the agent:

use PhpClaw\PrestaShop\Plugin;
$response = Plugin::getInstance()->engine()->send('Analyse cart abandonment this week.');
echo $response->text;

One front controller, with the action in the query string:

ActionURLReturns
send{shop}/index.php?fc=module&module=phpclaw&controller=api&action=sendthe reply as JSON
chat/stream{shop}/index.php?fc=module&module=phpclaw&controller=api&action=chat/streamServer-Sent Events

Both need POST with a JSON body holding message (at most 50,000 bytes) and an optional conversation_id.

Terminal window
curl -X POST "https://example.com/index.php?fc=module&module=phpclaw&controller=api&action=send" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"message":"how many orders came in today?"}'
  • Bearer token. A SuperAdmin issues a token for an employee on phpClaw → Settings. It is shown once and stored as a SHA-256 hash. It acts as that employee, who must be active and hold view on the Chat tab. Only the Authorization header is read. The employee and the grant are checked on every request, so revoking the token, removing the grant or deactivating the employee takes effect immediately.
  • Back office session. A logged-in employee with view on the Chat tab, from a same-origin request.
StatusCodeWhen
400phpclaw_empty_message, phpclaw_long_messagethe message is missing or too long
403phpclaw_forbiddennot authenticated, no Chat grant, or another employee’s conversation
404phpclaw_not_foundunknown action
405phpclaw_forbiddennot a POST
422phpclaw_guarda guard blocked the message
429phpclaw_rate_limitedmore than 60 requests from one IP in a 60-second window
500phpclaw_erroranything else failed
503phpclaw_not_configuredno provider is configured, or the agent raised a configuration error

The rate limit counts in APCu. Without APCu nothing is counted, so no request is limited.


PageTab permissionShows
SettingsSettingsthe settings, Test Connection, and API tokens for SuperAdmins
ChatChatthe chat interface with the employee’s conversations
AnalyticsAnalyticsconversation and message counts; store-wide for SuperAdmins, otherwise the employee’s own
GuideGuidethe registered tools
AboutAboutmodule information

Each conversation stores the creating employee’s id in id_employee, from the back office session or the token’s employee. Conversations created from the CLI store 0. An employee sees and opens only their own conversations; opening another’s is refused with 403. SuperAdmins see every conversation.

The agent always uses the ps_router memory driver, PsRouterMemory: conversations in the conversation tables, everything else in phpclaw_memory. The module also registers ps_db (PsDbMemory, phpclaw_memory only) and ps_setting (PsSettingMemory, PrestaShop’s configuration table).


A module registers additions by hooking these actions and returning an array of entries; phpClaw merges every module’s returned array. The bucket parameter holds what has been collected so far and is passed by value, so changing it adds nothing:

HookAdds
actionPhpclawExtraToolstools
actionPhpclawExtraGuardsguards
actionPhpclawExtraHookslifecycle listeners
actionPhpclawExtraSkillsskills
actionPhpclawExtraMemorymemory drivers
actionPhpclawExtraProvidersproviders

While events_bridge is on, every lifecycle event is also executed as a PrestaShop hook named actionPhpClaw followed by the event name in CamelCase, such as actionPhpClawAgentAfter, with event and context parameters. The event names are listed on the Hooks page.