Installation
Add the bundle to your composer.json:
composer require chigix/chiji-bundle
Enable it in config/bundles.php:
return [
// ...
Chigix\ChijiBundle\ChijiBundle::class => ['all' => true],
];
Configuration Publish the default config:
php bin/console chiji:install
Update config/packages/chigix_chiji.yaml with your Chiji API credentials:
chiji:
api_key: 'your_api_key_here'
base_uri: 'https://api.chiji.example.com'
First Use Case
Inject the ChijiClient service in a controller or command:
use Chigix\ChijiBundle\Client\ChijiClient;
class ExampleController extends AbstractController
{
public function __construct(private ChijiClient $chiji)
{}
public function index()
{
$response = $this->chiji->get('/v1/data');
return new JsonResponse($response);
}
}
API Integration
Use the ChijiClient for HTTP requests:
// GET request
$data = $this->chiji->get('/endpoint', ['param' => 'value']);
// POST request with payload
$this->chiji->post('/endpoint', ['key' => 'value']);
Event-Driven Logic Subscribe to Chiji events via Symfony’s event dispatcher:
# config/services.yaml
services:
App\EventListener\ChijiListener:
tags:
- { name: kernel.event_listener, event: chiji.response, method: onResponse }
Command-Line Automation Create custom commands using the client:
namespace App\Command;
use Chigix\ChijiBundle\Client\ChijiClient;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class SyncDataCommand extends Command
{
protected static $defaultName = 'app:chiji:sync';
public function __construct(private ChijiClient $chiji)
{
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$output->writeln('Syncing data...');
$this->chiji->post('/sync', ['force' => true]);
return Command::SUCCESS;
}
}
Twig Integration (if supported) Pass data to templates via controllers or create a custom Twig extension:
// src/Twig/AppExtension.php
class AppExtension extends \Twig\Extension\AbstractExtension
{
public function getFunctions()
{
return [
new \Twig\TwigFunction('chiji_data', [$this, 'getChijiData']),
];
}
public function getChijiData(ChijiClient $chiji)
{
return $chiji->get('/widget/data');
}
}
Deprecated Bundle
Configuration Overrides
config/packages/chigix_chiji.yaml exists after installation.API Rate Limits
ChijiClient:
$client->setMiddleware(function (callable $next) {
try {
return $next();
} catch (RateLimitException $e) {
sleep(10); // Retry after delay
return $next();
}
});
Event Dispatching
chiji.response may not be documented. Inspect the bundle’s EventDispatcher class for available events.Enable Debug Mode
Set debug: true in config/packages/chigix_chiji.yaml to log API requests/responses:
chiji:
debug: true
Custom HTTP Client
Extend ChijiClient to add logging or metrics:
class CustomChijiClient extends ChijiClient
{
public function __construct(GuzzleClient $client, LoggerInterface $logger)
{
parent::__construct($client);
$this->logger = $logger;
}
protected function doRequest(string $method, string $uri, array $options = [])
{
$this->logger->info("Chiji Request: {$method} {$uri}", $options);
return parent::doRequest($method, $uri, $options);
}
}
Override Services
Replace the default ChijiClient in config/services.yaml:
services:
Chigix\ChijiBundle\Client\ChijiClient:
alias: App\Service\CustomChijiClient
Add Custom Endpoints
Extend the bundle’s ChijiClient to include domain-specific methods:
class ExtendedChijiClient extends ChijiClient
{
public function fetchUserData(int $userId): array
{
return $this->get("/users/{$userId}");
}
}
Database Sync Use Doctrine listeners to sync Chiji data with your DB:
// src/EventListener/ChijiSyncListener.php
class ChijiSyncListener
{
public function onResponse(ChijiResponseEvent $event)
{
$data = $event->getData();
// Save to DB via EntityManager
}
}
How can I help you explore Laravel packages today?