Skip to content

Commit

Permalink
Merge pull request #115 from TwistPHP/development
Browse files Browse the repository at this point in the history
Release of v3.1.0
  • Loading branch information
danrwalker committed Jul 2, 2017
2 parents 722c43f + 1f7f358 commit 3dfa0b3
Show file tree
Hide file tree
Showing 88 changed files with 4,488 additions and 7,570 deletions.
33 changes: 30 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
.idea
node_modules
# --- OS --- #
.DS_Store

# --- JETBRAINS --- #
.idea

# --- VAGRANT --- #
.vagrant

# --- LOGS --- #
*.log
docs/resources

# --- DEMO --- #
demo/public/app/Assets/*
!demo/public/app/Assets/.htaccess
demo/public/app/Cache
demo/public/app/Controllers/*
!demo/public/app/Controllers/DEMO_*
demo/public/app/Logs
demo/public/app/Models/*
!demo/public/app/Models/DEMO_*
demo/public/app/Packages
demo/public/app/Resources/*
!demo/public/app/Resources/.htaccess
demo/public/app/Views/*
!demo/public/app/Views/DEMO_*

# --- JS DOC RESOURCES --- #
docs/resources

# --- NODE MODULES --- #
node_modules
27 changes: 14 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
language: php

php:
- 5.5
env GULP=ON
- 5.6
env COVERALLS=ON
- 7.0
env GULP=ON
- 7
- nightly

services:
Expand All @@ -20,27 +19,29 @@ mysql:
encoding: utf8

before_install:
- mysql -V
- mysql -e "CREATE DATABASE IF NOT EXISTS travis_ci_twist_test;"
- mysql -e "SHOW DATABASES"
- if [ "$GULP" = 'ON' ]; then npm install; fi;
- mysql -V
- mysql -e "CREATE DATABASE IF NOT EXISTS travis_ci_twist_test;"
- mysql -e "SHOW DATABASES"
- if [ "$GULP" = 'ON' ]; then nvm install 6.10&&npm install; fi;

install:
- if [ "$COVERALLS" = 'ON' ]; then composer require satooshi/php-coveralls '~1.0'; fi;
- composer require phpunit/phpunit:5.6
- php ./tests/install.php

before_script:
- mkdir -p ./build/logs
- mysql -e "USE travis_ci_twist_test; SHOW TABLES;"
- sed -i 's/Twist::ServeRoutes(false);/echo "TwistPHP Framework Loaded!\n\n";/g' ./tests/index.php
- mkdir -p ./build/logs
- mysql -e "USE travis_ci_twist_test; SHOW TABLES;"
- sed -i 's/Twist::ServeRoutes(false);/echo "TwistPHP Framework Loaded!\n\n";/g' ./tests/index.php
- if ["$GULP" = 'ON' ]; then npm install -g gulp; fi;

script:
- phpunit
- if [ "$GULP" = 'ON' ]; then gulp test; fi;
- if [ "$GULP" = 'ON' ]; then gulp test; fi;
- vendor/bin/phpunit

notifications:
on_success: never
on_failure: always

after_success:
- if [ "$COVERALLS" = 'ON' ]; then ./vendor/bin/coveralls -v; fi;
- if [ "$COVERALLS" = 'ON' ]; then ./vendor/bin/coveralls -v; fi;
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ One line is all it takes:
require_once( 'twist/framework.php' );
```

## Vagrant

To get started with a Vagrant machine:

* Install [Vagrant](https://www.vagrantup.com/downloads.html)
* Install [VirtualBox](https://www.virtualbox.org/)
* Run `vagrant up`
* Load up [localhost:8080](http://localhost:8080/)
* You can SSH into the Vagrant server with `vagrant ssh`

## Documentation

Full documentation of the framework can be found on the [TwistPHP website](https://twistphp.com/docs).
Expand Down
17 changes: 17 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.synced_folder ".", "/vagrant"
config.vm.provision :shell, path: "demo/setup.sh"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 3306, host: 3306, host_ip: "127.0.0.1"

config.vm.provider "virtualbox" do |v|
v.memory = 1024
end
end
442 changes: 442 additions & 0 deletions demo/demo.sql

Large diffs are not rendered by default.

109 changes: 109 additions & 0 deletions demo/public/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# TWISTPHP
# ================================================================================
# TwistPHP - Default .htaccess
#
# All the options in this .htaccess can be edited within the farmework manager
#
# DO NOT REMOVE!
# --------------------------------------------------------------------------------
# Author: Shadow Technologies Ltd.
# Licence: https://www.gnu.org/licenses/gpl.html GPL License
# Documentation: https://twistphp.com/docs
# Note: Do not edit information inside the '# TWISTPHP' tags
# ================================================================================

# An index.html will supersede Twist (if it exists)
DirectoryIndex index.php index.html index.htm

RewriteEngine on

# Custom HTAccess rules that have been setup in the manager


# www redirect when enabled in the settings
#RewriteCond %{HTTP_HOST} ^www\.
#RewriteRule ^(.*)$ http://%{REQUEST_URI} [L,R=301]

# HTTPS redirect when enabled in the settings
#RewriteCond %{HTTPS} on
#RewriteRule ^(.*)$ http://%{REQUEST_URI} [L,R=301]

# Rewrite rules that have been setup in the manager


# Disable directory browsing
Options All -Indexes

# Disable access to HTaccess and HTpass filesincluding any other files that might end in hta or htp
<Files ~ "^.*\.([Hh][Tt][AaPp])">
order allow,deny
deny from all
satisfy all
</Files>

# Disallow a list of file extensions form being served
<Files ~ "^.*\.(bash|git|hg|log|svn|swp|cvs)">
order allow,deny
deny from all
satisfy all
</Files>

# Disable hotlinking of images with extensions (jpg|jpeg|png|gif|svg)
#RewriteCond %{HTTP_REFERER} !^$
#RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?/.*$ [NC]
#RewriteRule \.(jpg|jpeg|png|gif|svg)$ http:///hotlink.gif [R,L]

# Disable PHP files from being run within the Uploads directory
RewriteRule ^uploads/.*\.(?:php[1-6]?|pht|phtml?)$ - [NC,F]

# Filter suspicious query strings in the URL
RewriteCond %{QUERY_STRING} \.\.\/ [NC,OR]
RewriteCond %{QUERY_STRING} etc/passwd [NC,OR]
RewriteCond %{QUERY_STRING} boot\.ini [NC,OR]
RewriteCond %{QUERY_STRING} ftp\: [NC,OR]
RewriteCond %{QUERY_STRING} http\: [NC,OR]
RewriteCond %{QUERY_STRING} https\: [NC,OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [NC,OR]
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(%24&x).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(127\.0).* [NC]
RewriteRule ^.* - [F]

# Rewrite rules to allow routing
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]

# Set the cache-control max-age
#<FilesMatch "\.(html|htm)$">
# Header set Cache-Control "max-age=0, must-revalidate"
# Header unset Last-Modified
#</FilesMatch>

#<FilesMatch "\.(css|map)$">
# Header set Cache-Control "max-age=0, public, must-revalidate"
# Header unset Last-Modified
#</FilesMatch>

#<FilesMatch "\.(js)$">
# Header set Cache-Control "max-age=0, public, must-revalidate"
# Header unset Last-Modified
#</FilesMatch>

#<FilesMatch "\.(ico|pdf|flv|jpg|png|gif|swf|svg)$">
# Header set Cache-Control "max-age=0, public, must-revalidate"
# Header unset Last-Modified
#</FilesMatch>

# Turn off the ETags
#Header unset ETag
#FileETag None

# Deflate diffrent files by content type
#AddOutputFilterByType DEFLATE text/html
#AddOutputFilterByType DEFLATE text/css
#AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
#AddOutputFilterByType DEFLATE image/jpg image/png image/svg image/svg+xml

# /TWISTPHP
4 changes: 4 additions & 0 deletions demo/public/app/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Refuse direct access to all files and folders
Order deny,allow
Deny from all
Allow from 127.0.0.1
2 changes: 2 additions & 0 deletions demo/public/app/Assets/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Allow direct access to Assets
Allow from all
39 changes: 39 additions & 0 deletions demo/public/app/Config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* TwistPHP - An open source PHP MVC framework built from the ground up.
* Copyright (C) 2016 Shadow Technologies Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author Shadow Technologies Ltd. <contact@shadow-technologies.co.uk>
* @license https://www.gnu.org/licenses/gpl.html GPL License
* @link https://twistphp.com
*/

