{"id":37012104,"url":"https://github.com/carlcraig/tc-front-matter","last_synced_at":"2026-01-14T01:03:05.175Z","repository":{"id":57065731,"uuid":"83849905","full_name":"carlcraig/tc-front-matter","owner":"carlcraig","description":"An adapter based front matter parser/dumper for php","archived":false,"fork":false,"pushed_at":"2017-03-04T02:48:09.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-31T15:01:25.656Z","etag":null,"topics":["front-matter","json","php","symfony","yaml"],"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/carlcraig.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":"2017-03-03T23:15:34.000Z","updated_at":"2017-03-04T15:16:53.000Z","dependencies_parsed_at":"2022-08-24T07:50:41.721Z","dependency_job_id":null,"html_url":"https://github.com/carlcraig/tc-front-matter","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/carlcraig/tc-front-matter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlcraig%2Ftc-front-matter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlcraig%2Ftc-front-matter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlcraig%2Ftc-front-matter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlcraig%2Ftc-front-matter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carlcraig","download_url":"https://codeload.github.com/carlcraig/tc-front-matter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlcraig%2Ftc-front-matter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["front-matter","json","php","symfony","yaml"],"created_at":"2026-01-14T01:03:04.519Z","updated_at":"2026-01-14T01:03:05.155Z","avatar_url":"https://github.com/carlcraig.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Tc Front Matter\n===============\n\n\u003e An adapter based front matter parser/dumper for php\n\nInstallation\n------------\n\n```shell\ncomposer require tc/front-matter\n```\n\nAdapters\n--------\n\n- YAML\n- JSON\n\nExample Usage\n-------------\n\n```php\n\u003c?php\n\nuse Tc\\FrontMatter\\FrontMatter;\nuse Tc\\FrontMatter\\Adapter\\JsonAdapter;\n\n// sample yaml front matter\n$fileContent = '---\ntitle: A Title\nslug: a-slug\ncreated: 2017-01-01 12:00\n---\nThis is some sample content\n';\n\n// create a new parser/dumper\n$frontMatter = new FrontMatter();\n\n// parse file contents\n$document = $frontMatter-\u003eparse($fileContent);\n\n// get data\n$document-\u003egetData();\n\n// get content\n$document-\u003egetContent();\n\n// dump the document back to front matter string\n$dump = $frontMatter-\u003edumpDocument($document);\n\n// dump data and content back to front matter string\n$dump = $frontMatter-\u003edump(['foo' =\u003e 'bar'], 'Hello World');\n\n// parse JSON front matter\n$jsonAdapter = new JsonAdapter();\n\n// create new parser/dumper using the json adaptor\n$frontMatter = new FrontMatter($jsonAdapter);\n\n// sample json front matter\n$fileContent = '---\n{\n    \"title\": \"A Title\",\n    \"slug\": \"a-slug\",\n    \"created\": \"2017-01-01 12:00\"\n}\n---\nThis is some sample content\n';\n\n// parse file contents\n$document = $frontMatter-\u003eparse($fileContent);\n```\n\nSymfony Integration\n-------------------\n\nTo enable symfony integration add the bundle to your kernel\n\n```\nnew Tc\\FrontMatter\\Bridge\\Symfony\\TcFrontMatterBundle(),\n```\n\nNow you have access to the front matter service's:\n\n- YAML `tc.front_matter` or `tc.front_matter.yaml`\n- JSON `tc.front_matter.json`\n\nExample:\n\n```php\n\u003c?php\n\nnamespace AppBundle\\Controller;\n\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller;\n\nclass DefaultController extends Controller\n{\n    public function indexAction()\n    {\n        $file = file_get_contents('./path/to/front-matter-file');\n        $document = $this-\u003eget('tc.front_matter')-\u003eparse($file);\n\n        return $this-\u003erender('default/index.html.twig', [\n            'content' =\u003e $document-\u003egetContent(),\n            'data' =\u003e $document-\u003egetData()\n        ]);\n    }\n}\n```\n\nCustom Adapters\n---------------\n\nYou can create your own custom adapters to parse and dump front matter.\n\nAll you need to do is implement `Tc\\FrontMatter\\Adapter\\AdapterInterface`\n\nYou can then create a new instance of front matter using your adapter. e.g.\n\n```php\n\u003c?php\n\n$myFrontMatter = new FrontMatter(new FooAdapter());\n```\n\nIf you are using symfony you can register your adapters as a service,\nand tag them. e.g.\n\n```\nfoo_adapter:\n    class: 'AppBundle\\Adapter\\FooAdapter'\n    tags:\n        - {name: tc.front_matter.adapter, adapter_name: foo}\n```\n\nThe front matter bundle will then auto generate a front matter service for you: `tc.front_matter.foo`\n\n\nLicense\n-------\n\nTc Front Matter is licensed with the MIT license.\n\nSee LICENSE for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlcraig%2Ftc-front-matter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarlcraig%2Ftc-front-matter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlcraig%2Ftc-front-matter/lists"}