## Getting Started
### Minimal Setup
1. **Installation**:
```bash
composer require arnaudmoncondhuy/synapse-admin:^0.1
Ensure synapse-core is also installed (dependency).
Bundle Registration:
Add to config/bundles.php:
ArnaudMoncondhuy\SynapseAdmin\SynapseAdminBundle::class => ['all' => true],
Route Configuration:
Include routes in config/routes.yaml:
synapse_admin:
resource: '@SynapseAdminBundle/config/routes.yaml'
prefix: /synapse/admin
Security:
Protect routes in config/packages/security.yaml:
access_control:
- { path: ^/synapse/admin, roles: ROLE_ADMIN }
First Use Case:
Access /synapse/admin to view the dashboard. Start by configuring LLM providers (e.g., OpenAI, Gemini) under Providers (/synapse/admin/intelligence/configuration-llm).
Provider Configuration:
AdminSecurityTrait).Preset Management:
/synapse/admin/presets/new).Agent Configuration:
ROLE_SUPER_ADMIN).RAG Source Management:
/synapse/admin/rag).synapse:rag:test console command.Analytics & Quotas:
Leverage Twig Templates:
Extend layouts with @Synapse/admin/layout.html.twig for consistent UI.
Example:
{% extends '@Synapse/admin/layout/base.html.twig' %}
{% block body %}
{{ include('@Synapse/admin/partials/dashboard.html.twig') }}
{% endblock %}
Customize Permissions:
Extend DefaultPermissionChecker to add granular role checks:
use ArnaudMoncondhuy\SynapseAdmin\Security\AdminSecurityTrait;
class CustomPermissionChecker implements PermissionCheckerInterface
{
use AdminSecurityTrait;
public function hasPermission($user, string $attribute, mixed $subject = null): bool
{
// Custom logic here
return $this->isGranted('ROLE_CUSTOM_ADMIN', $user);
}
}
Extend Forms:
Override preset/provider forms by creating custom templates in templates/SynapseAdminBundle/ (e.g., preset/_form.html.twig).
Async Tasks: Use Symfony Messenger for long-running tasks (e.g., RAG reindexing):
$this->messageBus->dispatch(new ReindexRagSourceMessage($sourceId));
Multilingual Support:
Add translations via Symfony’s translation system (domain: synapse_admin):
# config/packages/translation.yaml
locales: [en, fr]
Security Misconfigurations:
/synapse/admin routes in security.yaml.ROLE_ADMIN (or custom role) via access_control.php bin/console debug:security to verify roles.Credential Leaks:
AdminSecurityTrait for encrypted storage. Never log raw credentials.var/log/synapse_admin.log for encrypted values (not plaintext).RAG Indexing Failures:
config/packages/dev/synapse_admin.yaml):
debug: true
php bin/console messenger:consume async -vv
Preset Testing Quirks:
system_prompt and tools in the Debug Logs (/synapse/admin/systeme/debug).Quota Overrides:
SynapseSpendingLimit entity is flushed after updates:
$limit->setAmount(1000);
$entityManager->flush();
Enable Debug Mode:
Add to config/packages/dev/synapse_admin.yaml:
synapse_admin:
debug: true
This logs:
preset.tested).Check Console Commands: Useful commands:
# Test RAG relevance
php bin/console synapse:rag:test "query here"
# Clear cache (if UI changes aren’t reflected)
php bin/console cache:clear
# List all agents/presets
php bin/console debug:container synapse_admin
Stimulus Debugging: For Stimulus controllers (e.g., live preset testing):
npm run dev # Rebuild assets
Check browser console for Stimulus errors (e.g., stimulus:action).
Custom Tools:
Register new AiToolInterface implementations:
// config/services.yaml
services:
App\Tool\CustomTool:
tags: ['synapse_admin.tool']
Dashboard Widgets:
Add custom widgets to the dashboard by extending the DashboardController:
class CustomDashboardController extends AbstractDashboardController
{
public function customWidget(): Response
{
return $this->render('@App/custom_widget.html.twig');
}
}
Audit Logs:
Extend audit logging by implementing SynapseAuditLoggerInterface:
class CustomAuditLogger implements SynapseAuditLoggerInterface
{
public function logEvent(string $event, array $context): void
{
// Custom logic (e.g., send to external SIEM)
}
}
Multilingual Forms: Override form translations dynamically:
{% trans with {'%model%': preset.model} from 'synapse_admin' %}
Preset uses model: %model%
{% endtrans %}
Health Checks:
Add custom checks to /synapse/admin/systeme/health:
use Symfony\Component\HealthCheck\HealthCheckInterface;
class CustomHealthCheck implements HealthCheckInterface
{
public function check(HealthCheck $healthCheck): void
{
if ($this->isDatabaseHealthy()) {
$healthCheck->ok();
} else {
$healthCheck->fail('Database unavailable');
}
}
}
Register in config/services.yaml:
tags: ['health_check.checker']
Asset Mapping:
If Stimulus controllers fail, ensure asset-mapper is configured:
# config/packages/framework.yaml
assets:
packages:
synapse_admin:
json_manifest_path: '%kernel.project_dir%/public/build/manifest.json'
Cache Invalidation:
Clear the synapse_admin cache after:
php bin/console cache:pool:clear synapse_admin
Provider-Specific Settings:
Some providers (e.g., OVH) require additional config. Check the DatabaseConfigProvider for defaults:
$provider = $this->configProvider->getProvider('ovh');
$provider->setApiKey('your_key_here');
Twig Strict Variables:
Avoid undefined variables in templates. Use {{ dump(var) }} to debug:
How can I help you explore Laravel packages today?