Download the PHP package snowbuilds/laravel-mirror without Composer
On this page you can find all versions of the php package snowbuilds/laravel-mirror. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download snowbuilds/laravel-mirror
More information about snowbuilds/laravel-mirror
Files in snowbuilds/laravel-mirror
Package laravel-mirror
Short Description Laravel recommendation engine
License MIT
Homepage https://github.com/snowbuilds/laravel-mirror
Informations about the package laravel-mirror
- Introduction
- Installation
- Usage
- Weighted Averages
- Compare Different Properties
- Custom Scoring Algorithms
- Combining Weights & Custom Algorithms
- Organizing Code
- Macros
- Relationships
- Generate Recommendations
- Roadmap
- Testing
- Changelog
- Contributing
- Security Vulnerabilities
- Code of Conduct
- License
Introduction
Bring your user experience to the next level! Laravel Mirror lets you suggest content to your users intelligently! Easily recommend blog posts, products, recipes, books, etc., with pure PHP! Start by registering a recommendation strategy and routinely updating recommendations in a CRON job!
Installation
You can install the package via composer:
Usage
Registering a strategy is as simple as comparing two values! We added some utilities for convenience. For example, recommending blog posts with similar titles:
Weighted Averages
It is possible to combine algorithms! For example, suggesting posts with similar titles and tags. Adding weights will give fields precedence. Larger numbers have higher precedence. We made the title field score higher in a recommendation engine than the tags:
Different Properties in the Same Calculation
You can add a second parameter to the utility method when comparing properties with different names. For example, users should see posts based on their biography and followed communities:
Custom Scoring algorithms
When the helper utilities are insufficient, you can invoke custom algorithms using the using
method. The first value, $a
, is the model that has recommendations, and the second value, $b
, is the model being suggested:
Combining Weights with Custom Algorithms
Weights can also be applied to custom algorithms. The weights are applied in the order that the algorithm was registered. Our custom title comparator will take precedence over our tag comparator:
Managing Multiple Algorithms and Weights
The code becomes hard to read when using multiple custom algorithms and weights. If you use an associative array, you can keep your algorithms and weights organized:
Macros - Extracting Algorithms
When your custom algorithm is too cumbersome, you can extract it into a macro. We use an internal utility for registering algorithms, which you are free to use in your macros. This will create a clean utility API ->huggingFace
for our user model:
Relationships
You can define a relationship between the model and the suggested content using the morphsRecommendation
method. The content is ordered by the most suggested content:
Generating Recommendation Matrix
Calculating recommendations is resource-intensive. Laravel Mirror provides a command for syncing recommendations. After syncing, the recommendations are stored in the database and you will be able to fetch related suggestions:
In production, this should be a CRON job or registered in the Laravel kernel.
Roadmap
- [x] Blazingly Fast!
- [x] Polymorphic recommendations
- [x] Recommendation collections
- [x] Common comparison algorithms
- [x] Sync command
- [ ] Testing
- [ ] Programmatically invoke syncing actions
- [x] Simplified API for weights and faceted algorithms
- [ ] Queueing
- [ ] More algorithms
- [ ] More settings
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.
Credits
- Snow Labs
- Inspiration for Laravel Mirror
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-mirror with dependencies
illuminate/console Version ^10.15|^11.0
illuminate/container Version ^10.15|^11.0
illuminate/contracts Version ^10.15|^11.0
illuminate/filesystem Version ^10.15|^11.0
illuminate/pipeline Version ^10.15|^11.0
illuminate/support Version ^10.15|^11.0
oefenweb/damerau-levenshtein Version ^3.0
php-ai/php-ml Version ^0.10.0