{"id":20253240,"url":"https://github.com/becklyn/robots-txt","last_synced_at":"2025-04-10T23:33:44.629Z","repository":{"id":62492752,"uuid":"157220696","full_name":"Becklyn/robots-txt","owner":"Becklyn","description":"A package for generating a robots.txt programmatically.","archived":false,"fork":false,"pushed_at":"2022-02-18T08:19:11.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"1.x","last_synced_at":"2024-09-18T13:16:02.819Z","etag":null,"topics":["library","php","robots-txt"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Becklyn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2018-11-12T13:50:23.000Z","updated_at":"2022-02-18T08:17:56.000Z","dependencies_parsed_at":"2022-11-02T09:30:48.929Z","dependency_job_id":null,"html_url":"https://github.com/Becklyn/robots-txt","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Becklyn%2Frobots-txt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Becklyn%2Frobots-txt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Becklyn%2Frobots-txt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Becklyn%2Frobots-txt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Becklyn","download_url":"https://codeload.github.com/Becklyn/robots-txt/tar.gz/refs/heads/1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317331,"owners_count":21083519,"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":["library","php","robots-txt"],"created_at":"2024-11-14T10:22:36.874Z","updated_at":"2025-04-10T23:33:44.604Z","avatar_url":"https://github.com/Becklyn.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Robots.txt Library\n==================\n\n\nUsage\n-----\n\nFirst, you need to create a builder. With this builder you can create sections for different user agents and add the directives to it.\n\nYou can also add a header to the robots.txt and register your sitemap URLs.\n\n\n### Adding Sections\n\n```php\nuse Becklyn\\RobotsTxt\\Builder\\RobotsTxtBuilder;\n\n$builder = new RobotsTxtBuilder();\n\n// adding a section\n$builder-\u003egetSection(\"google\")\n    -\u003eallow(\"/public\")\n    -\u003edisallow(\"/admin\")\n    -\u003ecrawlDelay(20);\n    \n$builder-\u003egetSection(\"bing\")\n    -\u003eallow(\"/public\")\n    -\u003edisallow(\"/admin\")\n    -\u003edisallow(\"/private\")\n    -\u003ecrawlDelay(15);\n```\n    \nIf multiple search engines have the same directives, you can add one section for all of them:\n```php\n$builder-\u003egetSection(\"google\", \"bing\")\n    -\u003eallow(\"/public\")\n    -\u003edisallow(\"/admin\")\n    -\u003ecrawlDelay(20);\n```    \n    \nThe builder tries to bundle combine the directives of multiple sections if possible:\n\n```php\n$builder-\u003egetSection(\"google\")\n    -\u003eallow(\"/public\");\n    \n// ... some code ...\n\n$builder-\u003egetSection(\"google\")\n    -\u003edisallow(\"/admin\")\n    \n// will produce a single entry:\n//\n//      User-Agent: google\n//      Allow: /public\n//      Disallow: /admin\n```\n\n### Sitemaps\n\n```php\n$builder\n    -\u003eaddSitemap(\"https://example.org/sitemap.xml.tar.gz\")\n    -\u003eaddSitemap(\"https://example.org/sitemap.xml\");\n```\n\n### Header\n\nYou can also add a header which will be included at the very top:\n\n```php\n$builder\n    -\u003esetHeader(\"This is some example text\");\n    \n$builder-\u003egetSection(\"google\")\n    -\u003eallow(\"/public\");\n    \n// Will produce:\n//\n//      # This is some example text\n//\n//      User-Agent: google\n//      Allow: /public\n```\n\n### Outputting the robots.txt\n\n```php\n$content = $builder-\u003egetFormatted();\nfile_put_contents(\"robots.txt\", $content);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbecklyn%2Frobots-txt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbecklyn%2Frobots-txt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbecklyn%2Frobots-txt/lists"}