1. Go to this page and download the library: Download pigagent/pig 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/ */
pigagent / pig example snippets
// ~/.pig/agent/hooks/no-force-push.php
use Pig\CodingAgent\Hooks\HookApi;
use Pig\CodingAgent\Hooks\Results\ToolCallEventResult;
return function (HookApi $pi): void {
$pi->on('tool_call', function ($event) {
if ($event->toolName === 'bash' && str_contains($event->input['command'] ?? '', '--force')) {
return new ToolCallEventResult(block: true, reason: 'No force pushes from here.');
}
return null;
});
};
// ~/.pig/agent/tools/wc/index.php
use Pig\Agent\AgentToolResult;
use Pig\Ai\TextContent;
use Pig\CodingAgent\CustomTools\CustomTool;
use Pig\CodingAgent\CustomTools\CustomToolApi;
return fn (CustomToolApi $pi) => new CustomTool(
name: 'wc',
label: 'Count lines',
description: 'Count the lines in a file.',
parameters: [
'type' => 'object',
'properties' => ['path' => ['type' => 'string', 'description' => 'the file']],
'
bash
composer global "$(composer global config bin-dir --absolute):\$PATH\"" >> ~/.zshrc
exec $SHELL
bash
ANTHROPIC_API_KEY=sk-ant-... php examples/ask.php "why is the sky blue?"
bash
composer install
php test/lint.php # php -l over every file
vendor/bin/phpunit
php test/live.php # the providers against the real endpoints — costs money, needs keys
php scripts/generate-models.php # bring the model registry up to date from models.dev
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.