Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/php-5.6.wasm
Binary file not shown.
Binary file modified assets/php-7.0.wasm
Binary file not shown.
Binary file modified assets/php-7.1.wasm
Binary file not shown.
Binary file modified assets/php-7.2.wasm
Binary file not shown.
Binary file modified assets/php-7.3.wasm
Binary file not shown.
Binary file modified assets/php-7.4.wasm
Binary file not shown.
Binary file modified assets/php-8.0.wasm
Binary file not shown.
Binary file modified assets/php-8.1.wasm
Binary file not shown.
Binary file modified assets/php-8.2.wasm
Binary file not shown.
3 changes: 0 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
</script>
</head>
<body>
<!-- admax -->
<script src="https://adm.shinobi.jp/o/e2f614fcb49db1ba301801411967d4be"></script>
<!-- admax -->
<div id="app"></div>
</body>
<script type="module" src="/src/index.tsx"></script>
Expand Down
66 changes: 33 additions & 33 deletions src/__test__/__snapshots__/php.test.ts.snap

Large diffs are not rendered by default.

42 changes: 23 additions & 19 deletions src/__test__/php.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,26 @@ describe('load wasm files', async function () {
});
});

describe("show phpinfo()", async function() {
versions.forEach(
function(v) {
it(`version: ${v} run phpinfo().`, async function() {
const data = fs.readFileSync(`assets/php-${v}.wasm`);
const pattern = `php-${v}.wasm?.+`;
mockFetch("GET", new RegExp(pattern)).willResolve(data.buffer);
// Runtime error occurs, but you can ignore it because it is a problem with the way wasm is loaded.
const sut = await initPHP(v);
expect(sut.version).toBe(v);
let actual = await runPHP(sut, "<? phpinfo();")
// Shrink the request time
actual = actual.replace(/(<tr>.+?REQUEST_TIME_FLOAT.+?<td.+?>)([\d.]+)(<\/td><\/tr>)/g, '$1--$3')
actual = actual.replace(/(<tr>.+?REQUEST_TIME.+?<td.+?>)([\d.]+)(<\/td><\/tr>)/g, '$1--$3')
expect(actual).toMatchSnapshot()
})
}
);
})
describe('show phpinfo()', async function () {
versions.forEach(function (v) {
it(`version: ${v} run phpinfo().`, async function () {
const data = fs.readFileSync(`assets/php-${v}.wasm`);
const pattern = `php-${v}.wasm?.+`;
mockFetch('GET', new RegExp(pattern)).willResolve(data.buffer);
// Runtime error occurs, but you can ignore it because it is a problem with the way wasm is loaded.
const sut = await initPHP(v);
expect(sut.version).toBe(v);
let actual = await runPHP(sut, '<? phpinfo();');
// Shrink the request time
actual = actual.replace(
/(<tr>.+?REQUEST_TIME_FLOAT.+?<td.+?>)([\d.]+)(<\/td><\/tr>)/g,
'$1--$3'
);
actual = actual.replace(
/(<tr>.+?REQUEST_TIME.+?<td.+?>)([\d.]+)(<\/td><\/tr>)/g,
'$1--$3'
);
expect(actual).toMatchSnapshot();
});
});
});
12 changes: 10 additions & 2 deletions src/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ export default function Footer() {
</a>
</Text>
<Text as="small" size="xs">
<a href="https://twitter.com/glassmonekey" target="_blank" rel="noreferrer">
<a
href="https://twitter.com/glassmonekey"
target="_blank"
rel="noreferrer"
>
Contact
</a>
</Text>
</HStack>
<Text as="small" size="xs">
&copy; 2023{' '}
<a href="https://twitter.com/glassmonekey" target="_blank" rel="noreferrer">
<a
href="https://twitter.com/glassmonekey"
target="_blank"
rel="noreferrer"
>
@glassmonekey
</a>
</Text>
Expand Down
6 changes: 2 additions & 4 deletions src/header.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Heading, Link, Text, Flex } from "@chakra-ui/react";
import { Heading, Link, Text, Flex } from '@chakra-ui/react';
import * as React from 'react';

