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:
- Change directories to your webroot
cd /my/web/root
- Initialize a git repository
git init
- 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 ofzing
- 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
- Copy the following files/directories into the root of your web directory
- Websites/*
- Zing/*
- index.php
- .htaccess
- Make sure Mod_Rewrite is enabled if it is not:
- Enable Mod_Rewrite
- Restart Apache
- Nginx
- Copy the following files/directories into the root of your web directory
- Websites/*
- Zing/*
- index.php
- Place nginx.cfg in your sites config directory
- 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"
)
)
);
- Replace
example.com
with your domain (excludinghttp://
and/orwww
). - Either remove the databases section or modify the values for
hostname
,username
,password
anddatabase
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 equalshome
- Example 2:
/@page=blog/@month/@year
; This will only take place when page equalsblog
- Example 3:
/@id/@action/@page
- Default:
- Anything prefixed with an
@
becomes a$_GET
variable
- Set URL routes to format your URL's as you please
- Over-rideable methods
runBefore()
Runs before the main code usually for setting up defaultsrunAfter()
Runs after the main code usually for cleanupcatchAll()
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)
- Example:
- Mass data check to check if any item is blank (Removes before check: Spaces, Tabs, New Lines, Carage Returns)
- Validation
- Vaidates
- Emails
- IP's
- URL's
- User Names (0-9, A-Z, a-z and _)
- Custom Format Tool
- Example
$this->validate->isFormat($input, "(###) ###-####")
- Example
- Vaidates
- 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"))
- Example:
##Features still in the works
- Image
- Image Manipulation
- Resizing
- Croping
- Filters
- Blending
- Image CAPTCHA
- Image Manipulation
There are many other items, and new items being added all the time.