Recently, I found a site called PHPSandbox that allows users to create PHP applications that can be run in the same way as applications on CodePen. This includes using composer to inject dependencies into the application and a nice little editor interface to see the output and logs from the application.
This is where PHPSanbox come in. It allows you to create PHP projects that you can then execute to see the output using PHP 7.4 or 8.0 (at time of writing).
You can define the normal things you need for a PHP application like environment variables and composer packages. PHPSandbox also gives you the ability to create applications from skeleton examples using frameworks like Symfony and Slim. Each application you create is called a notebook and can be shared or downloaded easily. Once set up you will have a fully functioning PHP environment that you can develop simple applications with included composer dependencies. If your application outgrows the site then you can always download it and work on it from there.
It is also possible to link PHPSandbox to your GitHub account to allow code to be pulled directly from GitHub into notebooks. I wasn't able to get this working as the permissions created would allow the site any access to any repo I have access to, which includes a few private repositories belonging to companies. I think this is how GitHub permissions work though, and not a problem with PHPSandbox. For a beginner this shouldn't be a problem, I just couldn't accept the risk here.
What PHPSandbox doesn't come with is PHP extensions like the GD2 library, which means you are unable to generate image files. It does have access to Sqlite database so it's possible to plug your applications into a data source.
Each notebook supports a few different mechanisms to allow them to be embedded. The example below if using the iframe embed option (although I had to tweak some of the variables to get it to work correctly).
By running the above code you can see the evolution engine I have been working on (and am currently writing some articles about). All I did was to ensure the package was included as a dependency and then start writing code. If you click the "Run" button on the right you can see the result in the output window.
This can solve an issue on some sites where PHP examples are present, but there is no way to run them. You can't run every example as the sandbox you are given isn't a complete environment, but it will run standard PHP code without any issues.
I've been very impressed with what I have seen here and I would suggest giving PHPSandbox a go.