1. Go to this page and download the library: Download atlas-php/atlas library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
atlas-php / atlas example snippets
use Atlasphp\Atlas\Atlas;
$response = Atlas::text('openai', 'gpt-4o-mini')
->message('Draft a brief, friendly email letting a client know their project is running two days behind, and propose Thursday for delivery.')
->asText();
echo $response->text;
// Hi Jordan — a quick heads-up that we're running about two days behind
// on the project. We're aiming to have everything to you by Thursday..."
use Atlasphp\Atlas\Agent;
class PlantShopAgent extends Agent
{
public function provider(): ?string
{
return 'anthropic';
}
public function model(): ?string
{
return 'claude-sonnet-4-20250514';
}
public function instructions(): ?string
{
return <<<'PROMPT'
You are Fern, the friendly plant-care and order specialist for {shop_name}.
## Customer
- **Name:** {customer_name}
- **Member since:** {member_since}
## How you help
- Greet {customer_name} by name and keep it warm.
- For anything about an order, call `lookup_order` first — never guess a status.
- If a plant arrived damaged, use `start_return` to open a replacement, then reassure them.
- Drop in a genuinely useful care tip when it fits.
PROMPT;
}
public function tools(): array
{
return [
LookupOrderTool::class,
StartReturnTool::class,
];
}
}
use Atlasphp\Atlas\Tools\Tool;
use Atlasphp\Atlas\Schema\Fields\StringField;
class LookupOrderTool extends Tool
{
public function __construct(
private OrderService $orders
) {}
public function name(): string
{
return 'lookup_order';
}
public function description(): string
{
return 'Look up the status and contents of an order by its ID';
}
public function parameters(): array
{
return [
new StringField('order_id', 'The order ID, e.g. "5512"'),
];
}
public function handle(array $args, array $context): mixed
{
$order = $this->orders->find($args['order_id']);
return $order ? $order->toArray() : 'No order found with that ID.';
}
}
$response = Atlas::agent('plant-shop')
->withVariables([
'shop_name' => 'Leaf & Co.',
'customer_name' => 'Sarah',
'member_since' => '2023',
])
->message('My monstera arrived with a snapped leaf — order #5512. Can I get a replacement?')
->asText();
$response->text; // "Oh no, Sarah! Let me pull up #5512 for you..."
$response->usage; // Token usage
$response->steps; // Tool call loop — lookup_order, then start_return