Installation Add the bundle via Composer:
composer require bcc/myrrix-bundle
Enable the bundle in config/bundles.php:
return [
// ...
MichelSalib\BCCMyrrixBundle\BCCMyrrixBundle::class => ['all' => true],
];
Configuration Publish the default config:
php bin/console bcc-myrrix:install
Edit config/packages/bcc_myrrix.yaml to match your Myrrix cluster settings (e.g., host, port, namespace).
First Use Case
Inject the MyrrixClient service and interact with Myrrix:
use MichelSalib\BCCMyrrixBundle\Service\MyrrixClient;
class RecommendationService
{
public function __construct(private MyrrixClient $myrrix)
{
}
public function getRecommendations(string $userId, int $limit = 5): array
{
return $this->myrrix->recommend($userId, $limit);
}
}
Recommendation Fetching
Use the MyrrixClient to fetch recommendations:
$recommendations = $myrrix->recommend('user_123', 10);
// Returns array of recommended items (e.g., ['item_456', 'item_789']).
Feedback Handling Log implicit/explicit feedback:
$myrrix->logFeedback('user_123', 'item_456', 'click'); // 'click', 'purchase', etc.
Model Management Deploy/update models via CLI:
php bin/console bcc-myrrix:deploy-model --model=my_model --path=/path/to/model
kernel.request for real-time recommendations).Connection Issues
ConnectionException if the cluster is down. Implement retry logic:
try {
$myrrix->recommend($userId);
} catch (ConnectionException $e) {
// Fallback to cached recommendations or default items.
}
Namespace Conflicts
Ensure the namespace in bcc_myrrix.yaml matches your Myrrix cluster’s configuration. Mismatches cause silent failures.
Model Deployment
.model files). Validate before deployment:
php bin/console bcc-myrrix:validate-model --path=/path/to/model
bcc_myrrix.yaml (debug: true) for verbose output.bcc-myrrix:status to check cluster health:
php bin/console bcc-myrrix:status
Custom Metrics
Extend the FeedbackLogger to support custom metrics:
$myrrix->logCustomMetric('user_123', 'session_duration', 120);
Recommendation Filters
Override the RecommendationFilter service to pre/post-process recommendations:
# config/services.yaml
MichelSalib\BCCMyrrixBundle\Service\RecommendationFilter:
arguments:
$customFilter: '@app.custom_recommendation_filter'
Event Listeners
Subscribe to Myrrix events (e.g., model.deployed) via Symfony’s event dispatcher.
How can I help you explore Laravel packages today?