Installation
Downloading
PHP Jet is distributed as a complete package containing both the library itself and all the tools, as well as a sample application including the installer. This package can be downloaded here.
You can also use composer to download it:
composer create-project mirekmarek/php-jet
PHP Jet has no dependencies on any other libraries, and does not require any PHP modules that cannot be considered completely standard by default.
Quick Testing
If you just want to get a feel for PHP Jet, this is the easiest way to go:
- Make sure you have PHP 8 installed, including all the standard modules.
- Go to the directory where you have downloaded and unzipped PHP Jet.
- Start:
php _playground/start.php
- In your browser, open the URL http://localhost:8000/ (unless you specified a different address and port when you started the playground).
- Finish the installation using the web installer.
Full installation
Jet is a framework designed for PHP8 and later only. Thus, you will definitely need a test environment with this version of PHP.
PHP Jet itself and applications based on it are developed, tested and run in practice on two types of web servers Apache and NGINX. It is probably possible to run on another web server (e.g. IIS) without any problems.
It is also worth mentioning that Jet is primarily developed and run in the GNU/Linux OS world, but it is certainly possible to run it on Windows (used in practice by colleagues) and of course other Unix systems such as MacOS X, BSD and so on.
I assume you know how to install and configure the mentioned web servers, PHP itself, PHP modules, MySQL/MariaDB and so on. Therefore, I will focus on the necessary web server setup and the installation of Jet (or the Jet sample application) itself.
Basics
When developing applications, we follow a process where each project has its own virtual within the web server. This is both on the individual developers' machines and of course on the development and test server. Each project can (and usually does) have its own specific conditions, longevity and so on. That's why we try to simulate the conditions of the future real deployment of the project right from the beginning of the development.
That's why we create a "dummy domain" and a hosts file entry for each project. And each project has its own virtual within the web server.
In practice, I've known developers who had everything within one directory and when they wanted to test their project they would type the URL http://localhost/muj-projekt-1/ into the browser.
It would probably be possible to do this with Jet applications as well, but here we will describe the procedure where each project has its own virtual.
So, in preparation for running on your local machine, you need to:
- Make sure you have PHP8 or later.
- Use the hosts file entry to create a "dummy domain".
- Create a directory dedicated to Jet and extract the Jet package into it.
- Ideally, create a separate test database (MySQL/MariaDB or PostgreSQL). However, the built-in support for SQLite may be sufficient for the purpose of getting familiar with Jet - if that is enough to get you started, then you don't need to create a test database.
- Configure the web server (see below).
- In the browser, open that dummy URL and go through the installer of the sample application.
- Start getting familiar with the world of PHP Jet ;-)
Setting up an Apache web server
You probably already know how to create a virtual within Apache, or you can learn from the documentation of this web server.
PHP Jet does not need anything other than enabled mod_rewrite to run with the Apache web server (see your system documentation).
A caution for a possible catch with the need to enable AllowOverride All!
Setting up an NGINX web server
The term "virtual" belongs, of course, to the world of Apache web servers (which is older, however, and so the term has sort of "caught on"). NGINX uses the term "server block".
To run Jet (or your projects already built on Jet), you need to create such a server block.
Below you will find an example of what such a server block should look like:
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
server_name jet.lc;
root /home/user/projects/Jet;
index index.html;
location ~ /\.ht {
deny all;
}
location ~ ^/(css|js|images)/ {
try_files $uri $uri/ =404;
}
location / {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/application/bootstrap.php;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
}
location ~ ^/_tools/studio/(css|js|images)/ {
try_files $uri $uri/ =404;
}
location /_tools/studio/ {
include fastcgi_params;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
}
}
Notes on the NGINX "server block":
- Of course, you have to set the server_name and root parameters according to the situation on your computer.
- An example involves the use of SSL certificates for local testing, which are offered by NGINX itself. Of course, these must not be used in live operation.
- Also, the "location" associated with the Jet Studio tool (/_tools/studio/) shouldn't exist at all on a live server, just like the tool itself.