Skip to content

Added StaticPHP framework #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ If you find something wrong with my code, please feel free to send Pull Requests
1. Laravel 5.1.24
1. Zend Framework 2.5.2
1. TYPO3 Flow 3.0.0
1. StaticPHP 0.9.4

## Results

Expand Down Expand Up @@ -170,6 +171,7 @@ If you want to see current configuration, run `sudo sysctl -a`.
* [Radar](https://github.com/radarphp/Radar.Project)
* [Silex](http://silex.sensiolabs.org/)
* [Slim](http://www.slimframework.com/) ([@slimphp](https://twitter.com/slimphp))
* [StaticPHP](https://github.com/gintsmurans/staticphp)
* [Symfony](http://symfony.com/) ([@symfony](https://twitter.com/symfony))
* [How to Deploy a Symfony Application](http://symfony.com/doc/current/cookbook/deployment/tools.html)
* [Tipsy](http://tipsy.la)
Expand Down
1 change: 1 addition & 0 deletions list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ laravel-5.2
zf-2.5
#typo3f-2.3
typo3f-3.0
staticphp-0.9
"
16 changes: 16 additions & 0 deletions staticphp-0.9/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8

end_of_line = lf
insert_final_newline = true

indent_style = space
indent_size = 4

trim_trailing_whitespace = true
19 changes: 19 additions & 0 deletions staticphp-0.9/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/Vendor/
/Application/Cache/
/Application/Public/assets/vendor/
/Application/Public/uploads/
/Application/Public/xhprof/
/Application/Public/docs/


# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
Desktop.ini
94 changes: 94 additions & 0 deletions staticphp-0.9/Application/Config/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

/**
* Default config array
*
* (default value: [])
*
* @var mixed[]
* @access public
*/
$config = [];

/*
|--------------------------------------------------------------------------
| General
|--------------------------------------------------------------------------
*/

$config['base_url'] = null; // NULL for auto detect
$config['disable_twig'] = true; // Option to disable twig template engine


/*
|--------------------------------------------------------------------------
| Debug
|--------------------------------------------------------------------------
*/

// Set environment
$config['env'] = (
(empty($_SERVER['app_env']) || $_SERVER['app_env'] !== 'dev') &&
php_sapi_name() != 'cli-server' ? 'live' : 'dev'
);
$config['debug'] = ($config['env'] !== 'dev' ? false : true);
$config['debug_ips'] = ['::1', '127.0.0.1'];

/*
| Send errors to this email address.
|
| * Core will only send error emails when debug is turned off.
| * Emails are sent using php's mail function, if you intend to use this feature,
| make sure your system is configured to be able to send emails.
*/
$config['debug_email'] = null;

/*
|--------------------------------------------------------------------------
| Web server variables
|
| Set where various variables will be taken from
| In most cases these should work by default
|--------------------------------------------------------------------------
*/

$config['request_uri'] = & $_SERVER['REQUEST_URI'];
$config['query_string'] = & $_SERVER['QUERY_STRING'];
$config['script_name'] = & $_SERVER['SCRIPT_NAME'];
$config['client_ip'] = & $_SERVER['REMOTE_ADDR'];

/*
|--------------------------------------------------------------------------
| Uris
|
| URL prefixes can be useful when for example identifying ajax requests,
| they will be stored in config variable and can be checked with Router::hasPrefix('ajax') === true
| they must be in correct sequence. For example, if url is /ajax/test/en/open/29, where ajax and test is prefixes,
| then array should look something like this - ['ajax', 'test']. In this case /test/en/open/29 will also work.
|--------------------------------------------------------------------------
*/
$config['url_prefixes'] = [];

/*
|--------------------------------------------------------------------------
| Autoload
|
| Place filenames without ".php" extension here to autoload various files and classes
| Possible formats: Application/Module/Filename, Module/Filename, Filename (only to load global config)
|--------------------------------------------------------------------------
*/

$config['autoload_configs'] = [];
$config['autoload_helpers'] = ['Defaults/Bootstrap'];

/*
|--------------------------------------------------------------------------
| Hooks
|
| Currently only "before controller" hook is supported and will be called right
| before including controller file. It passes three parametrs as references - $file,
| $class and $method, meaning callback can override current controller.
|--------------------------------------------------------------------------
*/

$config['before_controller'] = [];
20 changes: 20 additions & 0 deletions staticphp-0.9/Application/Config/Routing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
|--------------------------------------------------------------------------
| Routing
|
| Each next item overrides last one
| Format: 'regular expression'[without starting slash] => 'new URL'
| Leave '' for default controller
|--------------------------------------------------------------------------
*/

$config['routing'] = [

// Default Controller and Method names
'' => 'Defaults/Welcome/index',

// Rest of the routing
# '^([0-9]+)$' => 'orders/details/$1' # Example rewrite: http://example.com/1234 -> http://example.com/orders/details/1234
];
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Defaults\Controllers\Test;

class Test1
{
public static function index()
{
echo 'one ';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Defaults\Controllers\Test;

class TestSecond
{
public static function index()
{
echo 'TestSecond::index: YES';
}

public static function testMe()
{
echo 'TestSecond::testMe: YES';
}
}
11 changes: 11 additions & 0 deletions staticphp-0.9/Application/Modules/Defaults/Controllers/Welcome.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Defaults\Controllers;

class Welcome
{
public static function index()
{
echo 'Hello World!';
}
}
38 changes: 38 additions & 0 deletions staticphp-0.9/Application/Modules/Defaults/Helpers/Bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

// This is the right place to set headers, start a session, etc.

use \Core\Models\Load;

// Send content type and charset header
header('Content-type: text/html; charset=utf-8');


// CLI Access
if (!empty($GLOBALS['argv'][1])) {
Load::$config['request_uri'] =& $GLOBALS['argv'][1];
}


// Set locales
// setlocale(LC_TIME, 'lv_LV.utf8', 'lv_LV.UTF-8');
// setlocale(LC_NUMERIC, 'lv_LV.utf8', 'lv_LV.UTF-8');
// setlocale(LC_CTYPE, 'lv_LV.utf8', 'lv_LV.UTF-8');
// date_default_timezone_set('Europe/Riga');


// Init db - Before uncommenting add at the use secion: "use \Core\Models\Db;"
// Db::init();


// Start session
/*
session_set_cookie_params(0);
session_name('MY_SESSION_NAME');
session_start();
*/


// Load js and css versions. These can be loaded from database or some cache.
load::$config['view_data']['css_version'] = 1;
load::$config['view_data']['js_version'] = 1;
Loading