Download the PHP package particle-academy/fancy-mlm without Composer

On this page you can find all versions of the php package particle-academy/fancy-mlm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package fancy-mlm

Fancy MLM (PHP)

particle-academy/fancy-mlm — a framework-agnostic multi-level referral / network-marketing engine for agentic apps. A pure-PHP core (zero framework in require) with an optional Laravel bridge and first-class integration with the Fancy stack: fun-lab (gamified rewards), catalog (commerce), and fms (tiers + metered bonuses).

v0.2: Configurable downline trees — unilevel (unlimited frontline, up the sponsor tree), binary (two legs, up the placement tree), and matrix (forced W×depth, up the placement tree). A reward flows up the chosen tree, decaying per level and scaling by each upline member's tier, with dynamic compression. The gamified fun-lab loop is wired, and the Node mirror (@particle-academy/fancy-mlm) + React UI (@particle-academy/fancy-mlm-ui) track the same plan shape. Monetary commission ledgers and the catalog/fms bridges are on the roadmap (see .ai/plans/fancy-mlm.md).

For agents. This package is listed on the Fancy MCP catalog server at https://ui.particle.academy/mcp (streamable HTTP, no API key; MCP id fancy-ui), with install commands and docs, alongside the rest of the kit. How an agent installs and uses this package is in AGENTS.md.

Install

The core requires zero framework. The Laravel bridge auto-registers via package discovery when you're on Laravel 13 (the minimum; an older Laravel is refused).

Plain PHP (framework-agnostic core)

Implement two ports — read your members, receive computed rewards — and run the engine:

MemberRepository (find(id)) and RewardSink (pay(RewardComputation)) are the only things you implement. CompensationPlan is JSON — the same shape the Node mirror (@particle-academy/fancy-mlm) loads, so both produce identical rewards.

Downline trees

tree selects the shape the reward climbs — the engine walks it identically, the plan just points it at a different parent chain:

tree climbs frontline placement
unilevel sponsor tree (sponsor_id) unlimited —
binary placement tree (placement_id, falls back to sponsor_id) 2 spillover
matrix placement tree (placement_id, falls back to sponsor_id) width forced fill

Laravel

The bridge ships an Eloquent member tree, a config-driven plan, a facade, and the gamified referral loop (when laravel-fun-lab is installed):

The fun-lab loop. With laravel-fun-lab installed and mlm.fun_lab.enabled, the bridge listens for XpAwarded: when a referral earns XP, their upline is credited in points — scaled by level and tier — via LFL::award(...)->from('mlm'). Awards stamped with that source are ignored by the listener, so a bonus never re-triggers the loop (recursion guard).

Tiers map naturally onto fms feature groups, and a tier's scaling cap onto an fms resource-feature limit (MAX-wins group overrides) — see the design doc.

Referral codes, scans and attribution

Codes and links, scan and click logging, scan-to-signup attribution with a permanent sponsor, and conversion stats. Privacy-first by default.

Codes are 16 characters from the CSPRNG over a 32-letter alphabet (digits and lowercase letters without i, l, o, u): 80 bits, so they cannot be guessed. Lookups are case-insensitive. Each code is active or revoked, with an optional expiry. Mlm::revokeCode($code) stops it recording or attributing.

What a scan stores: the code, its owner and scope, the time, an HMAC-SHA256 of a session token under a secret key, and any $context you pass. Never an IP address, a user agent or a raw session id; the table has no column for them. The key is MLM_SESSION_HASH_KEY, or a sub-key derived from APP_KEY; with neither, hashing refuses to run. Rotating the key breaks dedupe and attribution for sessions already in flight.

If you put an IP or user agent in $context yourself, the scans table holds personal data (GDPR and similar laws treat both as such), your retention setting becomes a legal obligation, and you need a lawful basis to collect it. The package will store what you hand it; it will never fetch it.

