Skip to content
Greg Bowler edited this page Sep 4, 2016 · 41 revisions

On Linux and Mac, the following one-liner can be used to install the automated tools and environment:

php -r "readfile('https://php.gt/install');" | php

Please note that as version 3 is being developed, the automated installer is temporarily unavailable and the Composer method must be used instead. For now, running the above script will just display a friendly message.

The script uses Composer to install all sources to your system, then globally aliases the scripts in the bin directory which are used to automate the creation of new projects, serve your applications locally and deploy to servers.

Once the install script has completed, the following commands will be available inside the terminal:

gt-create MyProject  # Creates a blank project called "MyProject".
gt-serve MyProject   # Serves your new project on localhost:8080.
gt-test MyProject    # Runs all unit and acceptance tests.
gt-deploy MyProject  # Deploys your project online, according to the project config.

It is recommended, but not required, to have one directory on your development computer to use for organising all your web projects. A common location for this is a directory named Sites/ or Web/ in your user's home directory.

When you create a new project using gt-create, the project's files will be created within a new directory, named with the project's name, in the current working directory of your terminal.

Manual installation.

The functionality of the main codebase is installed using Composer, packed at https://packagist.org/packages/phpgt/webengine . Composer is a tool for dependency management for PHP, which allows projects to declare the dependent libraries they need, and the libraries are installed and loaded automatically behind the scenes.

The first thing you need to do to create a project manually is make the directory for the project to live in. Pick somewhere on your system and type mkdir my-project, then cd my-project to enter that directory.

See https://getcomposer.org/download/ for details on how to install Composer. Once Composer is installed, the first (and often only) thing you specify in the composer.json file within your project's root directory is the require key. You're simply telling Composer which packages your project depends on.

The phpgt/webengine package needs to be added to the require block of your project's Composer configuration, pointing to at least version 3.0.0 .

An example composer.json:

{
    "require": {
        "phpgt/webengine": "^3.0.0"
    }
}

Once the composer.json file is in place, the composer install command will download and install all packages required to run your application, placing the individual code bases inside the vendor subdirectory.

To test your project, create an index.html, and place it into the src/page directory within your project's root. To serve the file, navigate to the project's root in the terminal and run vendor/bin/gt-serve, then you can visit http://localhost:8080 in your browser and view the newly-created page. Any errors will be displayed in the terminal running the server.

Quick recap.

To manually install, perform these steps:

  1. Make a directory for your project: mkdir my-project && cd my-project.
  2. Install Composer: php -r "readfile('https://getcomposer.org/installer');" | php.
  3. Add PHP.Gt webengine as a dependency: echo '{"require":{"phpgt/webengine": "^3.0.0"}}' > composer.json.
  4. Install dependencies: ./composer.phar install.
  5. Serve: vendor/bin/gt-serve.

To learn more about what files and directories do what within your application, read the Project layout chapter.

You can use a third-party server to serve your application, which is highly recommended in production. Read more about Serving your application.

Clone this wiki locally