Skip to content

Commit f8758d6

Browse files
committed
Improve SEO of doc pages
1 parent ec02f90 commit f8758d6

41 files changed

Lines changed: 265 additions & 8 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/.vitepress/config.mts‎

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from 'vitepress'
1+
import { defineConfig, type HeadConfig } from 'vitepress'
22
import { withMermaid } from 'vitepress-plugin-mermaid'
33

44
export default withMermaid(
@@ -91,7 +91,7 @@ export default withMermaid(
9191
? (frontmatterImage.startsWith('http') ? frontmatterImage : `${siteUrl}${frontmatterImage.replace(/^\//, '')}`)
9292
: `${siteUrl}og-default.png`;
9393

94-
return [
94+
const headTags: HeadConfig[] = [
9595
['link', { rel: 'canonical', href: canonicalUrl }],
9696
['meta', { property: 'og:site_name', content: 'TypePHP' }],
9797
['meta', { property: 'og:type', content: pageData.relativePath.startsWith('blog/') ? 'article' : 'website' }],
@@ -110,6 +110,45 @@ export default withMermaid(
110110
['meta', { name: 'twitter:description', content: pageDescription }],
111111
['meta', { name: 'twitter:image', content: imageUrl }],
112112
];
113+
114+
if (pageData.relativePath === 'troubleshooting.md') {
115+
headTags.push([
116+
'script',
117+
{ type: 'application/ld+json' },
118+
JSON.stringify({
119+
'@context': 'https://schema.org',
120+
'@type': 'FAQPage',
121+
mainEntity: [
122+
{
123+
'@type': 'Question',
124+
name: 'What is the difference between TypePHP (typephp/typephp) and Swoole TypePHP?',
125+
acceptedAnswer: {
126+
'@type': 'Answer',
127+
text: 'TypePHP (typephp/typephp on Packagist, typephp.dev) is a 100% pure-PHP 8.1+ Composer library that enforces PHPDoc contracts, reified generics, array shapes, and typestates at runtime on standard PHP and frameworks like Laravel, Symfony, and Shopware. Swoole TypePHP is a separate Ahead-of-Time compiler that translates a PHP subset into C++ native binaries.',
128+
},
129+
},
130+
{
131+
'@type': 'Question',
132+
name: 'Does TypePHP work with Laravel, Symfony, Pest, and PHPUnit?',
133+
acceptedAnswer: {
134+
'@type': 'Answer',
135+
text: 'Yes. TypePHP hooks into Composer autoloading automatically and works as a drop-in across Laravel, Symfony, Shopware, WordPress, Pest, and PHPUnit with zero C-extensions or build steps.',
136+
},
137+
},
138+
{
139+
'@type': 'Question',
140+
name: 'Can I run TypePHP alongside PHPStan or Psalm?',
141+
acceptedAnswer: {
142+
'@type': 'Answer',
143+
text: 'Yes. PHPStan and Psalm verify static code structure at compile time, while TypePHP enforces those same PHPDoc contracts at runtime against live dynamic data, database rows, API payloads, and generic containers.',
144+
},
145+
},
146+
],
147+
}),
148+
]);
149+
}
150+
151+
return headTags;
113152
},
114153

115154
markdown: {

‎docs/advanced/compile-time-elimination.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: "Compile-Time AST Check Elimination"
3+
description: "How TypePHP eliminates runtime assertion wrappers at load time for proven literals, folded arithmetic, $this returns, enums, shapes, and generators."
4+
---
5+
16
# Compile-Time Check Elimination
27

38
A common concern with runtime type enforcement is performance overhead. If every return statement, variable assignment, and property initialization were blindly wrapped in runtime assertions, high-frequency functions and tight loops would suffer from unnecessary Zend VM function-call overhead.

‎docs/advanced/exception-handling.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: "Exception Handling (TypePHP\\Exception\\TypeError)"
3+
description: "Catch TypePHP\\Exception\\TypeError or native \\TypeError for call-site stack trace attribution and clean HTTP 422 API payload validation responses."
4+
---
5+
16
# Exception Handling
27

38
If you run TypePHP in live production applications especially for validating external HTTP API payloads, webhooks, or dynamic database records and catching `TypePHP\Exception\TypeError` gives you a clean way to intercept data validation failures gracefully without letting exceptions crash your application.

‎docs/advanced/extensions.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: "Building TypePHP Extensions"
3+
description: "Create reusable TypePHP extensions implementing ExtensionInterface to bundle vendor path whitelists and stub files with safe include-only isolation."
4+
---
5+
16
# Building Extensions
27

38
TypePHP provides an Extension System that allows third-party package authors and framework integrations to automatically register path whitelists and pre-verified stub files so end-users can benefit from type checking without writing manual include paths or stub configuration in `typephp.php`.

‎docs/advanced/how-it-works.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: "How TypePHP Works (StreamWrapper & Load-Time Weaving)"
3+
description: "Inside TypePHP's pure-PHP architecture: file:// StreamWrapper interception, compile-time AST elimination, callee-side contracts, zero line-drift, and WeakMap state."
4+
---
5+
16
# How It Works
27

38
TypePHP provides transparent, zero-overhead runtime type enforcement without custom C-extensions or modified PHP binaries. It operates entirely in PHP user-land by combining native stream interception, compile-time AST analysis, bytecode caching, and in-memory generic state tracking.

‎docs/advanced/ignore-annotations.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: "Ignore Annotations (@typephp-ignore)"
3+
description: "Selectively skip runtime type checking on legacy methods, properties, files, or downstream call stacks with @typephp-ignore and @typephp-ignore-file."
4+
---
5+
16
# Ignore Annotations (`@typephp-ignore`)
27

38
TypePHP provides docblock suppression tags to skip type enforcement on legacy code, un-refactored methods, performance-critical loops, or test callers without requiring you to remove PHPDoc annotations.

‎docs/advanced/stubs.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: "Stub Files (Third-Party Vendor Overrides)"
3+
description: "Override or fix inaccurate PHPDoc contracts and generic variance in third-party Composer packages using .stub files without editing vendor/."
4+
---
5+
16
<script setup>
27
const paramStubFiles = {
38
'index.php': `<?php

‎docs/advanced/vendor-and-path-filtering.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: "Vendor Isolation & Path Filtering"
3+
description: "Control which PHP files TypePHP instruments using longest-match glob specificity, single-file overrides, and vendor DocBlock isolation."
4+
---
5+
16
<script setup>
27
const vendorExclusionFiles = {
38
'index.php': `<?php

‎docs/blog/index.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
2+
title: "TypePHP Engineering Blog & Release Notes"
3+
description: "Deep dives, performance benchmarks, case studies, and release notes on pure-PHP runtime type checking, reified generics, typestates, and Zend Engine optimization."
24
layout: doc
35
sidebar: false
46
aside: false

‎docs/core-concepts/by-reference-contracts.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
title: "By-Reference Contracts & Mutations"
3+
description: "Guard PHP reference boundaries at runtime: &$param entry checks, @param-out exit contracts, variable and property aliasing, foreach loops, and array_walk."
4+
---
5+
16
# By-Reference Contracts & Mutations
27

38
In standard PHP, references (`&`) create Zend Engine `zval` aliases (`IS_REFERENCE`). Historically, references have been the single most common loophole in dynamic validation systems: once a reference is created, modifying the alias bypasses standard variable assignment interceptors.

0 commit comments

Comments
 (0)