The Laravel helpers hash a random token kept inside the session rather than the session id, because Auth::login() migrates the id and would break the link between a scan and the signup that follows it. On a stateless route, pass your own opaque visitor id to Mlm::recordScan() / Mlm::attributeSignup().

Refreshes don't inflate counts. A second scan of the same code from the same session within dedupe_minutes (default 30) is reported as duplicate and not stored.

Rate limiting is yours, through Laravel's limiter. For example:

(Limiting by IP keeps the IP in your cache for the decay period; that is your call, and nothing in this package stores it.)

Attribution

A signup is attributed to a scan by the same session within window_days (default 30) before it. model is first_touch (default) or last_touch.

Why first touch by default: the sponsor is permanent, so the model decides who owns a member for good. First touch credits whoever actually introduced the prospect, a later link cannot snipe that introduction, and the answer for a session does not change as more scans arrive.

The code must still be active and unexpired at signup: a code revoked or expired between scan and signup attributes nothing. The code's owner cannot be the new member (self_referral) or anyone in their downline (cycle). If the preferred scan is ineligible, the next one in policy order is tried. Calling attribution twice is safe: the second call returns the first result.

The sponsor is permanent

sponsor_id can go from null to a member once. After that, any change or clear fails loudly, at three layers:

Layer Refuses with
Mlm::assignSponsor() / the program SponsorImmutable, SelfReferral, SponsorCycle
The Member model ($member->update(...)) SponsorImmutable, SelfReferral
The database (query builder, raw SQL, other apps) a QueryException whose message starts fancy-mlm: sponsor_id

The database layer is a BEFORE UPDATE trigger: RAISE(ABORT) on SQLite, SIGNAL SQLSTATE '45000' on MySQL/MariaDB, a plpgsql function on PostgreSQL 11+. Other drivers get no trigger and rely on the code layers. If your database user cannot create triggers, set mlm.attribution.database_guard to false before migrating; the code layers still apply.

Correcting a sponsor set wrong (audited)

A support ticket or a fraud finding can show that a sponsor was set wrong. There is exactly one way to change it, and it is a separate method, never a flag on the paths above, which stay as locked as before:

How the database lets only this through. The trigger still refuses any change to a set sponsor_id, with one exception: the change that the member's latest audit row names, from exactly the current sponsor to exactly the new one. correctSponsor() writes that row and then updates the sponsor in the same transaction, so a failed update rolls the row back. A raw UPDATE with no row is refused, and so is a raw UPDATE that tries to reuse an old row: once a member is corrected again, the newer row is the latest, and the older one can never match. The same rule is why the table must be append-only, since deleting the latest row would make an older one usable again.

The guarantee is "no sponsor changes without an audit row", not "only this package can change a sponsor". Someone with raw write access could insert a row and then update, and they would leave exactly the audit trail this is for. Someone with DDL rights can drop the triggers. No trigger can stop that, and MySQL's TRUNCATE bypasses triggers too.

SQLite is what this package's suite runs. The MySQL/MariaDB triggers follow the same rule, but the suite does not run them. The PostgreSQL triggers were proved on PostgreSQL 17 by two consumers, through the published migrations:

On PostgreSQL, a refused statement aborts the surrounding transaction. Every statement after it fails with SQLSTATE 25P02 until the transaction rolls back. So:

Retention

The command refuses a retention shorter than the attribution window, since a pruned scan cannot attribute. Attributions are kept when scans are pruned.

Data model

mlm_members carries two parent pointers so one schema serves every tree type: sponsor_id (the enroller tree — who referred you, drives unilevel + matching) and placement_id (binary/matrix placement after spillover). Unilevel walks the sponsor tree; binary/matrix walk the placement tree, falling back to sponsor_id when a member has no distinct placement.

Compliance

A legitimate MLM pays on real product sales, not recruitment. This engine is built to anchor volume to actual catalog sales and to support clawbacks and income-disclosure reporting as those layers land. Use it accordingly.

License

MIT.


All versions of fancy-mlm with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package particle-academy/fancy-mlm contains the following files

Loading the files please wait ...