PHP Language Improvements and Web Server Capabilities
We're happy to announce two new PHP-related languages:
https://repl.it/languages/php7 - PHP Web servers! Just like other hosted repls, this allows you to write websites using PHP.
https://repl.it/languages/php_cli - PHP Command line interface, in case you still needed it and wanted to use it with multiple files.
In both of these languages, multiple files and syntax highlighting are supported.
Why and How
The early Repl.it product started with humble roots. It used to truly just be nothing more than a repl. The decision to add a multi-line editor was highly controversial... Look at where we are now!
We've had this pretty annoying bug for a while where php files didn't support syntax highlighting. Oh wait, except they did, you just needed a
<?php tag at the beginning. Except that would somehow throw a syntax error. What the heck? Also, why couldn't you have multiple files in PHP? And where were the PHP web servers?
The simple explanation is that we were taking your (single) file contents and running it through
php -r <code>, which runs the code via the command line without script tags (your file contents get put right in
<code>). We sprinkle some repl.it magic here and there to make sure that your program state still existed in the repl, but that's basically the issue.
Trying to include a PHP tag was no good here:
So we decided that enough was enough and it was time to "modernize" the language, so to speak. We created two new PHP languages running on our Polygott (master) image:
https://repl.it/languages/php7 - Your repls here are run with the command
php -S 0.0.0.0:8000 -t . (which is basically using PHP's built in web server to host from the current directory).
https://repl.it/languages/php_cli - Your repls here are run normally (with some polygott magic - feel free to poke through and contribute to the repo!).
In both these languages, you'll get syntax highlighting, because we're no longer running your code with the
-r flag and those opening PHP tags are required (apparently the closing tags are optional). Unfortunately, the repl in the console is no longer available in these languages, but we felt that the PHP community needed multiple files and web servers over a repl.
We hope you enjoy these changes to our PHP languages! If you have any feedback, please feel free to post it here or to leave it on our Feedback boards.