Skip to content

ZingPHP/Zing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zing

Lightweight php framework

##Installation

I would recommend NOT cloning the repo because then you will have to copy and paste files, and pulling zing framework updates will be much easier, so do the following:

  1. Change directories to your webroot cd /my/web/root
  2. Initialize a git repository git init
  3. Set your upstream git remote add zing https://github.com/ZingPHP/Zing.git
  • If this is your only git repo for the website you can use origin instead of zing
  1. Download the repo git pull zing master

If you did the above 4 steps, then skip to step 2 in either the Apache or Nginx section

  • Apache
    1. Copy the following files/directories into the root of your web directory
    2. Websites/*
    3. Zing/*
    4. index.php
    5. .htaccess
    6. Make sure Mod_Rewrite is enabled if it is not:
    7. Enable Mod_Rewrite
    8. Restart Apache
  • Nginx
    1. Copy the following files/directories into the root of your web directory
    2. Websites/*
    3. Zing/*
    4. index.php
    5. Place nginx.cfg in your sites config directory
    6. Reload Nginx service nginx reload (use sudo if needed)

Next you will need to modify the config file:

$config = array(
    "websites" => array(
        "host"      => "example.com"
        "tplEngine" => "Smarty", // Default Template Engine (Remove for no engine): Smarty, Twig or other framework
    ),
    "databases" => array(
        "localhost" => array(// Global databases all sites can use
            "hostname" => "localhost",
            "username" => "my_user",
            "password" => "my_password",
            "database" => "my_database"
        )
    )
);
  1. Replace example.com with your domain (excluding http:// and/or www).
  2. Either remove the databases section or modify the values for hostname, username, password and database

If all goes well, when you navigate to your domain you should see the following message:

Success!
Welcome to the Zing framework! Looks like all is well!

##Some Key Features (Light List)

  • Routes
    • Set URL routes to format your URL's as you please
      • Default: /@page/@action; Note: @page and @action are reserved words
      • Example 1: /@page=home/@id/@title; This will only take place when page equals home
      • Example 2: /@page=blog/@month/@year; This will only take place when page equals blog
      • Example 3: /@id/@action/@page
    • Anything prefixed with an @ becomes a $_GET variable
  • Over-rideable methods
    • runBefore() Runs before the main code usually for setting up defaults
    • runAfter() Runs after the main code usually for cleanup
    • catchAll() Runs if the called action was not found
  • Database aka DBO (Any database supported by PDO)
    • Connect to one or more databases
    • Can interact with a database using a Database Object Model
    $this->db->getTable("members")->getItemById(123);
    • You can write queries as you normally would as well
    $this->db
        ->getAll("select * from movies where title like ? ", array("peter%"))
        ->each(function($row){
            echo "<p>" . $row["title"] . ": " . $row["description"] . "</p>";
        });
  • Mail
    • Send email with/without attachments
    $this->mail
        ->addAttachment("myfile.jpg")
        ->addRecipients(array("John Doe" => "jdoe@gmail.com"))
        ->send(array("email" => "noreply@example.com", "name" => "No Reply"), "My Title", "My HTML Message");
  • Smarty Templates
  • Cache
    • File Caching for those who don't have memcache or APC
    $trending = $this->cache->setEngine()->cache("trending_news", 300, function(){
        return $this->db->getAll("select * from news where votes > 50 order by last_vote desc");
    });
    • APC Caching
    • Memcache
  • Twitter
    • PUT/GET from Twitters API
  • HTTP
    • Get and work with websites using the easy to use cURL API
  • Manage users sessions
    • Password tool for secure password storage
    • Validate passwords
    • Log user in
    • Check if user is logged in
    • Force user to be logged in to view a page
  • Utilities
    • Mass data check to check if any item is blank (Removes before check: Spaces, Tabs, New Lines, Carage Returns)
      • Example: $this->util->isBlank($one, $two, $three)
  • Validation
    • Vaidates
      • Emails
      • IP's
      • URL's
      • User Names (0-9, A-Z, a-z and _)
      • Custom Format Tool
        • Example $this->validate->isFormat($input, "(###) ###-####")
  • Widgets
    • These are pre-built items that accompany or inhance the actual page
    • These are call using one line of code with optional settings
      • Example: $this->getWidget("Calendar", array("day" => "full"))

##Features still in the works

  • Image
    • Image Manipulation
      • Resizing
      • Croping
      • Filters
      • Blending
    • Image CAPTCHA

There are many other items, and new items being added all the time.

Releases

No releases published

Packages

No packages published

Languages