Skip to content

Commit 2efbf58

Browse files
Merge pull request #31 from php-debugger/home-cards
update the quick start and key features cards
2 parents 8604526 + 9a1aa83 commit 2efbf58

4 files changed

Lines changed: 76 additions & 41 deletions

File tree

‎src/components/HomeCards/index.js‎

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,46 @@
1+
import {useEffect, useState} from 'react';
12
import Link from '@docusaurus/Link';
23
import CodeBlock from '@theme/CodeBlock';
4+
import {PLATFORMS, detectPlatform} from '@site/src/lib/installer';
35
import styles from './styles.module.css';
46

5-
const quickStartSnippet = `# php.ini
6-
zend_extension=php_debugger
7+
function quickStartSnippet(command) {
8+
return `# Install\n${command}\n\n# Debug\nphp your-script.php`;
9+
}
10+
11+
/* Shows the command for the visitor's own OS. The page is prerendered without
12+
knowing it, so this starts on the Unix command and corrects itself after
13+
mounting -- detecting in an effect rather than during render keeps the first
14+
client render identical to the server's, which is what hydration compares. */
15+
function QuickStartSnippet() {
16+
const [platform, setPlatform] = useState('macos');
17+
18+
useEffect(() => {
19+
const detected = detectPlatform();
20+
if (detected) {
21+
setPlatform(detected);
22+
}
23+
}, []);
24+
25+
const active = PLATFORMS.find((p) => p.id === platform) ?? PLATFORMS[0];
726

8-
# Run your script
9-
XDEBUG_TRIGGER=1 php your-script.php`;
27+
return (
28+
<CodeBlock language={active.language}>
29+
{quickStartSnippet(active.command)}
30+
</CodeBlock>
31+
);
32+
}
1033

1134
const keyFeatures = [
12-
'Interactive CLI debugger',
13-
'Breakpoints & conditional breakpoints',
14-
'Step over, into, and out',
15-
'Inspect variables and expressions',
16-
'Exception handling',
17-
'Logging and error handling',
35+
'Always on — no trigger to set',
36+
'Near-zero overhead when idle',
37+
'Line, conditional and exception breakpoints',
38+
'Step into, over and out',
39+
'Inspect variables across the call stack',
40+
'Watch expressions and live value edits',
1841
];
1942

20-
const ides = ['PhpStorm', 'VS Code'];
43+
const ides = ['PhpStorm', 'VS Code', 'Any other editor with PHP debugging'];
2144

2245
function Card({icon, title, children, linkTo, linkLabel}) {
2346
return (
@@ -42,8 +65,9 @@ export default function HomeCards() {
4265
title="Quick Start"
4366
linkTo="/getting-started/quick-start"
4467
linkLabel="View quick start guide">
45-
<p>Get up and running in seconds.</p>
46-
<CodeBlock language="ini">{quickStartSnippet}</CodeBlock>
68+
<p>Install it. There is nothing to configure.</p>
69+
<QuickStartSnippet />
70+
<p>Start your editor listening, set a breakpoint, run your code.</p>
4771
</Card>
4872
<Card
4973
icon={

‎src/components/HomeCards/styles.module.css‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,10 @@
9797
grid-template-columns: minmax(0, 1fr);
9898
}
9999
}
100+
101+
/* The installer URL is longer than the card is wide. Wrapping keeps the whole
102+
command visible and copyable rather than clipping it at the card edge. */
103+
.cardBody :global(.theme-code-block) code {
104+
white-space: pre-wrap;
105+
overflow-wrap: anywhere;
106+
}

‎src/components/InstallCommand/index.js‎

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import {useEffect, useRef, useState} from 'react';
22
import clsx from 'clsx';
33
import CodeBlock from '@theme/CodeBlock';
4+
import {PLATFORMS, detectPlatform} from '@site/src/lib/installer';
45
import styles from './styles.module.css';
56

6-
/* macOS and Linux run the same script -- it detects the OS and architecture
7-
itself -- so both tabs deliberately show the same command. */
8-
const UNIX_COMMAND =
9-
'curl -fsSL https://github.com/php-debugger/installer/releases/latest/download/install.sh | sh';
10-
const WINDOWS_COMMAND =
11-
'powershell -c "irm https://github.com/php-debugger/installer/releases/latest/download/install.ps1 | iex"';
12-
137
const iconProps = {
148
width: 15,
159
height: 15,
@@ -35,27 +29,6 @@ const CheckIcon = () => (
3529
</svg>
3630
);
3731

38-
const PLATFORMS = [
39-
{id: 'macos', label: 'macOS', language: 'bash', command: UNIX_COMMAND},
40-
{id: 'linux', label: 'Linux', language: 'bash', command: UNIX_COMMAND},
41-
{id: 'windows', label: 'Windows', language: 'powershell', command: WINDOWS_COMMAND},
42-
];
43-
44-
function detectPlatform() {
45-
const ua = navigator.userAgent;
46-
if (/Windows/i.test(ua)) {
47-
return 'windows';
48-
}
49-
if (/Mac OS X|Macintosh/i.test(ua)) {
50-
return 'macos';
51-
}
52-
/* Android reports Linux too, and the command is the same either way. */
53-
if (/Linux|Android|X11/i.test(ua)) {
54-
return 'linux';
55-
}
56-
return null;
57-
}
58-
5932
export default function InstallCommand() {
6033
/* The page is prerendered without knowing the visitor's OS, so start on macOS
6134
and correct it after mounting. Detecting in an effect rather than during

‎src/lib/installer.js‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* The installer commands and OS detection, shared by the Installation page's
2+
InstallCommand component and the home page's Quick Start card so the two can
3+
never drift apart. */
4+
5+
/* macOS and Linux run the same script -- it detects the OS and architecture
6+
itself -- so both platforms deliberately use the same command. */
7+
export const UNIX_COMMAND =
8+
'curl -fsSL https://github.com/php-debugger/installer/releases/latest/download/install.sh | sh';
9+
export const WINDOWS_COMMAND =
10+
'powershell -c "irm https://github.com/php-debugger/installer/releases/latest/download/install.ps1 | iex"';
11+
12+
export const PLATFORMS = [
13+
{id: 'macos', label: 'macOS', language: 'bash', command: UNIX_COMMAND},
14+
{id: 'linux', label: 'Linux', language: 'bash', command: UNIX_COMMAND},
15+
{id: 'windows', label: 'Windows', language: 'powershell', command: WINDOWS_COMMAND},
16+
];
17+
18+
export function detectPlatform() {
19+
const ua = navigator.userAgent;
20+
if (/Windows/i.test(ua)) {
21+
return 'windows';
22+
}
23+
if (/Mac OS X|Macintosh/i.test(ua)) {
24+
return 'macos';
25+
}
26+
/* Android reports Linux too, and the command is the same either way. */
27+
if (/Linux|Android|X11/i.test(ua)) {
28+
return 'linux';
29+
}
30+
return null;
31+
}

0 commit comments

Comments
 (0)