On Tue, Oct 13, 2020, at 6:56 PM, tyson andre wrote:
> Hi internals,
> 
> > As far as php.net can help with PHP's reputation, I think a brief homepage
> > intro that showcased some modern-looking PHP code would be great (e.g.
> > typescriptlang.org, golang.org). The docs design could also be
> > slightly tweaked to make everything seem newer, while still keeping the
> > (very good) content basically the same.
> 
> That reminds me of an idea I had a while ago:
> One of the features I've seen on many other programming
> languages' documentation and tutorials was the ability to run and edit 
> the example snippets.
> It may help in understanding the content of tutorials or example 
> snippets for functions,
> - e.g. seeing what happens if code is rearranged
>   or how PHP handles edge cases
> - It also allows new developers to try out php before deciding to 
> install it.
> 
> Right now, you can read the examples in 
> https://www.php.net/manual/en/language.variables.scope.php
> and copy them to run them locally, but you can't run them and see their 
> output
> (as plain text or html, depending on context)
> 
> Some examples in other languages:
> 
> - MDN has JavaScript demos in the browser, e.g. 
>   
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some
> - Rust has https://play.rust-lang.org/ (run on the server side)
> - golang has https://tour.golang.org/welcome/1 (run on the server side)
> 
> There's two main options available for testing out php in a browser right now:
> 
> - A general sandboxed php implementation hosted by the owners of php.net
>   (requires that it be secured and may lead to additional hosting 
> costs),
>   https://3v4l.org/ (not open source https://3v4l.org/about - but 
> similar to what I was thinking of)
>   or https://psalm.dev/ (open source) are projects in that area
>   (Matthew Brown is one of the authors of Psalm)
> - A WebAssembly solution, e.g. https://phan.github.io/demo/ (forked 
> from https://oraoto.github.io/pib/)
>   (I'm one of the maintainers of Phan)
> 
> WebAssembly has some noticeable drawbacks such as requiring a modern 
> browser,
> requiring a large download, and requiring more RAM than an ordinary 
> website.
> Many other websites for programming languages have moved to sandboxed 
> implementations
> hosted on an actual server.
> 
> Thanks,
> - Tyson

This sounds like a fantastic idea.  The inline-run capability of Go and Rust's 
documentation is a huge win.  Writing good sample code for the documentation 
would be an interesting challenge, but it's the sort of thing that can be done 
over time.

The interesting question would be how to configure it to ensure it doesn't 
become a security issue.  We'd probably need to lock down the environment's ini 
settings *hard* to make sure it can't do any outgoing communication at all.

If we need hosting for that, I work for a hosting company and we're happy to 
help.

--Larry Garfield

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to