Introduction

HipPHP is a modern MVC PHP framework designed to streamline the development of object oriented PHP websites and applications.

Notice: At this time there is no installer associated with HipPHP.

Requirements:

  • Apache web server with PHP5.6 or higher.
  • MySQL

Installation:

  1. Download hipPhp
  2. Extract and upload files to your webserver.
  3. Rename htaccess.txt to .htaccess.
  4. Create a folder outside your public html to store site data.
  5. Edit /engine/settings.php (See code below:)
  6. SSH into your server and run "yarn" in your project root folder. Learn about yarn here. https://yarnpkg.com/en/
  7. While SSH'd into your server, run "composer install" in your project root folder. Learn about composer here. https://getcomposer.org/
  8. Once this information is complete, you can visit your site.
  9. Register your first user. This will be your site admin.

Contents of settings.php:

<?php
define('SITENAME', '');		//      Enter the name of your site here.
define('SITEURL', '');		//      This will be the URL to your site followed by a /
define('SITEPATH', '');		//	The path to your index.php file.  (ex. /home/public_html/)
define('SITEDATAPATH', '');	//	The path to your external data folder.  (ex. /home/data/)
define('SITEEMAIL','');		//	This is the email address that system emails will be sent from.
define('SITESECRET','');	//	Create a unique key.  Key will be used to identify your site.
define('SITELANGUAGE','en');    //	This configures the language of your site.  Defaults to English.
define('DBHOST', 'localhost');	//	Your database host.  Defaults to localhost.
define('DBNAME', '');		//	Your database name.
define('DBUSER', '');		//	Your database user name.
define('DBPASS', '');		//	Your database password.

Plugins:

HipPHP functionality and appearance can be modified with the use of plugins. Do not edit core files!