/**
* Database Configuration Settings
* TWIST_DATABASE_NAME - The name of your primary database
* TWIST_DATABASE_HOST - Host IP / Name of the database server
* TWIST_DATABASE_USERNAME - Username to use whilst connecting to the database
* TWIST_DATABASE_PASSWORD - Password to use whilst connecting to the database
* TWIST_DATABASE_PROTOCOL - Select the protocol to use (mysql,mysqli) default: mysqli
* TWIST_DATABASE_TABLE_PREFIX - Prefix that will be applied to all tables installed by Twist
*/
Twist::define('TWIST_DATABASE_NAME','twistphp');
Twist::define('TWIST_DATABASE_HOST','localhost');
Twist::define('TWIST_DATABASE_USERNAME','root');
Twist::define('TWIST_DATABASE_PASSWORD','twistphp');
Twist::define('TWIST_DATABASE_PROTOCOL','mysqli');
Twist::define('TWIST_DATABASE_TABLE_PREFIX','twist_');
12 changes: 12 additions & 0 deletions demo/public/app/Controllers/DEMO_HelloWorld.controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Controllers;
use \Twist\Core\Controllers\Base;

class DEMO_HelloWorld extends Base {

public function _index() {
return $this -> _view( 'DEMO_welcome.tpl' );
}

}
5 changes: 5 additions & 0 deletions demo/public/app/Models/DEMO_Books.model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

class Books {

}
2 changes: 2 additions & 0 deletions demo/public/app/Resources/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Allow direct access to Resources
Allow from all
1 change: 1 addition & 0 deletions demo/public/app/Views/DEMO_welcome.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Welcome! What a beautiful {date:l} it is :)</p>
26 changes: 26 additions & 0 deletions demo/public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/* ================================================================================
* TwistPHP Demo
* --------------------------------------------------------------------------------
* Author: Shadow Technologies Ltd.
* Licence: https://www.gnu.org/licenses/gpl.html GPL License
* Documentation: https://twistphp.com/docs
* ================================================================================
*/

//Define the globals required
define( 'TWIST_PUBLIC_ROOT', '/vagrant/demo/public' );
define( 'TWIST_APP', './app' );

//Include TwistPHP
require_once '../../dist/twist/framework.php';

//Define a controller
Twist::Route()->controller( '/%', 'DEMO_HelloWorld' );

//Register the framework manager
Twist::Route()->manager( '/manager' );

//Serve all registered routes
Twist::ServeRoutes();

0 comments on commit 3dfa0b3

Please sign in to comment.