-
-
Notifications
You must be signed in to change notification settings - Fork 5
Quick start
This page is the shortest route from a fresh machine to a running WebEngine application. If you want more background on installation choices, see Installation. Here we will keep to the fastest useful path first.
The gt command is the small command line wrapper around the normal tasks of starting, building, and testing a WebEngine project. If you have not installed it yet, follow the short install route:
curl https://install.php.gt | shOnce that is done, run gt on its own. If a command list appears, the tooling is ready.
To create a new project, choose a directory where you keep your code and run:
gt create my-first-appBy default this creates a minimal WebEngine project with the standard directory layout and a starter page. You can also choose a namespace and blueprint via command line arguments, otherwise gt will interactively ask you how to proceed.
gt create my-first-app --namespace App --blueprint Hello-WorldThe project name becomes the directory on disk. The namespace controls the PHP namespace used for classes in the project. A blueprint is a starter project shape. If you omit it, you get an empty application scaffold.
If you prefer not to use gt create, you can still create a project by hand:
mkdir my-first-app
cd my-first-app
composer require phpgt/webengineFrom there you can create a file at page/index.html with whatever contents you like.
From the project root, run:
gt runThis starts the local development server and, where needed, also runs the build watcher and cron watcher for the project. In a tiny starter app those extra pieces do very little, but once the application grows they become part of the normal development loop.
If you only want the PHP server, use:
gt serveWithout gt, the local server can still be started with PHP's local development server: php -S 0.0.0.0:8080 vendor/phpgt/webengine/go.php -t www.
With some page content inside page/index.html and the server running on port 8080, visit http://localhost:8080/ and you should see your page.
That is the static-first approach in its simplest form: begin with plain HTML, check the page in a browser, and add PHP when the page needs dynamic behaviour. The page at page/index.html is visiable at http://localhost:8080/ (the filename "index" is assumed), and you can create any other page name such as page/example.html that will be visible at http://localhost:8080/example/
Check out the gt command overview, or move on to building our first page in Hello World tutorial.
- File-based routing
- Page views
- Page logic
- Dynamic URIs
- Headers and footers
- Custom HTML components
- Page partials
- Binding data to the DOM
- DOM manipulation
- Hello You tutorial
- Todo list tutorial
- Address book tutorial WIP
- Blueprints
- Application architecture
- Coding styleguide WIP
- PHP environment setup WIP
- Web servers WIP
- Background cron tasks
- Database setup WIP
- Client-side compilation WIP
- Testing WebEngine applications WIP
- Production checklist WIP
- Security WIP