From 2f980360087ef443219199868ad5487c3b7da774 Mon Sep 17 00:00:00 2001 From: Cody Phillips Date: Sat, 4 Apr 2015 20:18:52 -0700 Subject: [PATCH 1/9] Updated PHP requirement --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 75b9d1c..a12b2dc 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,11 @@ minPHP is an extremely lightweight MVC framework for PHP application development. +**Caution:** This repository is for minPHP 1.0, see [minPHP 0.x](https://github.com/phillipsdata/minphp/tree/0.x) for the previous version. + ## Requirements ## -* PHP 5.1.3 or greater +* PHP 5.3.0 or greater ## Getting Started ## From e907b1ae163f09d04b0cc401fb2ea2ce9ab546de Mon Sep 17 00:00:00 2001 From: Cody Phillips Date: Sun, 5 Apr 2015 15:50:32 -0700 Subject: [PATCH 2/9] composer autoload fixes #10 --- .gitignore | 3 ++- .travis.yml | 10 +++++++++- composer.json | 39 +++++++++++++++++++++++++++++++++++++++ phpunit.xml.dist | 28 ++++++++++++++++++++++++++++ src/lib/autoload.php | 1 + src/lib/init.php | 3 +-- src/lib/loader.php | 9 +-------- 7 files changed, 81 insertions(+), 12 deletions(-) create mode 100644 composer.json create mode 100644 phpunit.xml.dist diff --git a/.gitignore b/.gitignore index 63aaea3..4bfa32f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ - +composer.lock +vendor/* build/* .DS_Store diff --git a/.travis.yml b/.travis.yml index ab77279..709969f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,4 +4,12 @@ php: - 5.4 - 5.5 - 5.6 -script: phpunit -c ./build/phpunit.xml --coverage-text \ No newline at end of file + - 7.0 + - hhvm +before_script: + - composer install --dev +script: + - ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml + - ./vendor/bin/phpcs --extensions=php --report=summary --standard=PSR2 ./src ./tests +after_script: + - php ./vendor/bin/coveralls -v \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..aa15466 --- /dev/null +++ b/composer.json @@ -0,0 +1,39 @@ +{ + "name": "minphp/minphp", + "description": "An extremely lightweight MVC framework", + "homepage": "http://github.com/phillipsdata/minphp", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Cody Phillips", + "email": "therealclphillips@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "minphp/cache": "dev-master", + "minphp/configure": "dev-master", + "minphp/container": "dev-master", + "minphp/date": "dev-master", + "minphp/form": "dev-master", + "minphp/html": "dev-master", + "minphp/input": "dev-master", + "minphp/language": "dev-master", + "minphp/pagination": "dev-master", + "minphp/xml": "dev-master" + }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.2", + "satooshi/php-coveralls": "dev-master" + }, + "autoload": { + "classmap": [ + "src/app", + "src/components", + "src/helpers", + "src/lib" + ] + } +} \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..618ed1a --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,28 @@ + + + + + + + tests + + + + + + + + + + + + src + + + diff --git a/src/lib/autoload.php b/src/lib/autoload.php index 9d650a6..46d55d1 100644 --- a/src/lib/autoload.php +++ b/src/lib/autoload.php @@ -1,2 +1,3 @@ Date: Mon, 6 Apr 2015 20:06:51 -0700 Subject: [PATCH 3/9] Pull build status from 1.0 branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a12b2dc..e227c22 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # minPHP # -[![Build Status](https://travis-ci.org/phillipsdata/minphp.svg)](https://travis-ci.org/phillipsdata/minphp) +[![Build Status](https://travis-ci.org/phillipsdata/minphp.svg?branch=1.0)](https://travis-ci.org/phillipsdata/minphp) minPHP is an extremely lightweight MVC framework for PHP application development. From 9e9f529dc3f77fee13d4606cac6b764e58975150 Mon Sep 17 00:00:00 2001 From: Cody Phillips Date: Mon, 6 Apr 2015 20:07:48 -0700 Subject: [PATCH 4/9] removed PSR2 enforcement for now --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 709969f..8169886 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,5 @@ before_script: - composer install --dev script: - ./vendor/bin/phpunit --coverage-text --coverage-clover ./build/logs/clover.xml - - ./vendor/bin/phpcs --extensions=php --report=summary --standard=PSR2 ./src ./tests after_script: - php ./vendor/bin/coveralls -v \ No newline at end of file From a32e526fb1086511205aa10c2652493248bbdeed Mon Sep 17 00:00:00 2001 From: Cody Phillips Date: Mon, 6 Apr 2015 21:13:28 -0700 Subject: [PATCH 5/9] Removed closing tag --- src/lib/cache.php | 1 - src/lib/configure.php | 1 - src/lib/controller.php | 1 - src/lib/dispatcher.php | 1 - src/lib/init.php | 7 ++++--- src/lib/language.php | 1 - src/lib/loader.php | 1 - src/lib/model.php | 1 - src/lib/stdlib.php | 1 - src/lib/unknown_exception.php | 2 -- src/lib/view.php | 1 - 11 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/lib/cache.php b/src/lib/cache.php index af6b979..18eea9f 100644 --- a/src/lib/cache.php +++ b/src/lib/cache.php @@ -88,4 +88,3 @@ private static final function cacheName($name, $path=null) { return CACHEDIR . $path . md5(strtolower($name)) . Configure::get("Caching.ext"); } } -?> \ No newline at end of file diff --git a/src/lib/configure.php b/src/lib/configure.php index fa2ca51..e3e9099 100644 --- a/src/lib/configure.php +++ b/src/lib/configure.php @@ -100,4 +100,3 @@ public static function errorReporting($level) { error_reporting($level); } } -?> \ No newline at end of file diff --git a/src/lib/controller.php b/src/lib/controller.php index dee77c5..e479adb 100644 --- a/src/lib/controller.php +++ b/src/lib/controller.php @@ -322,4 +322,3 @@ protected final function setDefaultViewPath($path) { $this->structure->setDefaultView($path); } } -?> \ No newline at end of file diff --git a/src/lib/dispatcher.php b/src/lib/dispatcher.php index a7eb2a2..5f00f53 100644 --- a/src/lib/dispatcher.php +++ b/src/lib/dispatcher.php @@ -193,4 +193,3 @@ private static function cleanGlobals() { } } } -?> \ No newline at end of file diff --git a/src/lib/init.php b/src/lib/init.php index 2057125..df36400 100644 --- a/src/lib/init.php +++ b/src/lib/init.php @@ -18,9 +18,11 @@ error_reporting(-1); /** - * Sets the version of minPHP in use. [Major].[Minor].[Revision].[Build.RC] + * Sets the version of minPHP in use. [Major].[Minor].[Revision] + * + * @deprecated since 1.0.0 */ -define("MINPHP_VERSION", "0.11.3.20131004"); +define("MINPHP_VERSION", "1.0.0"); /** * Sets the directory separator used throughout the application. DO NOT use this @@ -118,4 +120,3 @@ include_once LIBDIR . "stdlib.php"; // Include core configuration include_once CONFIGDIR . "core.php"; -?> \ No newline at end of file diff --git a/src/lib/language.php b/src/lib/language.php index 4cc44a0..edaf4ad 100644 --- a/src/lib/language.php +++ b/src/lib/language.php @@ -156,4 +156,3 @@ public static final function setLang($language) { return $prev_lang; } } -?> \ No newline at end of file diff --git a/src/lib/loader.php b/src/lib/loader.php index 61903b6..a155618 100644 --- a/src/lib/loader.php +++ b/src/lib/loader.php @@ -268,4 +268,3 @@ private static function loadAndInitialize(&$parent, $type, $objects) { } } } -?> \ No newline at end of file diff --git a/src/lib/model.php b/src/lib/model.php index 216de32..fdecc8e 100644 --- a/src/lib/model.php +++ b/src/lib/model.php @@ -279,4 +279,3 @@ private function lazyConnect() { } } } -?> \ No newline at end of file diff --git a/src/lib/stdlib.php b/src/lib/stdlib.php index cc7ccd6..c9d25ea 100644 --- a/src/lib/stdlib.php +++ b/src/lib/stdlib.php @@ -31,4 +31,3 @@ * @see UnknownException::setFatalErrorHandler() */ register_shutdown_function(array("UnknownException", "setFatalErrorHandler")); -?> \ No newline at end of file diff --git a/src/lib/unknown_exception.php b/src/lib/unknown_exception.php index a8a7113..b32cfa7 100644 --- a/src/lib/unknown_exception.php +++ b/src/lib/unknown_exception.php @@ -69,5 +69,3 @@ public static function setFatalErrorHandler() { } } } - -?> \ No newline at end of file diff --git a/src/lib/view.php b/src/lib/view.php index bcc2669..1f88c1e 100644 --- a/src/lib/view.php +++ b/src/lib/view.php @@ -150,4 +150,3 @@ private function getViewPath($view=null) { return array($view_path, $view); } } -?> \ No newline at end of file From 0ce59dfef212c6dd9a24e4586a57ba7734cad413 Mon Sep 17 00:00:00 2001 From: Cody Phillips Date: Mon, 6 Apr 2015 21:16:24 -0700 Subject: [PATCH 6/9] Removed closing tag --- src/app/app_controller.php | 1 - src/app/app_model.php | 1 - src/app/controllers/404.php | 2 -- src/app/controllers/main.php | 1 - src/components/acl/acl.php | 1 - src/components/input/input.php | 1 - src/components/record/record.php | 1 - src/components/session/session.php | 1 - src/config/core.php | 2 -- src/config/database.php | 1 - src/config/routes.php | 1 - src/config/session.php | 1 - src/index.php | 1 - 13 files changed, 15 deletions(-) diff --git a/src/app/app_controller.php b/src/app/app_controller.php index 1c381e8..e258d77 100644 --- a/src/app/app_controller.php +++ b/src/app/app_controller.php @@ -12,4 +12,3 @@ class AppController extends Controller { # (e.g. $this->loadLang("langfile", "en_us")) # } -?> \ No newline at end of file diff --git a/src/app/app_model.php b/src/app/app_model.php index 6677037..ded1b9f 100644 --- a/src/app/app_model.php +++ b/src/app/app_model.php @@ -10,4 +10,3 @@ class AppModel extends Model { # models that extend this class. # } -?> \ No newline at end of file diff --git a/src/app/controllers/404.php b/src/app/controllers/404.php index b149361..b478538 100644 --- a/src/app/controllers/404.php +++ b/src/app/controllers/404.php @@ -9,5 +9,3 @@ class _404 extends AppController { } - -?> \ No newline at end of file diff --git a/src/app/controllers/main.php b/src/app/controllers/main.php index 37e4a71..12fe275 100644 --- a/src/app/controllers/main.php +++ b/src/app/controllers/main.php @@ -7,4 +7,3 @@ class Main extends AppController { } -?> \ No newline at end of file diff --git a/src/components/acl/acl.php b/src/components/acl/acl.php index 4d03f11..f61b2bd 100644 --- a/src/components/acl/acl.php +++ b/src/components/acl/acl.php @@ -278,4 +278,3 @@ private function addAcl($aro_id, $aco_id, $action, $permission) { set("action", $action)->set("permission", $permission)->insert("acl_acl"); } } -?> \ No newline at end of file diff --git a/src/components/input/input.php b/src/components/input/input.php index ac8f481..abe5b0f 100644 --- a/src/components/input/input.php +++ b/src/components/input/input.php @@ -589,4 +589,3 @@ private static function clearLeaves(&$data) { $data = null; } } -?> \ No newline at end of file diff --git a/src/components/record/record.php b/src/components/record/record.php index 5a7d4d3..79945eb 100644 --- a/src/components/record/record.php +++ b/src/components/record/record.php @@ -1436,4 +1436,3 @@ public function quoteIdentifier($identifier) { return implode(".", $parts); } } -?> \ No newline at end of file diff --git a/src/components/session/session.php b/src/components/session/session.php index cc2017c..ab23abd 100644 --- a/src/components/session/session.php +++ b/src/components/session/session.php @@ -292,4 +292,3 @@ private function sessionGarbageCollect($lifetime) { return $this->Record->affectedRows(); } } -?> \ No newline at end of file diff --git a/src/config/core.php b/src/config/core.php index b036d39..017b0b2 100644 --- a/src/config/core.php +++ b/src/config/core.php @@ -57,5 +57,3 @@ // Set to true to allow keys with no definition to be output, set to false to // output nothing if the key is not found. Configure::set("Language.allow_pass_through", false); - -?> \ No newline at end of file diff --git a/src/config/database.php b/src/config/database.php index b4c1d26..82e8c91 100644 --- a/src/config/database.php +++ b/src/config/database.php @@ -44,4 +44,3 @@ unset($default); unset($server); -?> \ No newline at end of file diff --git a/src/config/routes.php b/src/config/routes.php index 2245009..a6f2071 100644 --- a/src/config/routes.php +++ b/src/config/routes.php @@ -18,4 +18,3 @@ * example: $1, $2, ... $n. */ -?> \ No newline at end of file diff --git a/src/config/session.php b/src/config/session.php index e9f4e22..67bffa1 100644 --- a/src/config/session.php +++ b/src/config/session.php @@ -20,4 +20,3 @@ Configure::set("Session.session_name", "sid"); // Whether or not enable HTTP only session cookies Configure::set("Session.session_httponly", true); -?> \ No newline at end of file diff --git a/src/index.php b/src/index.php index a87599d..ddc2f74 100644 --- a/src/index.php +++ b/src/index.php @@ -43,4 +43,3 @@ // Display rendering time if benchmarking is enabled if (Configure::get("System.benchmark")) echo "execution time: " . ($end-$start) . " seconds"; -?> \ No newline at end of file From c588d3451eddcc27c1a84bbbef58e65244ca52fe Mon Sep 17 00:00:00 2001 From: Cody Phillips Date: Mon, 6 Apr 2015 21:24:37 -0700 Subject: [PATCH 7/9] Removed closing tag --- src/helpers/date/date.php | 1 - src/helpers/form/form.php | 1 - src/helpers/html/html.php | 2 -- src/helpers/javascript/javascript.php | 1 - src/helpers/pagination/pagination.php | 1 - src/helpers/xml/xml.php | 1 - 6 files changed, 7 deletions(-) diff --git a/src/helpers/date/date.php b/src/helpers/date/date.php index 25b09d1..a8db2a5 100644 --- a/src/helpers/date/date.php +++ b/src/helpers/date/date.php @@ -390,4 +390,3 @@ private function mergeArrays(array $arr1, array $arr2) { return $arr1; } } -?> \ No newline at end of file diff --git a/src/helpers/form/form.php b/src/helpers/form/form.php index 6b743ad..dab230b 100644 --- a/src/helpers/form/form.php +++ b/src/helpers/form/form.php @@ -625,4 +625,3 @@ private function inArray($needle, array $haystack, $strict=false) { return false; } } -?> \ No newline at end of file diff --git a/src/helpers/html/html.php b/src/helpers/html/html.php index bb0af1d..aac1ed4 100644 --- a/src/helpers/html/html.php +++ b/src/helpers/html/html.php @@ -203,5 +203,3 @@ public function hyperlink($content) { return preg_replace($pattern, $replacement, $content); } } - -?> \ No newline at end of file diff --git a/src/helpers/javascript/javascript.php b/src/helpers/javascript/javascript.php index 47c832f..4a7a285 100644 --- a/src/helpers/javascript/javascript.php +++ b/src/helpers/javascript/javascript.php @@ -127,4 +127,3 @@ public function unsetInline() { return $this; } } -?> \ No newline at end of file diff --git a/src/helpers/pagination/pagination.php b/src/helpers/pagination/pagination.php index 45c5c85..17876df 100644 --- a/src/helpers/pagination/pagination.php +++ b/src/helpers/pagination/pagination.php @@ -444,4 +444,3 @@ private function output($html) { echo $html; } } -?> \ No newline at end of file diff --git a/src/helpers/xml/xml.php b/src/helpers/xml/xml.php index 03951c4..5ead471 100644 --- a/src/helpers/xml/xml.php +++ b/src/helpers/xml/xml.php @@ -119,4 +119,3 @@ private function buildXmlSegment($value, $root_node="result", $tab_count=-1) { return $xml; } } -?> \ No newline at end of file From 33aaa39c14fefb3fb40cd5c2518d9a7414fe4c07 Mon Sep 17 00:00:00 2001 From: Cody Phillips Date: Tue, 14 Apr 2015 20:46:13 -0700 Subject: [PATCH 8/9] integrated minphp/language --- src/config/core.php | 2 - src/lib/language.php | 184 ++++++++----------------------------------- 2 files changed, 33 insertions(+), 153 deletions(-) diff --git a/src/config/core.php b/src/config/core.php index 017b0b2..c487bc0 100644 --- a/src/config/core.php +++ b/src/config/core.php @@ -1,8 +1,6 @@ 2) { - $args = array_slice(func_get_args(), 2, $argc-1); - // If printf args are passed as an array use those instead. This - // is the case, by default, if Language::_() was used. - if (is_array($args[0])) - $args = $args[0]; - array_unshift($args, $output); + self::setDefaultLanguage(Configure::get('Language.default')); + parent::loadLang($lang_file, $language, $lang_dir); - $output = call_user_func_array("sprintf", $args); - } - - if ($return) - return $output; - echo $output; - } - - /** - * Loads a language file whose properties may then be invoked. - * - * @param mixed $lang_file A string as a single language file or array containing a list of language files to load - * @param string $language The ISO 639-1/2 language to load the $lang_file for (e.g. en_us), default is "Language.default" config value - * @param string $lang_dir The directory from which to load the given language file(s), defaults to LANGDIR - */ - public static final function loadLang($lang_file, $language=null, $lang_dir=LANGDIR) { - if ($language == null) - $language = self::$current_language; - - if (is_array($lang_file)) { - $num_lang_files = count($lang_file); - for ($i=0; $i<$num_lang_files; $i++) - self::loadLang($lang_file[$i], $language, $lang_dir); - return; - } - - // Check if the language file in this language has already been loaded - if (isset(self::$lang_files[$lang_dir . $lang_file]) && in_array($language, self::$lang_files[$lang_dir . $lang_file])) - return; - - $load_success = true; - - // Fetch $lang from the language file, if it exists - if (file_exists($lang_dir . $language . DS . $lang_file)) - include_once $lang_dir . $language . DS . $lang_file; - elseif (file_exists($lang_dir . $language . DS . $lang_file . ".php")) - include_once $lang_dir . $language . DS . $lang_file . ".php"; - else - $load_success = false; - - if ($load_success) { - self::$lang_files[$lang_dir . $lang_file][] = $language; - - if (isset($lang) && is_array($lang)) { - - if (!isset(self::$lang_text[$language])) - self::$lang_text[$language] = array(); - - // Set the text for this language - foreach ($lang as $key => $text) - self::$lang_text[$language][$key] = $text; - - // Load the text for the default language as well so we have that to fall back on - if ($language != Configure::get("Language.default")) - self::loadLang($lang_file, Configure::get("Language.default"), $lang_dir); - } - // free up memory occupied by the $lang array, since it has already - // been loaded into the appropriate class variable - unset($lang); - } - // If the language just attemped did not load and this is the was not the - // default language, then attempt to load the default language - elseif ($language != Configure::get("Language.default")) - self::loadLang($lang_file, Configure::get("Language.default"), $lang_dir); - } - - /** - * Sets the language to load when not explicitly defined in the requested method - * - * @param string $language The ISO 639-1/2 language to use (e.g. en_us) for all future requests if not explicitly given to the requested method - * @return string The previously set language, null if not previously defined - */ - public static final function setLang($language) { - $prev_lang = self::$current_language; - - self::$current_language = $language; - - return $prev_lang; - } + self::setDefaultLanguage($default_language); + } } From 49b28b60fdbbc8fe7051a66788188828dd4c0a0b Mon Sep 17 00:00:00 2001 From: Cody Phillips Date: Tue, 14 Apr 2015 20:58:56 -0700 Subject: [PATCH 9/9] load core config --- src/lib/init.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/init.php b/src/lib/init.php index df36400..e710fb3 100644 --- a/src/lib/init.php +++ b/src/lib/init.php @@ -118,5 +118,5 @@ // Include core libraries include_once LIBDIR . "autoload.php"; include_once LIBDIR . "stdlib.php"; -// Include core configuration -include_once CONFIGDIR . "core.php"; +// Load core configuration +Configure::load("core");