Giter Site home page Giter Site logo

zlilemon / wei Goto Github PK

View Code? Open in Web Editor NEW

This project forked from twinh/wei

0.0 1.0 0.0 35.24 MB

A micro-framework provided powerful and simple APIs for faster and easier PHP 5.3+ development.

Home Page: https://github.com/twinh/wei

License: MIT License

wei's Introduction

Wei

Build Status Coverage Status Latest Stable Version

Wei is a micro-framework provided powerful but simple APIs for faster and easier PHP 5.3+ development.

Getting started

Start using Wei in 3 steps, it's easier than any frameworks you've seen before!

// 1. Include the wei container class
require 'path/to/wei/lib/Wei.php';

// 2. Create the default wei container instance
$wei = wei(array(
    // Options for wei container
    'wei' => array(
        'debug' => true,
        // Other options ...
    ),
    // Options for database
    'db' => array(
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'dbname'    => 'wei',
        'charset'   => 'utf8',
        'user'      => 'root',
        'password'  => 'xxxxxx',
    ),
    // More options ...
));

// 3. Using "db" object to execute SQL query
$result = $wei->db->fetch("SELECT 1 + 2");

Installation

Composer

Define the following requirement in your composer.json file and run php composer.phar install to install

{
    "require": {
        "wei/wei": "0.9.14"
    }
}

Download source code

Resources

API Overview

Cache

// Available cache objects
$wei->cache;
$wei->apc;
$wei->arrayCache;
$wei->couchbase;
$wei->dbCache;
$wei->fileCache;
$wei->memcache;
$wei->memcached;
$wei->mongoCache;
$wei->redis;

$cache = $wei->memcached;

// Cache APIs
$cache->get('key');
$cache->set('key', 'value', 60);
$cache->remove('key');
$cache->exists('key');
$cache->add('key', 'value');
$cache->replace('key', 'value');
$cache->incr('key', 1);
$cache->decr('key', 1);
$cache->getMulti(array('key', 'key2'));
$cache->setMulti(array('key' => 'value', 'key2' => 'value2'));
$cache->clear();

// ...

Database

$db = $wei->db;

// Basic CRUD and Active Recrod support
$db->query();
$db->insert();
$db->update();
$db->delete();
$db->select();
$db->selectAll();
$db->fetch();
$db->fetchAll();
$db->fetchColumn();
$db->find();
$db->findOne();
$db->findAll();
$db->execute();

// Using query builder to build SQL
$record = $db('table');

$record
    ->select()
    ->addSelect()
    ->update()
    ->delete()
    ->from()
    ->where()
    ->andWhere()
    ->orWhere()
    ->groupBy()
    ->addGroupBy()
    ->having()
    ->andHaving()
    ->orHaving()
    ->orderBy()
    ->addOrderBy()
    ->offset()
    ->limit()
    ->page()
    ->indexBy();

$record->find();
$record->findAll();
$record->fetch();
$record->fetchAll();
$record->fetchColumn();
$record->count();
$record->execute();
$record->getSql();

// ...

Validator

// Available validator objects

// Data type and composition
$wei->isAlnum($input);
$wei->isAlpha($input);
$wei->isBlank($input);
$wei->isDecimal($input);
$wei->isDigit($input);
$wei->isDivisibleBy($input);
$wei->isDoubleByte($input);
$wei->isEmpty($input);
$wei->isEndsWith($input);
$wei->isIn($input);
$wei->isLowercase($input);
$wei->isNull($input);
$wei->isNumber($input);
$wei->isRegex($input);
$wei->isRequired($input);
$wei->isStartsWith($input);
$wei->isType($input);
$wei->isUppercase($input);

// Length
$wei->isLength($input);
$wei->isCharLength($input);
$wei->isMaxLength($input);
$wei->isMinLength($input);

// Comparison
$wei->isEqualTo($input);
$wei->isIdenticalTo($input);
$wei->isGreaterThan($input);
$wei->isGreaterThanOrEqual($input);
$wei->isLessThan($input);
$wei->isLessThanOrEqual($input);
$wei->isBetween($input);

// Date and time
$wei->isDate($input);
$wei->isDateTime($input);
$wei->isTime($input);

// File and directory
$wei->isDir($input);
$wei->isExists($input);
$wei->isFile($input);
$wei->isImage($input);

// Network
$wei->isEmail($input);
$wei->isIp($input);
$wei->isTld($input);
$wei->isUrl($input);
$wei->isUuid($input);

// Region: All
$wei->isCreditCard($input);

// Region: Chinese
$wei->isChinese($input);
$wei->isIdCardCn($input);
$wei->isIdCardHk($input);
$wei->isIdCardMo($input);
$wei->isIdCardTw($input);
$wei->isPhoneCn($input);
$wei->isPostcodeCn($input);
$wei->isQQ($input);
$wei->isMobileCn($input);

// Group
$wei->isAllOf($input);
$wei->isNoneOf($input);
$wei->isOneOf($input);
$wei->isSomeOf($input);

// Others
$wei->isAll($input);
$wei->isCallback($input);
$wei->isColor($input);

// Validate and get error message
if (!$wei->isDigit('abc')) {
    print_r($wei->isDigit->getMessages());
}

// ...
$wei->request;
$wei->cookie;
$wei->session;
$wei->ua;
$wei->upload;
$wei->response;
$wei->e;
$wei->logger;
$wei->call;
$wei->env;
$wei->error;

// ...

Testing

To run the tests:

$ phpunit

License

Wei is an open-source project released MIT license. See the LICENSE file for details.

wei's People

Contributors

twinh avatar jmsbot avatar bitdeli-chef avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.