export default function Header() {
return (
<Flex gap="8px" direction="column">
<Heading as="h1">
PHP Playground
</Heading>
<Heading as="h1">PHP Playground</Heading>
<Text as="p">
PHP Playground let you to execute basic PHP code in real time
using WebAssembly technology.
Expand Down
183 changes: 91 additions & 92 deletions src/manual.tsx
Original file line number Diff line number Diff line change
@@ -1,97 +1,96 @@
import { Box, Heading, Link, Text, Flex } from "@chakra-ui/react";
import React from "react";
import { Box, Heading, Link, Text, Flex } from '@chakra-ui/react';
import React from 'react';

export default function Manual() {
return (
<Flex gap="16px" direction="column">
<Heading as="h2" id="about">About PHP Playground</Heading>
<Flex as="section" direction="column" gap="8px">
<Heading as="h3">
Description
</Heading>
<Box>
<Text as="p">
The Playground let you to execute basic{" "}
<Link href="https://www.php.net/" isExternal>
PHP
</Link>{" "}
code in real time using WebAssembly technology.
</Text>
<Text as="p">
The code you write can be immediately shared with your
friends via URL.
</Text>
</Box>
</Flex>
return (
<Flex gap="16px" direction="column">
<Heading as="h2" id="about">
About PHP Playground
</Heading>
<Flex as="section" direction="column" gap="8px">
<Heading as="h3">Description</Heading>
<Box>
<Text as="p">
The Playground let you to execute basic{' '}
<Link href="https://www.php.net/" isExternal>
PHP
</Link>{' '}
code in real time using WebAssembly technology.
</Text>
<Text as="p">
The code you write can be immediately shared with your
friends via URL.
</Text>
</Box>
</Flex>

<Flex as="section" direction="column" gap="8px">
<Heading as="h3">
Usage
</Heading>
<Box>
<Text as="p">
Simply enter the PHP code into the form. The result of the
execution output will be displayed in Iframe as HTML.
</Text>
<Text as="p">
Additionally, by selecting a different PHP version from the
select box, you can switch between versions without having
to change the currently running PHP execution code. This
allows you to experience the differences in PHP execution
between different versions.
</Text>
<Text as="p">
The URL parameter is saved with the status when the code is
entered, and can be bookmarked or referred to a friend if
necessary. Please use it to share snippets of your code
review.
</Text>
</Box>
</Flex>
<Flex as="section" direction="column" gap="8px">
<Heading as="h3">
Security
</Heading>
<Box>
<Text as="p">
PHP code is very secure because it is executed only within
the browser using WebAssembly technology.
</Text>
<Text as="p">
In addition, the results of the execution are output to an
iframe using an empty{" "}
<Link
href="https://developer.mozilla.org/ja/docs/Web/HTML/Element/iframe#attr-sandbox"
isExternal
>
sandbox attribute
</Link>
, so no JavaScript or other code will run.{" "}
</Text>
</Box>
</Flex>
<Flex as="section" direction="column" gap="8px">
<Heading as="h3">Usage</Heading>
<Box>
<Text as="p">
Simply enter the PHP code into the form. The result of
the execution output will be displayed in Iframe as
HTML.
</Text>
<Text as="p">
Additionally, by selecting a different PHP version from
the select box, you can switch between versions without
having to change the currently running PHP execution
code. This allows you to experience the differences in
PHP execution between different versions.
</Text>
<Text as="p">
The URL parameter is saved with the status when the code
is entered, and can be bookmarked or referred to a
friend if necessary. Please use it to share snippets of
your code review.
</Text>
</Box>
</Flex>
<Flex as="section" direction="column" gap="8px">
<Heading as="h3">Security</Heading>
<Box>
<Text as="p">
PHP code is very secure because it is executed only
within the browser using WebAssembly technology.
</Text>
<Text as="p">
In addition, the results of the execution are output to
an iframe using an empty{' '}
<Link
href="https://developer.mozilla.org/ja/docs/Web/HTML/Element/iframe#attr-sandbox"
isExternal
>
sandbox attribute
</Link>
, so no JavaScript or other code will run.{' '}
</Text>
</Box>
</Flex>

<Flex as="section" direction="column" gap="8px">
<Heading as="h3">
Request & Report
</Heading>
<Box>
<Text as="p">
If you have any problems or feature requests, please contact{" "}
<Link
href="https://github.com/glassmonkey/php-playground/issues"
isExternal
>
Issue
</Link>{" "}
or{" "}
<Link href="https://twitter.com/glassmonekey" isExternal>
DM
</Link>
.
</Text>
</Box>
</Flex>
</Flex>
);
<Flex as="section" direction="column" gap="8px">
<Heading as="h3">Request & Report</Heading>
<Box>
<Text as="p">
If you have any problems or feature requests, please
contact{' '}
<Link
href="https://github.com/glassmonkey/php-playground/issues"
isExternal
>
Issue
</Link>{' '}
or{' '}
<Link
href="https://twitter.com/glassmonekey"
isExternal
>
DM
</Link>
.
</Text>
</Box>
</Flex>
</Flex>
);
}
Loading