-
-
Notifications
You must be signed in to change notification settings - Fork 6
Installation
The following one-liner can be used to install the automated tools and environment:
php -r "readfile('https://php.gt/install');" | php
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, unit test your code, and deploy to servers.
Once the install script has completed, the following commands will be available inside the terminal:
gt-create my-project blog # Creates a project called "my-project" with the "blog" blueprint.
gt-serve my-project # Serves your new project on localhost:8080.
gt-test my-project # Runs all unit and acceptance tests.
gt-deploy my-project # Deploys your project, according to the project config.
gt-release my-project v1.0.5 # Stages a new live release for your project from the latest deployment.
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.
When inside the project's directory, the project name can be dropped from gt-*
commands as it is automatically inferred.
For more information about the gt-*
commands, read the gt commands chapter.
The functionality of the main codebase is installed using Composer, packaged 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, you need to specify the webengine as a required dependency. This can be done automatically with the command composer require phpgt/webengine
which will pick the latest released version.
This command creates a composer.json
file and fills it in for you. If you prefer, you can create the file yourself with the following contents:
{
"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.
To manually install, perform these steps:
- Make a directory for your project:
mkdir my-project && cd my-project
. - Install Composer:
php -r "readfile('https://getcomposer.org/installer');" | php
. - Add PHP.Gt webengine as a dependency:
composer require phpgt/webengine
. - Create your first page at
src/page/index.html
. - 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.
- Request-response lifecycle
- Running your application
- Project layout
- Application architecture
- Web servers
- URIs
- Page view
- Dynamic URIs and pages
- Headers and footers
- Page logic
- Protected globals
- User input
- Cookies
- Sessions
- DOM manipulation
- Custom HTML components
- DOM templates
- Binding data to the DOM
- Database
- Client side assets
- API Webservices
- Security
- Configuration
- Build system
- Coding styleguide