{"id":37376245,"url":"https://github.com/ashtaev/php-table-of-contents","last_synced_at":"2026-01-16T05:03:15.094Z","repository":{"id":62488602,"uuid":"175821812","full_name":"ashtaev/php-table-of-contents","owner":"ashtaev","description":"A lightweight PHP library, for generating table of contents (TOC) in the style of Wikipedia.","archived":false,"fork":false,"pushed_at":"2019-03-21T07:13:43.000Z","size":167,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-13T09:29:28.713Z","etag":null,"topics":["contents","php","table-of-contents","toc"],"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/ashtaev.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":"2019-03-15T13:06:17.000Z","updated_at":"2024-10-23T13:52:09.000Z","dependencies_parsed_at":"2022-11-02T11:00:38.555Z","dependency_job_id":null,"html_url":"https://github.com/ashtaev/php-table-of-contents","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ashtaev/php-table-of-contents","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashtaev%2Fphp-table-of-contents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashtaev%2Fphp-table-of-contents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashtaev%2Fphp-table-of-contents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashtaev%2Fphp-table-of-contents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashtaev","download_url":"https://codeload.github.com/ashtaev/php-table-of-contents/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashtaev%2Fphp-table-of-contents/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28477210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T03:13:13.607Z","status":"ssl_error","status_checked_at":"2026-01-16T03:11:47.863Z","response_time":107,"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":["contents","php","table-of-contents","toc"],"created_at":"2026-01-16T05:03:15.042Z","updated_at":"2026-01-16T05:03:15.090Z","avatar_url":"https://github.com/ashtaev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"PHP Table of Contents\n=============\n\n[![Latest Stable Version](https://poser.pugx.org/ashtaev/toc/v/stable)](https://packagist.org/packages/ashtaev/toc)\n[![Total Downloads](https://poser.pugx.org/ashtaev/toc/downloads)](https://packagist.org/packages/ashtaev/toc)\n[![Latest Unstable Version](https://poser.pugx.org/ashtaev/toc/v/unstable)](https://packagist.org/packages/ashtaev/toc)\n[![License](https://poser.pugx.org/ashtaev/toc/license)](https://packagist.org/packages/ashtaev/toc)\n\nA lightweight PHP library, for generating table of contents in the style of Wikipedia.\nIt automatically generates table of contents for your posts, pages and custom post types by parsing its contents for headers.\nBy doing so, you can let your readers jump to a corresponding header by clicking on a link in the TOC.\nYou can place this TOC anywhere in a post using the shortcodes.\nYou don’t have to add any links or create any anchors for this.\nBuilt Wikipedia in mind, the table of contents by default appears before the first heading on a page.\nYou also get various methods to configure your TOC and control how it is going to appear.\nAlso, it sets no limit to the number of TOC you can create.\nYou can go on and have as many TOC as you want.\n\n## Screenshots\n\nThey're rendered using the sample templates provided in the [templates](templates/) directory,\nwhich depend on Bootstrap 4. \nYou can easily use your own custom HTML to render the table of contents instead.\n\nDefault template:\n\n\u003cimg src=\"screenshot-toc.png\" width=\"530px\"\u003e\u003cbr/\u003e\n\n## Installation\n\nInstall with composer:\n\n    composer require ashtaev/toc\n\n## Basic usage\n\nHere's a quick example using the defaults:\n\n    \u003c?php\n    \n    require '../vendor/autoload.php';\n\n    use ashtaev\\Toc;\n\n    $toc = new Toc($post);\n\n    ?\u003e\n      \n    \u003chtml\u003e\n        \u003chead\u003e\n            \u003c!-- The default, built-in template supports the Bootstrap 4 TOC styles. --\u003e\n            \u003clink rel=\"stylesheet\" href=\"https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css\" integrity=\"sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T\" crossorigin=\"anonymous\"\u003e\n            \u003clink rel=\"stylesheet\" href=\"css/toc.css\"\u003e\n        \u003c/head\u003e\n        \u003cbody\u003e\n      \n        \u003ch1\u003eLorem ipsum\u003c/h1\u003e\n\n        \u003c?php \n            // Example of rendering the table of contents with the built-in template.\n    \n            echo $toc-\u003egetPostWhithToc(); \n        ?\u003e\n        \n        \u003c/body\u003e\n    \u003c/html\u003e\n\nThis will output the following:\n\n    \u003cp\u003eLorem ipsum... \u003c/p\u003e\n\n    \u003cdiv class=\"border d-inline-block pr-4 pt-3 bg-light toc\"\u003e\n        \u003cdiv class=\"ml-4 mb-2\"\u003e\u003cb\u003eContent\u003c/b\u003e\u003c/div\u003e\n        \u003col\u003e\n            \u003cli\u003e\u003ca href=\"#Lorem_ipsum\" title=\"Lorem ipsum\"\u003eLorem ipsum\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"#Expedita_sint\" title=\"Expedita sint\"\u003eExpedita sint\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"#Maiores_quas\" title=\"Maiores quas\"\u003eMaiores quas\u003c/a\u003e\n                \u003col\u003e\n                    \u003cli\u003e\u003ca href=\"#Delectus_laudantium\" title=\"Delectus laudantium\"\u003eDelectus laudantium\u003c/a\u003e\u003c/li\u003e\n                    \u003cli\u003e\u003ca href=\"#Eaque_quisquam?\" title=\"Eaque quisquam?\"\u003eEaque quisquam?\u003c/a\u003e\u003c/li\u003e\n                    \u003cli\u003e\u003ca href=\"#Deleniti_et\" title=\"Deleniti et\"\u003eDeleniti et\u003c/a\u003e\n                        \u003col\u003e\n                            \u003cli\u003e\u003ca href=\"#Facilis_iusto!\" title=\"Facilis iusto!\"\u003eFacilis iusto!\u003c/a\u003e\u003c/li\u003e\n                            \u003cli\u003e\u003ca href=\"#Beatae_eveniet\" title=\"Beatae eveniet\"\u003eBeatae eveniet\u003c/a\u003e\u003c/li\u003e\n                        \u003c/ol\u003e\n                    \u003c/li\u003e\n                    \u003cli\u003e\u003ca href=\"#Beatae_fugit?\" title=\"Beatae fugit?\"\u003eBeatae fugit?\u003c/a\u003e\u003c/li\u003e\n                \u003c/ol\u003e\n            \u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"#Fugit_in\" title=\"Fugit in maxime\"\u003eFugit in maxime\u003c/a\u003e\u003c/li\u003e\n            \u003cli\u003e\u003ca href=\"#Odit_reprehenderit\" title=\"Odit reprehenderit\"\u003eOdit reprehenderit\u003c/a\u003e\u003c/li\u003e\n        \u003c/ol\u003e\n    \u003c/div\u003e\n    \n    \u003ch2\u003e\u003cspan id=\"Lorem_ipsum\"\u003e\"1. Lorem ipsum\u003c/span\u003e\u003c/h2\u003e\n    \n    \u003cp\u003eLorem ipsum dolor...\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashtaev%2Fphp-table-of-contents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashtaev%2Fphp-table-of-contents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashtaev%2Fphp-table-of-contents/lists"}