{"id":22264353,"url":"https://github.com/nepster-web/php-mlm-matrix","last_synced_at":"2025-07-28T10:32:14.715Z","repository":{"id":24887986,"uuid":"28304112","full_name":"nepster-web/php-mlm-matrix","owner":"nepster-web","description":"Library for working with MLM matrices.","archived":false,"fork":false,"pushed_at":"2018-11-11T19:32:14.000Z","size":1422,"stargazers_count":58,"open_issues_count":2,"forks_count":48,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-11-04T20:06:25.515Z","etag":null,"topics":["mlm","mlm-matrix","network-marketing","php","php7"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nepster-web.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-21T15:42:12.000Z","updated_at":"2024-09-14T15:46:39.000Z","dependencies_parsed_at":"2022-08-23T03:50:26.500Z","dependency_job_id":null,"html_url":"https://github.com/nepster-web/php-mlm-matrix","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nepster-web%2Fphp-mlm-matrix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nepster-web%2Fphp-mlm-matrix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nepster-web%2Fphp-mlm-matrix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nepster-web%2Fphp-mlm-matrix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nepster-web","download_url":"https://codeload.github.com/nepster-web/php-mlm-matrix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227895724,"owners_count":17836454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mlm","mlm-matrix","network-marketing","php","php7"],"created_at":"2024-12-03T10:08:40.946Z","updated_at":"2024-12-03T10:08:41.450Z","avatar_url":"https://github.com/nepster-web.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"MLM Matrix\n==========\n\n[![Latest Version](https://img.shields.io/github/tag/nepster-web/php-mlm-matrix.svg?style=flat-square\u0026label=release)](https://github.com/nepster-web/php-mlm-matrix)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Total Downloads](https://img.shields.io/packagist/dt/nepster-web/php-mlm-matrix.svg?style=flat-square)](https://packagist.org/packages/nepster-web/php-mlm-matrix)\n\nLibrary for working with MLM matrices.\n\n\nDid you find an error?\n-----------------------\nIf you found an error in the code or grammatical mistake or any inaccuracy, \nplease create [new issues](https://github.com/nepster-web/php-mlm-matrix/issues/new).\n\n\nWhat is the MLM matrix?\n-----------------------\n\nAmong the many MLM compensation plans available today, the Matrix plan is among the most popularly \nrecommended owing to its uncomplicated structure. As it is quite simple in understanding it is \nconsidered very useful and resourceful and can be easily integrated into the MLM business.\n\nTo understand the Matrix plan, it makes sense to first understand its structure. The matrix  \nhas fixed numbers of rows and columns, organizing the numbers in a particular width and depth. \nTypically, most MLM Matrix plans follow two types of structures; 2x2 or the 3x3, but there are \nexceptions based on company requirements. All the members in a Matrix Plan are positioned \nserially from top to bottom or left to right.\n\n![demo](./doc/images/view.png \"\")\n\nAfter the matrix is filled, user at level 1 receives a reward and the matrix itself is divided into \nseveral matrices (depends on matrix pow, for example the cubic matrix will be divided into 3 new matrices). \nAfter that, new matrices wait for filling and cycle is repeated.\n\n\nInstall\n-------\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\n$ php composer.phar require --prefer-dist nepster-web/php-mlm-matrix \"*\"\n```\n\nor add\n\n```\n\"nepster-web/php-mlm-matrix\": \"*\"\n```\n\nto the `require` section of your `composer.json` file.\n\n\n\nStructure\n---------\n\n* `demo` - Library demo\n* `doc` - Documentation files for GitHub\n* `shema` - Sample database table schema (MySQL)\n* `src` - Main library code\n* `tests` - Unit tests\n\n\n\nUsage\n-----\n\nCreating a new matrix object:\n```php\nuse Nepster\\Matrix\\Matrix;\n\n$matrix = new Matrix(3, 2);\n```\n\n\nGetting information about the matrix:\n```php\n$matrix-\u003egetDepth();\n$matrix-\u003egetPow();\n```\n\n\nGet matrix array:\n```php\n$matrix-\u003etoArray();\n```\n\n\nManaging users in the matrix:\n```php\nuse Nepster\\Matrix\\Coord;\nuse Nepster\\Matrix\\Matrix;\n\n$matrix = new Matrix(3, 2);\n\n$matrix-\u003eaddTenant(null, function() {\n    // return your user data\n})\n\n$matrix-\u003eaddTenant(new Coord(1, 1), function() {\n    // return your user data\n})\n\n$matrix-\u003ehasTenant(new Coord(0, 0));\n$matrix-\u003ehasTenant(new Coord(1, 1));\n\n$matrix-\u003eremoveTenant(new Coord(1, 1));\n```\n\n\nCheck the correctness of coordinates:\n```php\n$matrix-\u003eisValidCoord(new Coord(0, 0));\n```\n\n\nCheck if there are free positions in the matrix:\n```php\n$matrix-\u003eisFilled();\n```\n\n[For more examples, see the demo file.](./demo/index.php)\n\n\nHow can I use database for matrices? \n------------------------------------\n\nBased on the different specifics of mlm projects and web development tools,\nthis library implements only the algorithm of operation of mlm matrices without storage support.\n\nHowever, if you works with the database you can easily implement keeping and restore of matrix objects.\nYou can study the example in the file [MySQL schema](shema/matrix.sql). \n\nFor example, create a new service that allows you to write and/or restore the matrix object from the database:\n\n```php\nclass MatrixService {\n\n    public function findById(int $id): Matrix\n    {\n        // You need make a query to the `matrix` table that find the required record\n        // Use join or another query to retrieve user data from the `matrix_users` table\n        // Initialize new Matrix object\n        // Using `addTenant` method that add users to Matrix object (based on data from `matrix_users` table)\n        // Return the proper Matrix object\n    }\n\n    public function save(Matrix $matrix): void\n    {\n        // Get the matrix array using the `$matrix-\u003etoArray()` method\n        // Create a valid request to save data to the database\n        // - Most likely in a relational database you will have 2 tables (matrices and matrix_users)\n        // - Don`t forget to check a new matrix is being created or edited an already existing matrix\n        \n        // Note1: Write down users with depth and number for further recovery\n        // Note2: Don`t write coordinates with empty positions to the database.\n    }\n\n}\n``` \n\n\nTesting\n-------\n\n```$ phpunit```\n\nor \n\n```$ vendor/bin/phpunit```\n\n\nLicense\n-------\nThis library is licensed under the MIT License - see the LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnepster-web%2Fphp-mlm-matrix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnepster-web%2Fphp-mlm-matrix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnepster-web%2Fphp-mlm-matrix/lists"}