-
-
Notifications
You must be signed in to change notification settings - Fork 6
Installation
On Linux and Mac, the following one-liner can be used to install the automated tools and environment:
php -r "readfile('http://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 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
It is recommended, but not required, to have a 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.
The functionality of the main codebase is installed using Composer, packed at https://packagist.org/packages/brightflair/php.gt . 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 MyProject
, then cd MyProject
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 brightflair/php.gt
package needs to be added to the require
block of your project's Composer configuration, pointing to at least version 2.0.0 .
An example composer.json
:
{
"minimum-stability": "dev",
"require": {
"brightflair/php.gt": "dev-master"
}
}
Once the composer.json
file is in place, the install
command will download and install all packages required to run your application, placing the individual code bases inside the vendor
subdirectory. If you have downloaded the Composer phar file to your project directory, install PHP.Gt as a dependency using ./composer.phar install
.
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/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 MyProject && cd MyProject
- Install Composer:
php -r "readfile('https://getcomposer.org/installer');" | php
- Add PHP.Gt as a dependency:
echo "{minimum-stability:'dev', require:{'brightflair/php.gt': 'dev-master'}}" > componser.json
- Install dependencies:
./composer.phar install
- Serve:
vendor/bin/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