Tinkerwell 4 is out now! Get the most popular PHP Scratchpad application. Learn more

Laravel Playground

Prefill embeds

Laravel Playground allows you to prefill your embeds. This allows you to keep the code that you want to embed entirely on your own website - say for a blog post.

Let's say that you want to include this piece of PHP code in your blog post:

$slice = Str::of('This is my name')->after('This is');

Laravel Playgrounds prefill embeds can now execute this PHP code for you in a sandboxed environment. This means that you keep your code on your website and Laravel Playground executes and renders it for you.

Here's the example code embedded:

<?php
$slice = Str::of('This is my name')->after('This is');
dd($slice);

The embed code that makes this work is very developer friendly. You can keep your code wrapped in <pre> or <code> blocks on your website and wrap them in a <div> with attributes that control the embed, like this:

<div 
  class="laravel-playground"
  data-height="500px"
>
<pre data-filename="index.php">
&lt;?php
$slice = Str::of('This is my name')->after('This is');
dd($slice);
</pre>
</div>
<script src="https://embed.laravelplayground.com"></script>

Embedding multiple files#

Your prefill embeds can also include multiple files at once. For each file that you want to embed, you can add one <pre> or <code> element with a data-filename attribute that determines the filename that you want to use. Here's an example that loads a file called index.php and a view called embedded.blade.php.

<?php
Route::get('/', function() {
	return view('embedded');
});
<h1>I got embedded!</h1>

To open a different file, click on the arrow icon next to the filename.

This is the code that powers the above embedded playground.

<div 
  class="laravel-playground"
  data-height="500px"
>
<pre data-filename="index.php">
&lt;?php
Route::get('/', function() {
	return view('embedded');
});
</pre>

<pre data-filename="embedded.blade.php">
&lt;h1&gt;I got embedded!&lt;/h1&gt;
</pre>
</div>
<script src="https://embed.laravelplayground.com"></script>

Copy any HTML element from any website

Speed up your workflow with Windy – the browser extension that transforms any HTML element into a Tailwind CSS component.

Learn more
Invoker screenshot