These are the steps to creating a plugin:

  1. Create a folder named "plugins" in the root of your installation. (If the plugins folder doesn't already exist.)
  2. Create a folder inside your plugins folder for your plugin. The name of this folder should be relative to the plugin you are creating. For this example, we will name the plugin folder "blog".
  3. Inside the blog folder, create a file named "manifest.json". The contents of this file are explained in the code block below:
    {
        "name": "blog",
        "label": "Blog Plugin"
    }
    
            
    The "name" should be the same as the folder name. The "label" is so you can identify the plugin in your plugins list later.
  4. Next create a php file named BlogPlugin. This file should start with the capitalized name of your plugin folder, and end with "Plugin". The contents of this file are explained in the code block below:
    <?php
    class BlogPlugin {
        function __construct() {
    
        }
    }
            
  5. Once these files are created, you can visit your admin panel by logging in as your admin user, and clicking "My Account" / "Dashboard". From there, click the "Plugins" menu item, then click "Rescan Folder" and confirm. The system will recognize your new plugin, and you can enable it.
  6. Your new plugin won't do much right now, but you can instantiate classes, add views folders, and use functions inside your plugin's constructor class.

Views

HipPHP uses a views system that can be extended with plugins.
Views can be contained in php files, or smarty tpl files.

The default views heirarchy is as follows:

  1. views
    1. admin
      1. general.tpl - System view
      2. hooks.tpl - System view
      3. login_as.tpl - System view
      4. logo.tpl - System view
      5. menu.tpl - System view
      6. pages.tpl - System view
      7. seo.tpl - System view
      8. tables.tpl - System view
      9. users.tpl - System view
      10. view extensions.tpl - System view
      11. views.tpl - System view
    2. bootstrap
      1. mediaobject - System view
    3. email
      1. elements
        1. footer.tpl - System view
        2. header.tpl - System view
      2. forgot_password_body.tpl - System view
      3. forgot_password_subject.tpl - System view
      4. verify_email_body.tpl - System view
      5. verify_email_subject.tpl - System view
    4. forms
      1. addPage.tpl - System view
      2. add_entity.tpl - System view
      3. create_custom_page.tpl - System view
      4. delete_all_data.tpl - System view
      5. edit_custom_page.tpl - System view
      6. edit_entity.tpl - System view
      7. edit_homepage.tpl - System view
      8. forgot_password.tpl - Forgot password form
      9. general_settings.tpl - System view
      10. login.tpl - Login form
      11. new_password.tpl - New password form (forgotten password)
      12. register.tpl - Registration form
      13. resend_verification_email.tpl - Resend verification email form
      14. seo_value.tpl - System view
      15. upload_logo.tpl - System view
      16. user_settings.tpl - System view
    5. input
      1. access.tpl - Access input
      2. button.tpl - Button input
      3. checkbox.tpl - Checkbox input
      4. checkboxes.tpl - Checkboxes input
      5. color.tpl - Color input
      6. date.tpl - Date input
      7. datetime.tpl - Date time input
      8. dropdown.tpl - Dropdown input
      9. editor.tpl - Editor input
      10. email.tpl - Email input
      11. file.tpl - File input
      12. hidden.tpl - Hidden input
      13. password.tpl - Password input
      14. submit.tpl - Submit button
      15. text.tpl - Text input
      16. textarea.tpl - Textarea input
      17. toggle.tpl - Toggle input
    6. js
      1. fullcalendar.tpl - Fullcalendar input
    7. layouts
      1. left_sidebar.tpl - View with a left sidebar
      2. one_column.tpl - View with one column
      3. right_sidebar.tpl - View with a right sidebar
    8. model
      1. Plugin.tpl - View for a plugin (used for lists)
      2. User.tpl - View for a user (used in lists)
    9. output
      1. button.tpl - Button output
      2. checkboxes.tpl - Checkboxes output
      3. date.tpl - Date output
      4. dropdown.tpl - Dropdown output
      5. editor.tpl - Editor output
      6. email.tpl - Email output
      7. file.tpl - System view
      8. file_download.tpl - System view
      9. image_viewer.php - System view
      10. location.tpl - System view
      11. owner_menu.tpl - System view
      12. text.tpl - Text output
      13. textarea.tpl - Textarea output
      14. timeago.tpl - Formatted time ago output
      15. video.tpl - System view
    10. page_elements
      1. accordion.tpl - System view
      2. ajax_tabs.tpl - System view
      3. breadcrumbs.tpl - View to display site breadcrumbs
      4. card.tpl - View to display bootstrap card element
      5. foot.tpl - Footer view just before javascript output
      6. footer.tpl - Entire footer view including foot.tpl view
      7. head.tpl - Site head, including CSS, javascript, and meta
      8. header.tpl - Entire site header view including head.tpl view
      9. js_init.tpl - System view
      10. logo.tpl - System view
      11. modal.tpl - System view
      12. navigation.tpl - Site navigation view
      13. page_heading.tpl - System view
      14. pagination.tpl - Site pagination
      15. panel.tpl - System view
      16. pills.tpl - Bootstrap pill view
      17. system_messages.tpl - System view
      18. tabs.tpl - Bootstrap tabs view
      19. tinymce_buttons_wrapper.tpl - System view
    11. pages
      1. 404.tpl - System view
      2. entity.tpl - System view
      3. home.tpl - Home page
      4. login.tpl - Login page
      5. password_reset_email_sent.tpl - System view
      6. register.tpl - Registration page
      7. settings.tpl - System view
      8. verification_email_sent.tpl - System view

Each view can be overriden by plugins. Plugins that are at the bottom of the plugin list have priority. To override a view, simply copy the view file and ancestor folders into your plugin folder.

Classes

  • Accesshandler

    Access handlers return true if access is granted, and false if not granted.

    To create a new Access handler, prepend AccessHandler with the name of the handler. ie. LoggedinAccessHandler

    <?php
    class LoggedinAccessHandler() {
        if (loggedIn()) {
            return true;
        } else {
            return false;
        }
    }
            
  • CSS

    Instantiate the CSS class to add CSS to the site.

    <?php
    new CSS("name","location");
            
  • Email

    Used to send system email.

    <?php
    new Email(array(
        "html"=>true,  //set to false to send regular text emails.  Defaults to true
        "from"=>array(
            "name"=>"From name",
            "email"=>"From email address."
        ),
        "to"=>array(
            "name"=>"To name",
            "email"=>"To email address"
        ),
        "subject"=>"Email subject",
        "body"=>"Email message"
    ));
            
  • FooterJS

    Used to add javascript to the site footer.

    <?php
    new FooterJS("name","location","weight","init"); 
    // name = a unique text name to identify the javascript
    // location = url of the javascript file
    // weight = where the javascript fits in the heirarchy (bigger numbers load later)
    // init = true of false whether or not to initialize the javascript in the footer 
            
  • Footerscript

    Used to add arbitrary javascript code tot he footer. Loads after FooterJS

    <?php
    $javascript = <<<HTML
    alert("testing");
    HTML;
    new Footerscript("name",$javascript);
            
  • HeaderJS

    Used to add javascript to the header of the site.

    <?php
    new HeaderJS("name","location","weight","init"); 
    // name = a unique text name to identify the javascript
    // location = url of the javascript file
    // weight = where the javascript fits in the heirarchy (bigger numbers load later)
            
  • MenuItem

    Used to create an entry in the site menu.

    <?php
    new MenuItem(array(
        "name"=>"blog",  // Arbitrary text name of the menu item.
        "label"=>"Blog",  // Label to show for menu item.
        "menu"=>"header_left",  // Menu in which to place the menu item (header_left, header_right, or account)
        "link_class"=>"nav-link"  // CSS class to add to the nav item's href
    ));
            
  • Model

    Extend the model class to create any type of object.

    <?php
    class Blog extends Model() {
        
    }
    
    $blog = new Blog;
    $blog->title = "This is a blog title";  // When adding metadata to a model, you may use any format of data.  The system will serialize the data before storing it.
    $blog->description = "This is a blog body.";
    $blog->save();  // The save method is used to save the model to the database.
            
  • Router

    Extend the Router class to provide routes for your site urls. For example, to create a router for the blog plugin, you would creat BlogRouter

    <?php
    class BlogRouter extends Router() {
        public function __construct() {
            $this->html = "Your page html here"; // This html will be shown when visiting your_site/blog
        }
    }
            
  • SystemMessage

    Used to create a system message to alert users of an event

    <?php
    new SystemMessage("Your information has been saved.");
            
  • ViewExtension

    Used to extend a view. In other words, attach a view to another one. For example, to attach the navigation view to the bottom of the header view, use this code:

    <?php
    new ViewExtension("page_elements/header","page_elements/navigation");
            

Functions

Functions can be used in php views, and plugin classes.
  • addTokenToURL

    Adds a security token to a given url. Used for form actions.

    <?php
    $url = "http://localhost";
    $url = addTokenToURL($url);
            
  • adminGateKeeper

    Prevents non logged in users, and non admin logged in users from accessing a page or action.

    <?php
    adminGateKeeper();
            
  • adminLoggedIn

    Returns true if the current logged in user is an admin. False otherwise.

    <?php
    if (adminLoggedIn()) {
        // do something
    }
            
  • classGateKeeper

    Prevents code from running or a view from displaying if the checked model isn't a member of the specified class.

    <?php
    classGateKeeper($user,"User");
            
  • currentPage

    Returns the current site page

    <?php
    if (currentPage() == "home") {
        echo "home page";
    }
            
  • drawForm

    Displays a form complete with tokens for form security.

    <?php
    echo drawForm(array(
        "name"=>"login",    //the view which holds the form.  forms are located in views/forms/
        "method"=>"post",   //form method (post or get)
        "action"=>"login"   //action class to instantiate.  In this case LoginActionHandler
    ));
            
  • drawPage

    Used to create a boostrap page layout

    <?php
    $heading = "Page heading";
    $body = "Page body";
    $buttons = "Button";
    echo drawPage(array(
        "heading"=>$heading,
        "body"=>$body,
        "buttons"=>$buttons
    ));
            
  • forward

    Forwards site to another page.

    <?php
    forward("home");
            
  • getLoggedInUser

    Returns logged in user model.

    <?php
    $user = getLoggedInUser();
            
  • getLoggedInUserGuid

    Returns the guid of the logged in user.

    <?php
    echo getLoggedInUserGuid();
            
  • getModel

    Returns a model by it's guid.

    <?php
    $user = getModel(3);
            
  • getModels

    Returns an array of models based on search criteria

    <?php
    $models = getModels(array(
        "type"=>"User",     // the type of model
        "wheres"=>array(    // an array of name,operand,value for searching
            array("name","=","Shane Barron")
        )
    ));
            
  • getSiteURL

    Returns the site's url.

    <?php
    echo getSiteURL();
            
  • isAdmin

    Checks if a user model is a site admin.

    <?php
    $user = getLoggedInUser();
    if (isAdmin($user)) {
        // do admin stuff
    }
            
  • isEnabledPlugin

    Checks if a given plugin is enabled

    <?php
    if (isEnabledPlugin("Blog")) {
        // do stuff
    }
            
  • listModels

    Displays a list of models.

    <?php
    echo listModels(array(
        "type"=>"User",     // the type of model
        "wheres"=>array(    // an array of name,operand,value for searching
            array("name","=","Shane Barron")
        )
    ));
            
  • loggedIn

    Checks if current user is logged in.

    <?php
    if (loggedIn()) {
        //do stuff
    }
            
  • loggedOut

    Checks if current user is logged out.

    <?php
    if (loggedOut()) {
        // do stuff
    }
            
  • pageArray

    The pageArray function breaks the site url into the following format: http://localhost/0/1/2 etc..

    <?php
    $guid = pageArray(2);  // Pass the url key to the function 
            
  • removeCSS

    Removes CSS from the page

    <?php
    removeCSS("bootstrap");  // Pass the name of the css to the function to have it removed.
            
  • removeHeaderJS

    Removes Javascript from the header

    <?php
    removeHeaderJS("jquery");  // Pass the name of the javascript to the function to have it removed.
            
  • removeFooterJS

    Removes Javascript from the footer

    <?php
    removeFooterJS("jquery"); // Pass the name of the javascript tot he function to have it removed
            
  • removeMenuItem

    Removes a menu item by name.

    <?php
    removeMenuItem("home","header_left");  // Accepts name of menu item, and menu from which to remove it.
            
  • reverseGatekeeper

    Blocks logged in users from viewing page

    <?php
    reverseGateKeeper();
            
  • view

    Displays a view

    <?php
    echo view("input/button");