Writing a PHP App

php

#1

PHP is a popular language for web applications and dynamic websites. You can develop and run your PHP code directly on Cloud9.

Running and Debugging PHP


You can run your PHP application on Cloud9 and use the built-in debugger to inspect your code in real-time. Read the documentation on Running and Debugging Your Code for a more detailed introduction.

There are a few different ways to launch the debugger, depending on the kind of PHP script you’re going to debug:

PHP Web Applications

In this mode, Cloud9 launches the built-in PHP web server, activates the debugger, then opens a preview window.

  • Open the script you want to debug, for example index.php
  • Set at least one breakpoint (optional)
  • Choose Run > Run With > PHP (built-in web server)
<?php
echo 'Hello, World!';

PHP Console Commands

If you have a command line script that you want to debug, you can run it directly using the console runner. In this mode, Cloud9 opens a terminal window, then launches a PHP process with the path to your script.

  • Open the CLI script you want to debug, for example scripts/hello-cli.php
  • Set at least one breakpoint (optional)
  • Choose Run > Run With > PHP (cli)
<?php
if ($argc !== 2) {
    echo "Usage: php hello.php [name].\n";
    exit(1);
}
$name = $argv[1];
echo "Hello, $name\n";

Installed Versions


Newly created Cloud9 workspaces run PHP 5.5 (5.5.9, 64-bit) by default. If you want to run a different version, you can use a tool like php-build to install it manually.

The following extensions are enabled by default:

$ php -v
PHP 5.5.9-1ubuntu4.9 (cli) (built: Apr 17 2015 11:44:57) 

$ php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
libxml
mbstring
mcrypt
mhash
mysql
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

Related topics


Tutorials - Table of Contents
Cannot run PHP cli script
Using Cloud9 on a shared hosting site?
#2

I’m missing how to change the port number, by default it uses port 8080 to start the server. However, I already have another application running on this port.

Currently my ‘nasty’ solution is by changing cloud9/plugins/c9.ide.run/run.js file manually. I change everything saying port = …; to my own port (like 8182). I just always set port to “8182” or returning “8182” as string.


#3

can I use live preview for php, with autoreload after saving?


#4

As far as I’m aware, livereload only works for static files (html, css, js) and won’t reload your server-side code (such as PHP).