Make sure you have PHP installed on your system. If not, click here for instructions on how to install it for your system.
If you're using Composer, you can run the following command:
composer require flightphp/core
OR you can download the files directly and extract them to your web directory.
This is by far the simplest way to get up and running. You can use the built-in server to run your application and even use SQLite for a database (as long as sqlite3 is installed on your system) and not require much of anything! Just run the following command once PHP is installed:
php -S localhost:8000
Then open your browser and go to http://localhost:8000.
http://localhost:8000
If you want to make the document root of your project a different directory (Ex: your project is ~/myproject, but your document root is ~/myproject/public/), you can run the following command once your in the ~/myproject directory:
~/myproject
~/myproject/public/
php -S localhost:8000 -t public/
Make sure Apache is already installed on your system. If not, google how to install Apache on your system.
For Apache, edit your .htaccess file with the following:
.htaccess
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [QSA,L]
Note: If you need to use flight in a subdirectory add the line RewriteBase /subdir/ just after RewriteEngine On. Note: If you want to protect all server files, like a db or env file. Put this in your .htaccess file:
Note: If you need to use flight in a subdirectory add the line RewriteBase /subdir/ just after RewriteEngine On.
RewriteBase /subdir/
RewriteEngine On
Note: If you want to protect all server files, like a db or env file. Put this in your .htaccess file:
RewriteEngine On RewriteRule ^(.*)$ index.php
Make sure Nginx is already installed on your system. If not, google how to Nginx Apache on your system.
For Nginx, add the following to your server declaration:
server { location / { try_files $uri $uri/ /index.php; } }
<?php // If you're using Composer, require the autoloader. require 'vendor/autoload.php'; // if you're not using Composer, load the framework directly // require 'flight/Flight.php'; // Then define a route and assign a function to handle the request. Flight::route('/', function () { echo 'hello world!'; }); // Finally, start the framework. Flight::start();
If you already have php installed on your system, go ahead and skip these instructions and move to the download section
php
Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install PHP:
brew install php
brew tap shivammathur/php brew install shivammathur/php/[email protected]
Switch between PHP versions:
brew unlink php brew link --overwrite --force [email protected]
php -v
Download PHP:
Extract PHP:
C:\php
Add PHP to the system PATH:
Configure PHP:
php.ini-development
php.ini
extension_dir
Verify PHP installation:
Repeat the above steps for each version, placing each in a separate directory (e.g., C:\php7, C:\php8).
C:\php7
C:\php8
Switch between versions by adjusting the system PATH variable to point to the desired version directory.
Update package lists:
sudo apt update
sudo apt install php
sudo apt install php8.1
Install additional modules (optional):
sudo apt install php8.1-mysql
update-alternatives
sudo update-alternatives --set php /usr/bin/php8.1
Verify the installed version:
Enable the EPEL repository:
sudo dnf install epel-release
Install Remi's repository:
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm sudo dnf module reset php
sudo dnf install php
sudo dnf module install php:remi-7.4
dnf
sudo dnf module reset php sudo dnf module enable php:remi-8.0 sudo dnf install php