1. Go to this page and download the library: Download synapcores/laravel 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/ */
synapcores / laravel example snippets
use SynapCores\Laravel\Facades\SynapCores;
$customers = SynapCores::sql('SELECT * FROM customers WHERE id = :id', ['id' => 42]);
foreach ($customers as $row) {
echo $row['name'], PHP_EOL;
}
$summary = SynapCores::agentRun(
persona: 'technical_advisor',
task: 'Summarize the open support tickets.'
);
echo $summary->answer;
use Illuminate\Database\Eloquent\Model;
use SynapCores\Laravel\Eloquent\VectorCast;
class Doc extends Model
{
protected $casts = [
'embedding' => VectorCast::class,
];
}
// Reads come back as float[]:
$doc = Doc::find(1);
count($doc->embedding); // 384
// Writes accept float[]:
$doc->embedding = SynapCores::embed("hello world");
$doc->save();
use SynapCores\Laravel\Eloquent\HasRAG;
class Doc extends Model
{
use HasRAG;
protected $synapcoresEmbeddingColumn = 'embedding'; // optional override
}
// Returns a Collection<Doc>, each with a _score attribute (cosine similarity).
$hits = Doc::ragSearch('how do I reset my password?', k: 5);
foreach ($hits as $doc) {
echo "[{$doc->_score}] {$doc->title}\n";
}
// With WHERE filters:
$hits = Doc::ragSearch('billing question', k: 10, where: ['lang' => 'en']);
use SynapCores\Laravel\Jobs\SynapCoresAgentJob;
$job = new SynapCoresAgentJob(
persona: 'support_summarizer',
task: 'Summarize all support tickets opened today.',
opts: ['max_iterations' => 8]
);
dispatch($job);
// Later, fetch the result:
$result = SynapCoresAgentJob::result($job->jobId);
echo $result['answer'];
bash
# Quick SQL sanity check
php artisan synapcores:query "SELECT NOW()"
# Format options: table (default), json, csv
php artisan synapcores:query "SELECT * FROM customers LIMIT 5" --format=json
# Fire an agent
php artisan synapcores:agent-run --persona=technical_advisor --task="What changed in v1.7?"
# Import a recipe
php artisan synapcores:recipe-import https://synapcores.com/recipes/churn-prediction.md
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.