PHP SDK: Algorithm Reference
The SDK provides ready-made tools inside a scenario. Use $ctx instead of direct cURL, files, or operating system commands: the platform applies site settings, permissions, request rate limits, and resource accounting.
This section documents PHP scenarios. To read about another language, use the selector next to the documentation version. The API section examples are for external applications.
A scenario can combine several websites and an incoming email. The site selected at creation determines where results are stored, not which addresses may be requested. Combining sources.
Reading the examples
<?php
function run(\Sdk\Context $ctx): void
{
// Put your algorithm and examples from this reference here.
$ctx->log('Starting collection');
}
Fragments on method pages belong inside run. Variables such as $response, $dom, $card, and $page are introduced at the start of the relevant page. They are separate examples, not one combined scenario to run from top to bottom.
In a signature, string is text, int an integer, float a decimal number, bool a Boolean, and array a list or map. ?string also allows null; mixed allows different types. A value after = is a default. void returns nothing, and never ends execution. Obtain SDK objects through $ctx; you cannot create them with new.
Choose a task
| Task | Section |
|---|---|
| Context: running, data, and progress | Context |
| AI: analyze, transform, and repair code | Ai |
| HTTP requests to a website | HttpClient |
| Wildberries products and regions | Wildberries |
| Response from a website | Response |
| Find elements in HTML | Dom |
| Individual card or element | Node |
| Text, prices, and numbers | TextTools |
| Links and URL parameters | UrlTools |
| State and resuming traversal | KeyValue |
| Open a page in a browser | Browser |
| Interact with a browser page | BrowserPage |
| Save files in S3 | Storage |
| Inspect a stored file | StoredFile |
Other allowed functions
Algorithms can use approved standard PHP functions such as count, trim, json_encode, preg_match, and array operations. The SDK catalog API and the editor show the current complete set. Not every PHP function is permitted: direct file access, networking, shell commands, dynamic code execution, and creating objects are prohibited.
Transport and CssSelector are internal SDK components, not user entry points, and should not be called from an algorithm.
Complete working examples
- First HTML collection
- Pages and categories
- JSON source
- Browser actions
- Parallel requests and progress
- Export transformation
For long collections, check for cancellation, save a cursor, report stages, and use a stable product key. Before publishing, run a trial and inspect the actual records.
Working with CAPTCHA: complete examples
Explore catalogs, pagination, batch loading, scrolling, sign-in, JavaScript rendering and control pages in the dedicated section. Each of the 12 walkthroughs includes settings, complete source and an explanation of the algorithm.
Explicit CAPTCHA tasks
Current type catalog, input schemas, cost quotations and task results are available through ctx.captcha(). The API works in the cloud and on agents with workspace billing. Reference.