{"id":36981336,"url":"https://github.com/wooserv/laravel-objectid","last_synced_at":"2026-01-13T22:51:10.039Z","repository":{"id":323262275,"uuid":"1092668308","full_name":"wooserv/laravel-objectid","owner":"wooserv","description":"Elegant ObjectId generator for Laravel models with migration macro \u0026 helper.","archived":false,"fork":false,"pushed_at":"2025-11-09T04:16:32.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-09T06:09:32.142Z","etag":null,"topics":["laravel","laravel-package","objectid"],"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/wooserv.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-09T04:09:36.000Z","updated_at":"2025-11-09T04:19:44.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/wooserv/laravel-objectid","commit_stats":null,"previous_names":["wooserv/laravel-objectid"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/wooserv/laravel-objectid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooserv%2Flaravel-objectid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooserv%2Flaravel-objectid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooserv%2Flaravel-objectid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooserv%2Flaravel-objectid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wooserv","download_url":"https://codeload.github.com/wooserv/laravel-objectid/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wooserv%2Flaravel-objectid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28402160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["laravel","laravel-package","objectid"],"created_at":"2026-01-13T22:51:09.980Z","updated_at":"2026-01-13T22:51:10.032Z","avatar_url":"https://github.com/wooserv.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚡ Laravel ObjectId\n\nElegant, fast **ObjectId** generator for Laravel models —\nwith automatic ID assignment, migration macro, and helper function.\n\n[![Tests](https://github.com/wooserv/laravel-objectid/actions/workflows/tests.yml/badge.svg)](https://github.com/wooserv/laravel-objectid/actions/workflows/tests.yml)\n[![Packagist](https://img.shields.io/packagist/v/wooserv/laravel-objectid.svg)](https://packagist.org/packages/wooserv/laravel-objectid)\n[![License](https://img.shields.io/github/license/wooserv/laravel-objectid.svg)](https://github.com/wooserv/laravel-objectid/blob/main/LICENSE)\n\n\u003e Laravel ObjectId brings the power and efficiency of MongoDB-style ObjectIds to your Eloquent models — with no database dependency.\n\u003e\n\u003e It’s a **drop-in, ultra-fast unique ID system** that fits seamlessly into Laravel’s model lifecycle.\n\u003e\n\u003e With this package, you can:\n\u003e\n\u003e * Automatically assign 24-character hex ObjectIds to your models.\n\u003e * Use `$table-\u003eobjectId()` directly in your migrations.\n\u003e * Generate IDs anywhere using the global `objectid()` helper.\n\u003e * Enjoy compact, sortable, timestamp-encoded identifiers — **3× faster than UUIDs**.\n\u003e\n\u003e Built for performance, readability, and developer happiness.\n\u003e\n\u003e ---\n\u003e\n\u003e **Perfect for:**\n\u003e\n\u003e * Large-scale Laravel apps\n\u003e * Multi-database systems\n\u003e * UUID/ULID replacements\n\u003e * Caching and indexing optimization\n\n---\n\n## Installation\n\n```bash\ncomposer require wooserv/laravel-objectid\n```\n\nThis package is auto-discovered by Laravel.\nNo manual provider registration needed.\n\n---\n\n## Usage\n\n### 1. Model\n\n```php\nuse WooServ\\LaravelObjectId\\Concerns\\HasObjectIds;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Post extends Model\n{\n    use HasObjectIds;\n}\n```\n\nNow every new record gets a unique ObjectId automatically:\n\n```php\n$post = Post::create(['name' =\u003e 'Hello World']);\necho $post-\u003eid; // e.g. 6730b6a0d8a28f890b7c9f40\n```\n\n---\n\n### 2. Migration Macro\n\nThe service provider automatically adds a new macro to the schema builder:\n\n```php\nSchema::create('posts', function (Blueprint $table) {\n    $table-\u003eobjectId(); // Creates string(24) primary key\n    $table-\u003estring('name');\n    $table-\u003etimestamps();\n});\n```\n\nOptionally:\n\n```php\n$table-\u003eobjectId('uuid', false); // custom column, not primary\n```\n\n---\n\n### 3. Helper Function\n\n```php\n$id = objectid(); // returns 24-char hex ObjectId string\n```\n\n---\n\n## Why Laravel ObjectId?\n\n| Feature            | ObjectId         | UUID              | ULID        |\n| ------------------ | ---------------- | ----------------- | ----------- |\n| Sortable           | ✅ Yes            | ❌ No              | ✅ Yes       |\n| Length             | 24 chars         | 36 chars          | 26 chars    |\n| Contains Timestamp | ✅ Yes            | ❌ No              | ✅ Yes       |\n| Index Friendly     | ✅ Yes            | ⚠️ Larger Indexes | ✅ Yes       |\n| Collision Chance   | 🔒 Extremely Low | 🔒 Very Low       | 🔒 Very Low |\n\n---\n\n## Testing\n\n```bash\ncomposer test\n```\n\nRuns a full PHPUnit suite using an in-memory SQLite database.\n\n---\n\n## ⚡️ Benchmark Results\n\nAll benchmarks were executed on PHP 8.4 using in-memory SQLite\nand 10000 iterations per test on a local machine.\n\n### ObjectId Generation Speed\n\n```\nLaravel ObjectId Benchmark (10000 iterations)\n----------------------------------------------------------\nObjectId             : 0.412 µs per ID\nobjectid() helper    : 0.417 µs per ID\nUUID                 : 1.283 µs per ID\nULID                 : 1.147 µs per ID\n----------------------------------------------------------\nFastest: ObjectId\n```\n\n**Result:** `ObjectId` is roughly **3× faster** than UUID and **~2.7× faster** than ULID.\n\n---\n\n### Database Insert Performance\n\n```\nDatabase Insert Benchmark (1000 inserts)\n----------------------------------------------------------\nObjectId   : 14.78 ms total (0.015 ms/insert)\nUUID       : 15.48 ms total (0.015 ms/insert)\nULID       : 15.17 ms total (0.015 ms/insert)\n----------------------------------------------------------\n```\n\n**Result:** Real-world insert performance is effectively identical across ID types,\nbut **ObjectId maintains slightly lower overhead** during generation and indexing.\n\n---\n\n### Summary\n\n| Metric             | ObjectId       | UUID         | ULID        |\n| ------------------ | -------------- | ------------ | ----------- |\n| Generation Speed   | 🥇 **Fastest** | ⚪ Slow       | ⚪ Medium    |\n| Insert Speed       | ⚡ Very Fast    | ⚡ Very Fast  | ⚡ Very Fast |\n| Length             | 24 chars       | 36 chars     | 26 chars    |\n| Sortable           | ✅ Yes          | ❌ No         | ✅ Yes       |\n| DB Index Size      | 🔹 Small       | 🔸 Large     | 🔹 Small    |\n| Human Readable     | ⚪ Hex          | ⚪ Hyphenated | ⚪ Base32    |\n| Timestamp Embedded | ✅ Yes          | ❌ No         | ✅ Yes       |\n\n---\n\n**Conclusion:**\n`Laravel ObjectId` provides *faster generation*, *compact indexes*,\nand *timestamp-friendly IDs* — ideal for large-scale Laravel applications.\n\n---\n\n## License\n\nMIT © [WooServ](https://www.wooserv.com/)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooserv%2Flaravel-objectid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwooserv%2Flaravel-objectid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwooserv%2Flaravel-objectid/lists"}