bcc/myrrix
Myrrix is a Laravel/PHP package that helps manage modular application features with a clean structure and tooling. It supports organizing code into modules, simplifying registration and discovery, and keeping large projects maintainable with predictable conventions.
Installation
composer require bcc/myrrix
Add the package to your config/app.php providers (if not auto-discovered).
Basic Configuration
Create a myrrix.php config file in config/:
return [
'host' => env('MYRRIX_HOST', 'localhost'),
'port' => env('MYRRIX_PORT', 8080),
'timeout' => 5.0,
];
First Use Case: Fetching Recommendations
use Bcc\Myrrix\Client;
$client = new Client(config('myrrix'));
$recommendations = $client->getRecommendations('user:123', 'item:*', 10);
new \Bcc\Myrrix\Client($config)getRecommendations($userId, $itemIdPattern, $limit)addFeedback($userId, $itemId, $rating)updateItemFeatures($itemId, $features)User Interaction → Feedback Loop
// In your controller
$recommendations = $client->getRecommendations(
auth()->id(),
'category:electronics',
5
);
// After user rates an item
$client->addFeedback(auth()->id(), $ratedItemId, $rating);
Batch Processing
$client->batchFeedback([
['userId' => 'user:1', 'itemId' => 'item:101', 'rating' => 5],
['userId' => 'user:2', 'itemId' => 'item:102', 'rating' => 3],
]);
Caching Layer: Cache recommendations for 5-10 minutes to reduce Myrrix load:
$cacheKey = "recs:{$userId}:{$category}";
return Cache::remember($cacheKey, now()->addMinutes(10), function() use ($client, $userId, $category) {
return $client->getRecommendations($userId, $category, 5);
});
Queue Delayed Feedback: Use Laravel queues to defer feedback processing:
FeedbackProcessed::dispatch($userId, $itemId, $rating)->delay(now()->addSeconds(30));
Feature Updates: Sync item metadata periodically:
$client->updateItemFeatures('item:123', [
'price' => 19.99,
'stock' => 50,
'category' => 'electronics',
]);
Connection Timeouts
config('myrrix.timeout') to 10.0 for heavy loads.storage/logs/laravel.log for stream_select(): failed errors.Item ID Patterns
*) in getRecommendations() are not supported in all Myrrix versions. Use exact IDs or pre-filter in Laravel:
$itemIds = Item::where('category', 'electronics')->pluck('myrrix_id');
$recommendations = $client->getRecommendations('user:123', implode('|', $itemIds), 5);
Feedback Throttling
try {
$client->addFeedback($userId, $itemId, $rating);
} catch (\Bcc\Myrrix\Exception\ThrottledException $e) {
sleep(2 ** $attempt);
retry();
}
Enable Verbose Logging
$client = new Client(config('myrrix'), [
'debug' => true,
'log_path' => storage_path('logs/myrrix.log'),
]);
Common Errors:
| Error | Cause | Fix |
|---|---|---|
Invalid user ID format |
Non-string user IDs | Ensure IDs are prefixed (e.g., user:123) |
Item not found |
Typos in item IDs | Validate IDs before calling Myrrix |
Serialization failed |
Non-serializable features | Use arrays/JSON strings only |
Custom Response Parsing Override the default JSON decoder:
$client = new Client(config('myrrix'));
$client->setResponseParser(function ($raw) {
return json_decode($raw, true, 512, JSON_BIGINT_AS_STRING);
});
Middleware for Requests Add headers or modify payloads:
$client->addRequestModifier(function ($request) {
$request->headers->set('X-Custom-Header', 'value');
});
Event Listeners Trigger events after operations:
$client->onRecommendations(function ($userId, $recommendations) {
event(new RecommendationsFetched($userId, $recommendations));
});
How can I help you explore Laravel packages today?