{"id":18389852,"url":"https://github.com/proloser/cakephp-closurebehavior","last_synced_at":"2025-04-07T02:34:44.060Z","repository":{"id":2186880,"uuid":"3134568","full_name":"ProLoser/CakePHP-ClosureBehavior","owner":"ProLoser","description":"An efficient alternative to CakePHP Tree Behavior","archived":false,"fork":false,"pushed_at":"2012-02-05T09:58:49.000Z","size":97,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T07:45:02.872Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ProLoser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-09T06:47:05.000Z","updated_at":"2018-02-28T12:44:55.000Z","dependencies_parsed_at":"2022-08-31T01:11:53.931Z","dependency_job_id":null,"html_url":"https://github.com/ProLoser/CakePHP-ClosureBehavior","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProLoser%2FCakePHP-ClosureBehavior","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProLoser%2FCakePHP-ClosureBehavior/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProLoser%2FCakePHP-ClosureBehavior/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProLoser%2FCakePHP-ClosureBehavior/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ProLoser","download_url":"https://codeload.github.com/ProLoser/CakePHP-ClosureBehavior/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247583551,"owners_count":20962057,"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":[],"created_at":"2024-11-06T01:44:49.856Z","updated_at":"2025-04-07T02:34:39.051Z","avatar_url":"https://github.com/ProLoser.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CakePHP Closure Behavior\nAn efficient alternative to the CakePHP Tree Behavior\n\n## Background\nI was working on a project, where I listed multiple posts on the homepage and wanted to show the categories they fell under as breadcrumbs. Normally the tree behavior works just fine, but if I have 40 posts, I now do 1 query for the list of posts and 40 queries to get a list of all ancestor categories for the post. This didn't seem like a good idea, so I started to look for ways around this. generateTreeList and an iterator function seemed more viable, cutting my query down to 2, but the function itself would prove to be complex and slow.\n\nAfter searching for feedback on irc.freenode.net/php someone pointed me to an [interesting slideshow](http://www.slideshare.net/billkarwin/sql-antipatterns-strike-back) where I learned about the 'Closure' pattern (page 68). It seems to be a much more efficient alternative to MPTT. So this is my attempt to implement it.\n\nAn interesting example implementation: http://codepad.org/pR5r68V0\n\n## Installation\n### With Git\n\n```\ngit submodule add git@github.com:ProLoser/CakePHP-ClosureBehavior.git Plugin/Closure\n```\n\n### Without Git\n[Download package](https://github.com/ProLoser/CakePHP-ClosureBehavior/downloads) and extract to Plugin/Closure\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproloser%2Fcakephp-closurebehavior","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fproloser%2Fcakephp-closurebehavior","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fproloser%2Fcakephp-closurebehavior/lists"}