Permalink
Browse files

Added PHP MVC structure

  • Loading branch information...
1 parent 4c819c2 commit 985f92ac84de260a1d52b02dbdc51fb71a02990d @rajibmp committed Feb 6, 2013
View
@@ -2,4 +2,5 @@
### 1.0 alpha
* Forked Version 4.1.0 from [HTML5 Boilerplate] (https://github.com/h5bp/html5-boilerplate)
-* Updated Readme, Licence, Contribute to suit our need.
+* Updated Readme, Licence, Contribute to suit our need.
+* Added PHP support and MVC pattern
File renamed without changes.
View
No changes.
View
No changes.
View
@@ -0,0 +1,62 @@
+<?php
+/**
+ * @package: PHP5-HTML5-Boilerplate
+ * @license: See the LICENSE.md
+ * @copyright: PHP5-HTML5-Boilerplate © 2013
+ * @link: http://rajibmp.github.com/PHP5-HTML5-Boilerplate/
+ *
+ * -----------------------------------------------------------------------------
+ * | Author and Contributor Date Version
+ * | ---------------------------------------------------------------------------
+ * |@author: Rajib Paudyal <rajib.mp@gmail.com> 06.02.2013, Wednesday 0.1
+ * |@task: Created the Index Page
+ * | ---------------------------------------------------------------------------
+ * |@author:
+ * |@task:
+ * -----------------------------------------------------------------------------
+ *
+ * @page: index.php
+ * This is the index file of the main project
+ * All the views would be rendered through this page
+ * @version: 0.1
+ *
+ */
+
+// Define the Root Path of the project
+define('ROOT', dirname(__FILE__) . '/');
+
+// Include the configuration file
+require_once ROOT.'library/config/index.php';
+
+/**
+ * @since: 0.1
+ * Force to define the project environment if not defined
+ * Check the project Environment
+ * When Environment = 'development' the error reporting is set to display all errors
+ * When Environment = 'production' the error reporting is suppressed
+ */
+
+if (!defined('Environment')) {
+ exit('Define the Project Environment correctly in library/config/config.php');
+} else {
+ switch (Environment)
+ {
+ case 'development':
+ error_reporting(E_ALL);
+ ini_set('display_errors',1);
+ ini_set('display_startup_errors',1);
+ break;
+
+ case 'production':
+ error_reporting(0);
+ ini_set('display_errors',0);
+ ini_set('display_startup_errors',0);
+ break;
+
+ default:
+ exit('The Project Environment is not set correctly.');
+ } //switch
+} //if
+
+// Rendering the view page for now to not have empty page. This will be changed once the MVC pattern will be included
+require_once 'view/index.php';
View
@@ -0,0 +1,40 @@
+<?php
+/**
+ * @license: See the LICENSE.md
+ * @copyright: PHP5-HTML5-Boilerplate © 2013
+ *
+ * -----------------------------------------------------------------------------
+ * | Author and Contributor Date Version
+ * | ---------------------------------------------------------------------------
+ * |@author: Rajib Paudyal <rajib.mp@gmail.com> 06.02.2013, Wednesday 0.1
+ * |@task: Created the Config Page
+ * | ---------------------------------------------------------------------------
+ * |@author:
+ * |@task:
+ * -----------------------------------------------------------------------------
+ *
+ * @page: library/config/config.php
+ * This is the main configuration file of the project
+ * All the project configuration is done here
+ * @version: 0.1
+ *
+ */
+
+/**
+ * @since: 0.1
+ * Defining Project Environment constant
+ * There are only two options 'development' and 'production'
+ * Set the environment according to the project phase
+ */
+define('Environment', 'development');
+
+
+/**
+ * @since: 0.1
+ * Making database connection parameters as constants
+*/
+define('HOST', 'localhost'); // host name
+define('DRIVER', 'mysql'); // pdo driver
+define('USER', 'root'); // database username
+define('PASSWORD', ''); // database password
+define('DATABASE', 'boilerplate'); // database name
View
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @license: See the LICENSE.md
+ * @copyright: PHP5-HTML5-Boilerplate © 2013
+ *
+ * -----------------------------------------------------------------------------
+ * | Author and Contributor Date Version
+ * | ---------------------------------------------------------------------------
+ * |@author: Rajib Paudyal <rajib.mp@gmail.com> 06.02.2013, Wednesday 0.1
+ * |@task: Created the Index Page
+ * | ---------------------------------------------------------------------------
+ * |@author:
+ * |@task:
+ * -----------------------------------------------------------------------------
+ *
+ * @page: library/config/index.php
+ * This is the index file of the config library
+ * All the config files would be included via this index file
+ * @version: 0.1
+ *
+ */
+
+// Include the necessary files for the project
+require_once 'requires.php';
+
+ /**
+ * @since: 0.1
+ * If anybody tries to access this page via URI
+ * Redirect them to main index page with 403 Forbidden error
+ */
+/*if (! defined(ROOT)) {
+ $errors->unauthorized_access();
+}//if
+*/
@@ -0,0 +1,32 @@
+<?php
+/**
+ * @license: See the LICENSE.md
+ * @copyright: PHP5-HTML5-Boilerplate © 2013
+ *
+ * -----------------------------------------------------------------------------
+ * | Author and Contributor Date Version
+ * | ---------------------------------------------------------------------------
+ * |@author: Rajib Paudyal <rajib.mp@gmail.com> 06.02.2013, Wednesday 0.1
+ * |@task: Created the Requires Page
+ * | ---------------------------------------------------------------------------
+ * |@author:
+ * |@task:
+ * -----------------------------------------------------------------------------
+ *
+ * @page: library/config/requires.php
+ * This file includes the necessary project files
+ * @version: 0.1
+ *
+ */
+
+// Calling all the constants from the config file
+require_once 'config.php';
+
+// Include the index page of helper folder
+require_once 'library/helper/index.php';
+
+// Including all index.php files from sub-folders under library folder
+foreach (glob("library/*/index.php") as $filename)
+{
+ require_once $filename;
+} //foreach
No changes.
No changes.
No changes.
No changes.
File renamed without changes.
View
@@ -0,0 +1,50 @@
+<?php
+/**
+ * @license: See the LICENSE.md
+ * @copyright: PHP5-HTML5-Boilerplate © 2013
+ *
+ * -----------------------------------------------------------------------------
+ * | Author and Contributor Date Version
+ * | ---------------------------------------------------------------------------
+ * |@author: Rajib Paudyal <rajib.mp@gmail.com> 06.02.2013, Wednesday 0.1
+ * |@task: Created the Errors Page
+ * | ---------------------------------------------------------------------------
+ * |@author:
+ * |@task:
+ * -----------------------------------------------------------------------------
+ *
+ * @page: library/helper/errors.php
+ * This class checks the type of error being sent
+ * and calls the respective error pages to display friendly custom errors
+ * @version: 0.1
+ *
+ */
+
+class Errors {
+
+ /*private $uri;
+
+ public function __construct() {
+ $this->uri = $uri;
+ }
+ */
+
+ /**
+ * @since: 0.1
+ * Direct access to unauthorized pages are redirected to 403 error page
+ * @todo: redirect the 403 unauthorized error page while trying to access it directly.
+ */
+ public function unauthorized_access() {
+ //Code here for Redirection to 403 error page
+ }
+
+ /**
+ * @since: 0.1
+ * File not found errors are redirected to custom 404 error page
+ * @todo: redirection code
+ */
+ public function not_found() {
+ //Code here for Redirection to 404 error page
+ }
+}
+$errors = new Errors();
View
@@ -0,0 +1,41 @@
+<?php
+/**
+ * @license: See the LICENSE.md
+ * @copyright: PHP5-HTML5-Boilerplate © 2013
+ *
+* -----------------------------------------------------------------------------
+ * | Author and Contributor Date Version
+ * | ---------------------------------------------------------------------------
+ * |@author: Rajib Paudyal <rajib.mp@gmail.com> 06.02.2013, Wednesday 0.1
+ * |@task: Created the Index Page
+ * | ---------------------------------------------------------------------------
+ * |@author:
+ * |@task:
+ * -----------------------------------------------------------------------------
+ *
+ * @page: library/helper/index.php
+ * This is the index file of the helper library
+ * All the helper files would be included via this index file
+ * @version: 0.1
+ *
+ */
+
+// Including all the files from helper folder
+foreach (glob("library/helper/*.php") as $filename)
+{
+ require_once $filename;
+} //foreach
+
+// Making the helper path as HELPER_PATH constant
+new Path_Constant(array(basename(__DIR__) => dirname(__FILE__)));
+
+
+ /**
+ * @since: 0.1
+ * If anybody tries to access this page via URI
+ * Redirect them to main index page with 403 Forbidden error
+ */
+/*if (defined(ROOT)) {
+ $errors->unauthorized_access();
+}//if
+*/
@@ -0,0 +1,59 @@
+<?php
+/**
+ * @license: See the LICENSE.md
+ * @copyright: PHP5-HTML5-Boilerplate © 2013
+ *
+ * -----------------------------------------------------------------------------
+ * | Author and Contributor Date Version
+ * | ---------------------------------------------------------------------------
+ * |@author: Rajib Paudyal <rajib.mp@gmail.com> 06.02.2013, Wednesday 0.1
+ * |@task: Created the Path_Constant Page
+ * | ---------------------------------------------------------------------------
+ * |@author:
+ * |@task:
+ * -----------------------------------------------------------------------------
+ *
+ * @page: library/helper/path_constant.php
+ * This class receives an array
+ * and makes the array(key) as constant and array(value) as the constant's value.
+ * @version: 0.1
+ *
+ */
+
+class Path_Constant {
+
+ /**
+ * @since: 0.1
+ * Constructs a constant for received array keys and values
+ * @param array $params
+ */
+ public function __construct($params) {
+ foreach ($params as $key => $val){
+ $key = $this->namePathConstant($key);
+ $this->setPathConstant(array($key => $val));
+ } // foreach
+ } // function
+
+ /**
+ * @since: 0.1
+ * Receives folder name as string and adds _PATH to it
+ * @param string $params
+ * @return string
+ */
+ private function namePathConstant($params) {
+ $params = strtoupper($params);
+ $params .= '_PATH';
+ return $params;
+ } // function
+
+ /**
+ * @since: 0.1
+ * Defines the Constants if it is not defined.
+ * @param array $params
+ */
+ private function setPathConstant($params) {
+ foreach ($params as $key => $val) {
+ defined($key) ? null : define($key, $val.'/');
+ } // foreach
+ } // function
+} // class
View
No changes.
View
No changes.
No changes.
View
No changes.
File renamed without changes.
File renamed without changes.
No changes.
@@ -10,17 +10,17 @@
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
- <link rel="stylesheet" href="css/bootstrap.min.css">
+ <link rel="stylesheet" href="vendor/twitter/bootstrap/bootstrap.min.css">
<style>
body {
padding-top: 60px;
padding-bottom: 40px;
}
</style>
- <link rel="stylesheet" href="css/bootstrap-responsive.min.css">
+ <link rel="stylesheet" href="vendor/twitter/bootstrap/bootstrap-responsive.min.css">
<link rel="stylesheet" href="css/main.css">
- <script src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
+ <script src="vendor/modernizr/modernizr/modernizr-2.6.2-respond-1.1.0.min.js"></script>
</head>
<body>
<!--[if lt IE 7]>
@@ -103,18 +103,18 @@
</div> <!-- /container -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
- <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.9.0.min.js"><\/script>')</script>
+ <script>window.jQuery || document.write('<script src="vendor/jquery/jquery/jquery-1.9.0.min.js"><\/script>')</script>
- <script src="js/vendor/bootstrap.min.js"></script>
+ <script src="vendor/twitter/bootstrap/bootstrap.min.js"></script>
<script src="js/plugins.js"></script>
<script src="js/main.js"></script>
- <script>
+ <!-- <script>
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
- </script>
+ </script> -->
</body>
</html>
File renamed without changes.
File renamed without changes.
View
No changes.
View
No changes.
View
No changes.
No changes.
No changes.
File renamed without changes.
View
@@ -0,0 +1,13 @@
+<?php
+/**
+ * This is just the test view field at the moment
+ * The main task is to determine how the view would be rendered
+ * Only the controller can envoke the view as the project planning
+ * I am planning for separate private and public view for authorized and unauthorized users
+ * Lets see how it pans out.
+ *
+ * The view is calling the default theme's index page for now to not have an empty page.
+ * something is better than nothing.
+ */
+
+require_once 'theme/default/index.html';

0 comments on commit 985f92a

Please sign in to comment.