-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1fa75f9
Showing
9 changed files
with
427 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
vendor/ | ||
.vscode/ | ||
app/config/config.php | ||
composer.lock | ||
.vagrant/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Flight PHP Skeleton App Simple Version | ||
|
||
Use this skeleton application to quickly setup and start working on a new Flight PHP application. This application uses the latest version of Flight PHP v3. | ||
|
||
This skeleton application was built for Composer. You also could download a zip of this repo, downloading a zip of the [flightphp/core](https://github.com/flightphp/core) repo, and manually autoload the files by running `require('flight/autoload.php')` in your `app/config/bootstrap.php` file. | ||
|
||
## Installation | ||
|
||
Run this command from the directory in which you want to install your new Flight PHP application. (this will require PHP 7.4 or newer) | ||
|
||
```bash | ||
composer create-project flightphp/skeleton cool-project-name | ||
``` | ||
|
||
Replace `cool-project-name` with the desired directory name for your new application. | ||
|
||
### Simple Setup of the Application | ||
|
||
This is basically a single file application. The only exception to this is the config file which is still in the `app/config/` directory. This is a good starting point for smaller projects or projects that you don't anticipate will grow much. | ||
|
||
To use the simple version, you'll need to copy the `app/config/config_sample.php` file to `app/config/config.php`. | ||
|
||
With the simple setup, there is two very import security steps to be aware of. | ||
- **DO NOT SAVE SENSITIVE CREDENTIALS TO THE `index.php` FILE**. | ||
- **DO NOT COMMIT ANY TYPE OF SENSITIVE CREDENTIALS TO YOUR REPOSITORY**. | ||
|
||
This is what the config file is for. If you need to save sensitive credentials (API keys, database credentials, etc), save them to the config file and then reference them in the `index.php` file. | ||
|
||
### More Complex Application | ||
|
||
If you want to build a more complex application, go to the [flightphp/skeleton](https://github.com/flightphp/skeleton) project for a more robust setup. | ||
|
||
## Running the Application | ||
|
||
### No Dependency Setup | ||
|
||
To run the application in development, you can run these commands | ||
|
||
```bash | ||
cd cool-project-name | ||
composer start | ||
``` | ||
|
||
After that, open `http://localhost:8000` in your browser. | ||
|
||
__Note: If you run into an error similar to this `Failed to listen on localhost:8000 (reason: Address already in use)` then you'll need to change the port that the application is running on. You can do this by editing the `composer.json` file and changing the port in the `scripts.start` key.__ | ||
|
||
### Docker Setup | ||
|
||
You can [install Docker](https://docs.docker.com/engine/install/) and use `docker-compose` to run the app with `docker`, so you can run these commands: | ||
```bash | ||
cd cool-project-name | ||
docker-compose up -d | ||
# or if a newer version of docker | ||
docker compose up -d | ||
``` | ||
After that, open `http://localhost:8000` in your browser. | ||
|
||
### Vagrant Setup | ||
You can [install Vagrant](https://vagrantup.com/download) and a provider like [VirtualBox](https://www.virtualbox.org/wiki/Downloads) and use simple run the following command to bring up an environment with PHP/MariaDB already setup based on [n0nag0n/firefly](https://github.com/n0nag0n/firefly) | ||
|
||
```bash | ||
cd cool-project-name | ||
vagrant up | ||
``` | ||
|
||
After that, open `http://localhost:8000` in your browser. | ||
|
||
## Do it! | ||
That's it! Go build something flipping sweet! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
# All Vagrant configuration is done below. The "2" in Vagrant.configure | ||
# configures the configuration version (we support older styles for | ||
# backwards compatibility). Please don't change it unless you know what | ||
# you're doing. | ||
Vagrant.configure("2") do |config| | ||
# The most common configuration options are documented and commented below. | ||
# For a complete reference, please see the online documentation at | ||
# https://docs.vagrantup.com. | ||
|
||
# Every Vagrant development environment requires a box. You can search for | ||
# boxes at https://vagrantcloud.com/search. | ||
config.vm.box = "n0nag0n/firefly" | ||
|
||
# Disable automatic box update checking. If you disable this, then | ||
# boxes will only be checked for updates when the user runs | ||
# `vagrant box outdated`. This is not recommended. | ||
# config.vm.box_check_update = false | ||
|
||
# Create a forwarded port mapping which allows access to a specific port | ||
# within the machine from a port on the host machine. In the example below, | ||
# accessing "localhost:8080" will access port 80 on the guest machine. | ||
# NOTE: This will enable public access to the opened port | ||
config.vm.network "forwarded_port", guest: 80, host: 8000 | ||
config.vm.synced_folder "./.", "/var/www/", mount_options: ["dmode=777,fmode=777"] | ||
|
||
# Create a forwarded port mapping which allows access to a specific port | ||
# within the machine from a port on the host machine and only allow access | ||
# via 127.0.0.1 to disable public access | ||
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" | ||
|
||
# Create a private network, which allows host-only access to the machine | ||
# using a specific IP. | ||
# config.vm.network "private_network", ip: "192.168.33.10" | ||
|
||
# Create a public network, which generally matched to bridged network. | ||
# Bridged networks make the machine appear as another physical device on | ||
# your network. | ||
# config.vm.network "public_network" | ||
|
||
# Share an additional folder to the guest VM. The first argument is | ||
# the path on the host to the actual folder. The second argument is | ||
# the path on the guest to mount the folder. And the optional third | ||
# argument is a set of non-required options. | ||
# config.vm.synced_folder "../data", "/vagrant_data" | ||
|
||
# Provider-specific configuration so you can fine-tune various | ||
# backing providers for Vagrant. These expose provider-specific options. | ||
# Example for VirtualBox: | ||
# | ||
# config.vm.provider "virtualbox" do |vb| | ||
# # Display the VirtualBox GUI when booting the machine | ||
# vb.gui = true | ||
# | ||
# # Customize the amount of memory on the VM: | ||
# vb.memory = "1024" | ||
# end | ||
# | ||
# View the documentation for the provider you are using for more | ||
# information on available options. | ||
|
||
# Enable provisioning with a shell script. Additional provisioners such as | ||
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the | ||
# documentation for more information about their specific syntax and use. | ||
#config.vbguest.no_install = true | ||
#config.vbguest.auto_reboot = false | ||
|
||
config.vm.provision "shell", inline: <<-SHELL | ||
sed -i 's#DocumentRoot /var/www$#DocumentRoot /var/www/public#g' /etc/apache2/sites-available/000-default.conf | ||
systemctl restart apache2 | ||
SHELL | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
use flight\debug\tracy\TracyExtensionLoader; | ||
use Tracy\Debugger; | ||
|
||
// Set the default timezone | ||
date_default_timezone_set('America/New_York'); | ||
|
||
// Set the error reporting level | ||
error_reporting(E_ALL); | ||
|
||
// Set the default character encoding | ||
if(function_exists('mb_internal_encoding') === true) { | ||
mb_internal_encoding('UTF-8'); | ||
} | ||
|
||
// Set the default locale | ||
if(function_exists('setlocale') === true) { | ||
setlocale(LC_ALL, 'en_US.UTF-8'); | ||
} | ||
|
||
/* | ||
* Set some flight variables | ||
*/ | ||
if(empty($app)) { | ||
$app = Flight::app(); | ||
} | ||
$app->path(__DIR__ . $ds . '..' . $ds . '..'); | ||
$app->set('flight.base_url', '/'); // if this is in a subdirectory, you'll need to change this | ||
$app->set('flight.case_sensitive', false); // if you want case sensitive routes, set this to true | ||
$app->set('flight.log_errors', true); // if you want to log errors, set this to true | ||
$app->set('flight.handle_errors', false); // if you want flight to handle errors, set this to true, otherwise Tracy will handle them | ||
$app->set('flight.views.path', __DIR__ . $ds . '..' . $ds . 'views'); // set the path to your view/template/ui files | ||
$app->set('flight.views.extension', '.php'); // set the file extension for your view/template/ui files | ||
$app->set('flight.content_length', true); // if flight should send a content length header | ||
|
||
/* | ||
* Get Tracy up and running | ||
* | ||
* There lots of setup options for Tracy! Logs, emails, clicking to | ||
* open in your editor and a lot more! | ||
* Check out the docs here: | ||
* https://tracy.nette.org/ | ||
*/ | ||
Debugger::enable(); // auto tries to figure out your environment | ||
// Debugger::enable(Debugger::DEVELOPMENT) // sometimes you have to be explicit (also Debugger::PRODUCTION) | ||
// Debugger::enable('23.75.345.200'); // you can also provide an array of IP addresses | ||
Debugger::$logDirectory = __DIR__ . $ds . 'log'; | ||
Debugger::$strictMode = true; // display all errors | ||
// Debugger::$strictMode = E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED; // all errors except deprecated notices | ||
if (Debugger::$showBar && php_sapi_name() !== 'cli') { | ||
$app->set('flight.content_length', false); // if Debugger bar is visible, then content-length can not be set by Flight | ||
(new TracyExtensionLoader($app)); | ||
} | ||
|
||
/* | ||
* This is where you will store database credentials, api credentials | ||
* and other sensitive information. This file will not be tracked by git | ||
* as you shouldn't be pushing sensitive information to a public or private | ||
* repository. | ||
* | ||
* What you store here is totally up to you. | ||
* | ||
* P.S. When you require a php file and that file returns an array, the array | ||
* will be returned by the require statement where you can assign it to a var. | ||
* Ex: $config = require('config.php'); | ||
*/ | ||
return [ | ||
'database' => [ | ||
'host' => 'localhost', | ||
'dbname' => 'dbname', | ||
'user' => 'root', | ||
'password' => 'root' | ||
], | ||
// 'google_oauth' => [ | ||
// 'client_id' => 'client_id', | ||
// 'client_secret' => 'client_secret', | ||
// 'redirect_uri' => 'redirect_uri' | ||
// ], | ||
]; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "flightphp/skeleton", | ||
"description": "A Flight PHP framework skeleton app to get your new projects up and running ASAP", | ||
"keywords": [ | ||
"microframework", | ||
"rest", | ||
"restapi", | ||
"simple", | ||
"easy", | ||
"lite" | ||
], | ||
"homepage": "https://flightphp.com", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "n0nag0n", | ||
"email": "n0nag0n@sky-9.com" | ||
} | ||
], | ||
"require": { | ||
"php": "^7.4 || ^8.0", | ||
"ext-json": "*", | ||
"flightphp/core": "^3.0" | ||
}, | ||
"config": { | ||
"process-timeout": 0, | ||
"sort-packages": true | ||
}, | ||
"scripts": { | ||
"start": "php -S localhost:8000 -t public" | ||
}, | ||
"require-dev": { | ||
"flightphp/tracy-extensions": "^0.1.2", | ||
"tracy/tracy": "^2.9" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
version: '3.7' | ||
|
||
services: | ||
flight: | ||
image: php:8-alpine | ||
working_dir: /var/www | ||
command: php -S 0.0.0.0:8080 -t public | ||
environment: | ||
docker: "true" | ||
ports: | ||
- "8080:8080" | ||
volumes: | ||
- .:/var/www |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
RewriteEngine On | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteRule ^(.*)$ index.php [QSA,L] | ||
|
||
# BEGIN GZIP | ||
<ifmodule mod_deflate.c> | ||
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript | ||
</ifmodule> | ||
# END GZIP |
Oops, something went wrong.