1. Create a PHP Project

Start Che, create a PHP project using a sample app:


2. Explore and Modify the Project Code

The sample project contains just a simple “Hello World!” script written in PHP.

Expand the project’s source tree in the Project Explorer panel on the left side of the screen. Double-click on the index.php file to open it in the PHP editor.

The index.php file contains a single instruction that will print “Hello World!” to the standard output.


echo "Hello World!";

You can use the editor to edit the script. The PHP editor provides rich IntelliSense features like syntax hightlighting, code completion, code validation, code navigation, etc.

3. Execute as a Script

The PHP stack has the run php script command that allows you to run the currently opened PHP file as a CLI script, i.e. the output of the PHP script will be printed in the Terminal panel.

While you have the index.php file on focus in the PHP editor, run the run php script command in the CMD command widget. “Hello World!” will be printed in the Terminal panel.


4. Run as a Web App

The PHP stack includes the Apache Web Server and has commands for starting, stopping and restarting it.

start apache will start the server and tail apache error and access logs. It will also produce a preview URL that will point to your current project directory that Apache is already listening (Document root is changed to projects).

You should see a Hello World page. Open index.php, edit it, refresh the preview page in your browser to see live changes.


5. Debug

The PHP stack includes the Zend Debugger module, which allows debugging PHP both as CLI script and Web app. See the Debug - PHP page for details.

6. Composer and Unit Tests

A PHP stack has Composer already installed and configured. Composer is used to manage project dependencies, i.e. makes it easy to use 3rd party libs and frameworks. Look at the Composer tutorial for more details on how to work with Composer in Che.

Let’s add the PHPUnit testing framework and write a simple Unit test.

In project root, create composer.json file with the following contents:

    "require-dev": {
        "phpunit/phpunit": "^6.1"

The JSON editor provides IntelliSense too. It provides code completion and validation according to the composer.json schema.

In the Processes panel, click New Terminal (+) button. This will open up a bash terminal:

$ cd /projects/web-php-simple
$ composer update

This will install the phpunit framework into vendor directory in the project.

Now, let’s write a simple test. Create a test.php file:


use PHPUnit\Framework\TestCase;

class SimpleTest extends TestCase {

    public function testTrueIsTrue() {
        $foo = true;

This test basically checks nothing but demonstrates use of composer-provided frameworks.

Run the test. Right-click on the test.php file and select Run Test > PHPUnit. The test will be executed and the result will be displayed in the Test Results pane.