{"id":21525822,"url":"https://github.com/bkwld/sitemap-from-routes","last_synced_at":"2025-03-17T18:19:57.282Z","repository":{"id":62494851,"uuid":"102861207","full_name":"BKWLD/sitemap-from-routes","owner":"BKWLD","description":"Generate a sitemap directly from your Laravel routes/web.php.","archived":false,"fork":false,"pushed_at":"2017-09-08T16:50:12.000Z","size":7,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-05T10:02:05.621Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BKWLD.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":"2017-09-08T12:53:55.000Z","updated_at":"2020-02-27T11:49:37.000Z","dependencies_parsed_at":"2022-11-02T11:31:38.175Z","dependency_job_id":null,"html_url":"https://github.com/BKWLD/sitemap-from-routes","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BKWLD%2Fsitemap-from-routes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BKWLD%2Fsitemap-from-routes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BKWLD%2Fsitemap-from-routes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BKWLD%2Fsitemap-from-routes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BKWLD","download_url":"https://codeload.github.com/BKWLD/sitemap-from-routes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244085008,"owners_count":20395523,"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-24T01:38:36.857Z","updated_at":"2025-03-17T18:19:57.264Z","avatar_url":"https://github.com/BKWLD.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sitemap from Routes\n\nGenerate a sitemap directly from your Laravel routes/web.php using [roumen/sitemap](https://github.com/Laravelium/laravel-sitemap).\n\n```php\nSitemap::add(Route::get('news', 'News@index'));\nSitemap::add('news/{article}', 'News@show'));\n```\n\nThis works because, during install, you change the Route facade to point to a class of this package that adds a the fluent `sitemap` to Laravel `Route` instances.  The `sitemap` method looks at the uri of the route and unpacks any model bindings it finds, fetching all public instances of those models and adding them to the sitemap.\n\n\n## Installation\n\n1. Run `require add bkwld/sitemap-from-routes`\n2. Install [roumen/sitemap](https://github.com/Laravelium/laravel-sitemap) assets: `php artisan vendor:publish --provider=\"Roumen\\Sitemap\\SitemapServiceProvider\"`\n3. Add a route for the sitemap to your routes file: `Route::get('sitemap', '\\Bkwld\\SitemapFromRoutes\\Controller@index')`.\n\n#### Laravel \u003c 5.5\n\n1. Add to `config.app` providers: `Bkwld\\SitemapFromRoutes\\ServiceProvider::class`\n2. Add to `config.app` aliases: `'Sitemap' =\u003e Bkwld\\SitemapFromRoutes\\Facades::class`\n\n## Usage\n\nCall `sitemap()` from any routes you want to add to the sitemap.  For example:\n\n```php\nSitemap::add('news', 'News@index'));\nSitemap::add('news/{article}', 'News@show')-\u003ename('article'));\n```\n\nDynamic route parameters must be named the same as the models they should resolve.  So, in the above example, you must have an `App\\Article` model.  \n\nBy default, all instances of a model are added to the sitemap by substituting the id of the model into the uri.  Thus, the example route would generate `news/1`, `news/2`, and so on.\n\n#### Customize the query\n\nTo customize which model instances should be added to the sitemap, specify a `forSitemap` scope on your model.  You would do this to only add public records to the sitemap, for instance.\n\n```\nnamespace App;\nclass Article {\n    public function scopeForSitemap($query)\n    {\n        $query-\u003ewhere('public', 1);\n    }\n}\n```\n\n#### Customize the URL\n\nTo customize the URL that is added to the sitemap for model instances, specify a `sitemapUrl` accessor on your model.  You would do this if you use slugs in your URLs.\n\n```\nnamespace App;\nclass Article {\n    public function getSitemapUrlAttribute()\n    {\n        return route('article', $this-\u003eslug);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkwld%2Fsitemap-from-routes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbkwld%2Fsitemap-from-routes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkwld%2Fsitemap-from-routes/lists"}