{"id":18367848,"url":"https://github.com/photon/utils-mongodb","last_synced_at":"2025-09-08T06:35:42.960Z","repository":{"id":57039268,"uuid":"47551515","full_name":"photon/utils-mongodb","owner":"photon","description":"Various useful tools for MongoDB","archived":false,"fork":false,"pushed_at":"2017-05-24T20:57:05.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-18T03:14:23.073Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/photon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-07T12:44:32.000Z","updated_at":"2017-04-18T17:05:56.000Z","dependencies_parsed_at":"2022-08-23T23:31:03.591Z","dependency_job_id":null,"html_url":"https://github.com/photon/utils-mongodb","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/photon/utils-mongodb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/photon%2Futils-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/photon%2Futils-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/photon%2Futils-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/photon%2Futils-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/photon","download_url":"https://codeload.github.com/photon/utils-mongodb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/photon%2Futils-mongodb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274146205,"owners_count":25230115,"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","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-05T23:23:42.888Z","updated_at":"2025-09-08T06:35:42.902Z","avatar_url":"https://github.com/photon.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"utils-mongodb\n============\n\n[![Build Status](https://travis-ci.org/photon/utils-mongodb.svg?branch=master)](https://travis-ci.org/photon/utils-mongodb)\n\nVarious useful tools for MongoDB\n\nPHP Versions\n------------\n\n- 5.6, 7.0 and 7.1 are supported and tested under travis\n- Use ext-mongodb and mongodb/mongodb. Do not works anymore with legacy ext-mongo\n\n\nQuick start\n----------\n\n1) Add the module in your project\n\n    composer require \"photon/utils-mongodb:dev-master\"\n\nor for a specific version\n\n    composer require \"photon/utils-mongodb:2.0.0\"\n\n2) Define a MongoDB connection in your project configuration\n\n    'databases' =\u003e array(\n        'default' =\u003e array(\n            'engine' =\u003e '\\photon\\db\\MongoDB',\n            'server' =\u003e 'mongodb://localhost:27017/',\n            'database' =\u003e 'utils',\n            'options' =\u003e array(\n                'connect' =\u003e true,\n            ),\n        ),\n    ),\n\n3) Enjoy !\n\nCounters\n--------\n\nThe counter class implement a atomic counter increment and retreive.\nIt's a thread safe auto-increment.\n\n1) Create a class to define a counters collection\n\n    class MyCounter extends \\photon\\utils\\mongodb\\Counter\n    {\n        const database = 'default';\n        const collection = 'counters';\n    }\n\n2) Read / Write counter\n\n        $value = MyCounter::get('foo');     // = 0\n        $value = MyCounter::inc('foo');     // = 1\n        $value = MyCounter::get('bar');     // = 0\n        $value = MyCounter::get('foo');     // = 1\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphoton%2Futils-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphoton%2Futils-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphoton%2Futils-mongodb/lists"}