Giter VIP home page Giter VIP logo

sagargurnani99 / sg-wordpress-playground Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wordpress/wordpress-playground

0.0 0.0 0.0 539.86 MB

SG's forked repository

Home Page: https://developer.wordpress.org/playground/

License: GNU General Public License v2.0

Shell 0.01% JavaScript 54.53% C 4.14% PHP 0.26% TypeScript 2.69% CSS 35.12% Makefile 0.06% HTML 0.28% CMake 0.05% Dockerfile 0.41% Roff 0.03% SCSS 2.43%

sg-wordpress-playground's Introduction

WordPress Playground and PHP WASM (WebAssembly)

Project Page | Live demo | Documentation and API Reference

WordPress Playground is an experimental in-browser WordPress that runs without a PHP server thanks to the magic of WebAssembly.

Why is WordPress Playground useful?

WordPress Playground is a building block that can power apps like:

  • Runnable code snippets in your documentation or course
  • Plugin and theme demos in a private WordPress instance where the user is already logged in as an admin
  • Easily switching PHP and WordPress version when testing
  • Replaying and fixing the failed CI tests right in the browser

See the WordPress.org announcement post to learn more about the vision.

WordCamp Contributor Day

If you're participating in a WordCamp Contributor Day, you can use the following instructions to get started: WordCamp Contributor Day.

Getting started

WordPress Playground has a live demo available.

You can embed WordPress Playground in your project via an <iframe> – find out how in the documentation. Note the embed is experimental and may break or change without a warning.

You can connect to the Playground using the JavaScript client. Here's an example of how to do it in the browser using an iframe HTML element and the startPlaygroundWeb function from the @wp-playground/client package.

index.html:

<!DOCTYPE html>
<html>
	<head>
		<title>WordPress Playground</title>
	</head>
	<body>
		<iframe id="wp" style="width: 1200px; height: 800px"></iframe>
		<script type="module">
			import { startPlaygroundWeb } from 'https://unpkg.com/@wp-playground/client/index.js';

			const client = await startPlaygroundWeb({
				iframe,
				remoteUrl: `https://playground.wordpress.net/remote.html`,
				blueprint: {
					landingPage: '/wp-admin/',
					preferredVersions: {
						php: '8.0',
						wp: 'latest',
					},
					steps: [
						{
							step: 'login',
							username: 'admin',
							password: 'password',
						},
						{
							step: 'installPlugin',
							pluginZipFile: {
								resource: 'wordpress.org/plugins',
								slug: 'friends',
							},
						},
					],
				},
			});

			const response = await client.run({
				code: '<?php echo "Hi!"; ',
			});
			console.log(response.text);
		</script>
	</body>
</html>

Cloning the repo

The vanilla git clone command will take ages. Here's a faster alternative that will only pull the latest revision of the trunk branch:

git clone -b trunk --single-branch --depth 1 [email protected]:WordPress/wordpress-playground.git

Contributing

You also can run WordPress Playground locally as follows:

git clone -b trunk --single-branch --depth 1 [email protected]:WordPress/wordpress-playground.git
cd wordpress-playground
npm install
npm run dev

A browser should open and take you to your very own client-side WordPress at http://127.0.0.1:5400/!

Any changes you make to .ts files will be live-reloaded. Changes to Dockerfile require a full rebuild.

From here, the documentation will help you learn how WordPress Playground works and how to use it to build amazing things!

And here's a few more interesting CLI commands, which expect that you have nx installed globally:

# Build and run PHP.wasm CLI
nx start php-wasm-cli

# Build latest WordPress releases
nx recompile-wordpress:all playground-remote

# Recompile PHP 5.6 - 8.2 releases to .wasm for web
nx recompile-php:all php-wasm-web

# Recompile PHP 5.6 - 8.2 releases to .wasm for node
nx recompile-php:all php-wasm-node

# Builds the documentation site
nx build docs-site

# Builds the Playground Client npm package
nx build playground-client

# Bonus: Run PHP.wasm in your local CLI:
npx @php-wasm/cli -v
PHP=7.4 npx @php-wasm/cli -v
npx @php-wasm/cli phpcbf

Backwards compatibility

This experimental software may break or change without a warning. Releasing a stable API is an important future milestone that will be reached once the codebase is mature enough.

Prior art

WordPress Playground forked the original PHP to WebAssembly build published in https://github.com/oraoto/pib and modified later in https://github.com/seanmorris/php-wasm.

Another strong inspiration was the Drupal in the browser demo which proved you can run non-trivial PHP software in the browser.

A worthy mention is Wasm Labs’s closed-source WordPress in the browser shared before this project was first published. There is no public repository available, but their technical overview gives a breakdown of the technical decisions that project took. WordPress Playground draws inspiration from the same PHP in the browser projects and makes similar technical choices.

WordPress Playground Tools

WordPress Playground Tools are independent applications built on top of WordPress Playground. They are located in a different repository: WordPress/playground-tools.

These tools include:

Contributing

WordPress Playground is an ambitious project in its early days. If the feature you need is missing, you are more than welcome to start a discussion, open an issue, and even propose a Pull Request to implement it.

sg-wordpress-playground's People

Contributors

adamziel avatar sejas avatar danielbachhuber avatar artemiomorales avatar eliot-akira avatar wojtekn avatar gziolo avatar kozer avatar stevendufresne avatar soean avatar dd32 avatar katinthehatsite avatar akirk avatar t-hamano avatar elchead avatar ahmadawais avatar ebinnion avatar intelrunner avatar johnkennyuk avatar palmiak avatar mpkelly avatar michalczaplinski avatar sc0ttkclark avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.