{"id":13684578,"url":"https://github.com/UseMuffin/Slug","last_synced_at":"2025-04-30T21:31:04.452Z","repository":{"id":30464905,"uuid":"34018840","full_name":"UseMuffin/Slug","owner":"UseMuffin","description":"Slugging for CakePHP","archived":false,"fork":false,"pushed_at":"2024-10-29T08:16:38.000Z","size":146,"stargazers_count":35,"open_issues_count":4,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T09:22:56.649Z","etag":null,"topics":["cakephp","cakephp-plugin","php","slug"],"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/UseMuffin.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}},"created_at":"2015-04-15T21:10:58.000Z","updated_at":"2024-10-29T08:16:38.000Z","dependencies_parsed_at":"2024-06-18T15:19:49.221Z","dependency_job_id":"9a25b92a-2360-4d23-98c7-0713f9310561","html_url":"https://github.com/UseMuffin/Slug","commit_stats":{"total_commits":126,"total_committers":11,"mean_commits":"11.454545454545455","dds":0.2063492063492064,"last_synced_commit":"524e02dc6aabada1430093cdffae711458071933"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FSlug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FSlug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FSlug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FSlug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UseMuffin","download_url":"https://codeload.github.com/UseMuffin/Slug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224224798,"owners_count":17276428,"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":["cakephp","cakephp-plugin","php","slug"],"created_at":"2024-08-02T14:00:35.128Z","updated_at":"2024-11-12T05:32:26.881Z","avatar_url":"https://github.com/UseMuffin.png","language":"PHP","readme":"# Slug\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/UseMuffin/Slug/ci.yml?style=flat-square\n)](https://github.com/UseMuffin/Slug/actions)\n[![Coverage](https://img.shields.io/codecov/c/github/UseMuffin/Slug/master.svg?style=flat-square)](https://codecov.io/github/UseMuffin/Slug)\n[![Total Downloads](https://img.shields.io/packagist/dt/muffin/slug.svg?style=flat-square)](https://packagist.org/packages/muffin/slug)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)\n\nSlugging for CakePHP\n\n## Installation\n\nUsing [Composer][composer]:\n\n```bash\ncomposer require muffin/slug\n```\n\nLoad the plugin using the CLI command:\n\n```bash\n./bin/cake plugin load Muffin/Slug\n```\n\n## Usage\nTo enable slugging add the behavior to your table classes in the\n`initialize()` method.\n\n```php\npublic function initialize(array $config): void\n{\n    //etc\n    $this-\u003eaddBehavior('Muffin/Slug.Slug', [\n        // Optionally define your custom options here (see Configuration)\n    ]);\n}\n```\n\n\u003e Please note that Slug expects a database column named `slug` to function.\n\u003e If you prefer to use another column make sure to specify the `field`\n\u003e configuration option.\n\n### Searching\nIf you want to find a record using its slug, a custom finder is provided by the plugin.\n\n```php\n// src/Controller/ExamplesController.php\n$example = $this-\u003eExamples-\u003efind('slugged', slug: $slug);\n```\n\n## Configuration\n\nSlug comes with the following configuration options:\n\n- `field`: name of the field (column) to hold the slug. Defaults to `slug`.\n- `displayField`: name of the field(s) to build the slug from. Defaults to\n     the `\\Cake\\ORM\\Table::displayField()`.\n- `separator`: defaults to `-`.\n- `replacements`: hash of characters (or strings) to custom replace before\n generating the slug.\n- `maxLength`: maximum length of a slug. Defaults to the field's limit as\n defined in the schema (when possible). Otherwise, no limit.\n- `slugger`: class that implements the `Muffin\\Slug\\SlugInterface`. Defaults\n to `Muffin\\Slug\\Slugger\\CakeSlugger`.\n- `unique:`: tells if slugs should be unique. Set this to a callable if you\n want to customize how unique slugs are generated. Defaults to `true`.\n- `scope`: extra conditions used when checking a slug for uniqueness.\n- `implementedEvents`: events this behavior listens to. Defaults to\n  `['Model.buildValidator' =\u003e 'buildValidator', 'Model.beforeSave' =\u003e 'beforeSave']`.\n  By default the behavior adds validation for the `displayField` fields to make\n  them required on record creating. If you don't want these auto added validations\n  you can set `implementedEvents` to just `['Model.beforeSave' =\u003e 'beforeSave']`.\n- `onUpdate`: Boolean indicating whether slug should be updated when updating\n  record, defaults to `false`.\n- `onDirty`: Boolean indicating whether slug should be updated when slug field\n  is dirty (has a preset value custom value), defaults to `false`.\n\n## Sluggers\n\nThe plugin contains two sluggers:\n\n### CakeSlugger\n\nThe `CakeSlugger` uses `\\Cake\\Utility\\Text::slug()` to generate slugs. In the\nbehavior config you can set the `slugger` key as shown below to pass options to\nthe `$options` arguments of `Text::slug()`.\n\n```php\n'slugger' =\u003e [\n    'className' =\u003e \\Muffin\\Slug\\Slugger\\CakeSlugger::class,\n    'transliteratorId' =\u003e '\u003cA valid ICU Transliterator ID here\u003e'\n]\n```\n\n### ConcurSlugger\n\nThe `ConcurSlugger` uses [concur/slugify](https://github.com/cocur/slugify) to generate slugs.\nYou can use config array similar to the one shown above to pass options to\n`Cocur\\Slugify\\Slugify`'s constructor.\n\n## Patches \u0026 Features\n\n* Fork\n* Mod, fix\n* Test - this is important, so it's not unintentionally broken\n* Commit - do not mess with license, todo, version, etc. (if you do change any, bump them into commits of\ntheir own that I can ignore when I pull)\n* Pull request - bonus point for topic branches\n\nTo ensure your PRs are considered for upstream, you MUST follow the CakePHP coding standards.\n\n## Bugs \u0026 Feedback\n\nhttp://github.com/usemuffin/slug/issues\n\n## License\n\nCopyright (c) 2015-Present, [Use Muffin][muffin] and licensed under [The MIT License][mit].\n\n[cakephp]:http://cakephp.org\n[composer]:http://getcomposer.org\n[mit]:http://www.opensource.org/licenses/mit-license.php\n[muffin]:http://usemuffin.com\n","funding_links":[],"categories":["SEO"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUseMuffin%2FSlug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FUseMuffin%2FSlug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUseMuffin%2FSlug/lists"}