<![CDATA[higrid.net]]> http://higrid.net 提供php建站程序HiCMS和HIGrid Wed, 05 Apr 2017 00:00:00 +0800 en-gb Copyright 2023 <![CDATA[HiGridpro快速安装向导]]> http://higrid.net/hi/docs/higridpro-quick-install http://higrid.net/hi/docs/higridpro-quick-install article Wed, 05 Apr 2017 00:00:00 +0800 HiGridpro快速安装向导

系统需求

  1. PHP 5.1以上
  2. PDO (MySQL or PostgreSQL) 例子为mysql

下载安装

本站下载 下载最新版本;

目录结构为:

│  example.php //php文件例子
│  readme.txt   
│  higridsql.sql //示例数据库   
├─example //例子文件夹
│      config.php //数据库设置文件
├─higrid
│  │  HiGrid.php //higrid 主程序
│  │  
│  └─scopbin //加密文件
│          911006.php
├─js //js文件
└─themes //CSS样式文件

安装

  1. 将下载的higrid.版本代码.rar解压缩
  2. 新建数据库,将higridsql.sql导入数据库
  3. 打开config.php设置数据库参数
  4. 将解压缩后的全部文件上传到服务器,任意目录都可
  5. 浏览器中打开example.php查看效果
  6. 增加其他表格只需模仿example文件夹中的php文件修改相应参数即可

注意事项

higrid展示jqgrid需要js和Css进行控制,因此一个显示页面的组成应该是这样的:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="http://higrid.net/include/css/higridstock.css" type="text/css" media="screen" charset="utf-8" />
<script src="http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://higrid.net/include/js/higridstock.js" charset="utf-8"></script>
</head>
<body>
<?php include "higrid的php程序文件.php";?>即:example下的文件如chanzhi.php
</body>
</html>

example.php就包含以上代码,只是使用参数ex=?来引用例子。 若您增加的例子如yourgrid.php可以采用path/example.php?ex=yourgrid.php;

以上js和Css采用jqgrid官方的推荐写法,即:

<link rel="stylesheet" type="text/css" media="screen" href="./themes/redmond/jquery-ui-custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="./themes/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="./themes/ui.multiselect.css" />
<style type="text">
   html, body {
   margin: 0;           /* Remove body margin/padding */
   padding: 0;
   overflow: hidden;    /* Remove scroll bars on browser window */
   font-size: 75%;
   }
</style>
<script src="./js/jquery.js" type="text/javascript"></script>
<script src="./js/i18n/grid.locale-cn.js" type="text/javascript"></script>
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<script src="./js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="./js/jquery-ui-custom.min.js" type="text/javascript"></script>

参数配置说明

defined('HIPATH') || define('HIPATH', dirname(__FILE__).'/');//本语句定义本文件的绝对路径
require_once(HIPATH.'config.php');//config.php保存着数据库连接设置,修改本目录下config.php相关参数

$connhigrid = new PDO(DB_DSN,DB_USER,DB_PASSWORD);//创建一个新的链接
$connhigrid->query("SET NAMES utf8");//设置数据库字符集

$grid = new hgGridRender($connhigrid);//实例化一个对象
//嗨网higrid:执行SQL查询,可自定义SQL语句
$grid->higridSC = 'SELECT * FROM higrid_letter';
$grid->setUserDate('Y-m-d');//自定义年月日显示方式
//也可以$grid->setUserDate('m/d/Y');

$grid->datearray = array('receiveddate','donedate');//'receiveddate'和'donedate'是这个表的两个日期字段

$grid->table = 'higrid_letter';//本数据库的表名称

//自动CRUD操作的key,唯一
$grid->setPrimaryKeyId('letterid');

$grid->dataType = 'json';
$grid->setColModel(); 


//嗨网higrid:隐藏部分列。默认所有列显示
$grid->higridsCP("letterid", array("hidden"=>true));
$grid->higridsCP("doneby", array("hidden"=>true));
$grid->higridsCP("donedate", array("hidden"=>true));

$grid->higridsCP('letterdate', 
        array("label"=>"收发文日期","width"=>"70",'align'=>'center',"formatter"=>"date",
            "formatoptions"=>array("srcformat"=>"Y-m-d", "newformat"=>"Y-m-d"),
            "editoptions"=>array(
            "defaultValue"=>date("Y-m-d"),
            "dataInit"=>
                "js:function(elm){setTimeout(function(){
                    jQuery(elm).datepicker({dateFormat:'yy-mm-dd'});
                    jQuery('.ui-datepicker').css({'font-size':'75%'});
                },200);}")
            ));

//设置每个字段名称,宽度,类型,是否必填?默认字符,筛选过滤选项等等
$grid->higridsCP("lettercontent", array("label"=>"函件内容",'width'=>250,"edittype"=>"textarea", "editrules"=>array("rows"=>10, "cols"=> 100,'width'=>400,"required"=>true)));
$grid->higridsCP('fromunit', array("width"=>"60",'align'=>'center', 'label'=>'发文单位',    "formoptions"=>array("label"=>"发文单位", "elmsuffix"=>"按下拉菜单选择")));
$grid->higridsCP('tounit', array("width"=>"60",'align'=>'center', 'label'=>'收文单位',));
$grid->higridsCP('originid', array("width"=>"80",'label'=>'编号',));
$grid->higridsCP('donedate', array("editoptions"=>array("defaultValue"=>date("Y-m-d"))));
$grid->setSelect("fromunit", array("部门一"=>"部门一","部门二"=>"部门二", "IBM"=>"IBM","google国内"=>"google国内","其他"=>"其他"), false, true, true, array(""=>"默认公司"));
$grid->setSelect("tounit", array("部门一"=>"部门一","部门二"=>"部门二", "IBM"=>"IBM","google国内"=>"google国内","其他"=>"其他"), false, true, true, array(""=>"默认公司"));

//嗨网higrid:post数据处理文件,一般设置本脚本文件路径
$grid->setUrl('./example/letter.php');
//嗨网higrid:表格列属性设置
$grid->higridsGO(array(
    "rownumbers"=>true,//是否显示行号,默认false
    "caption"=>"工作台账",//自定义标题
    "hoverrows"=>true,//鼠标滑动是否变色
    "altRows"=>true,//是否显示斑马表格
    "rowNum"=>20,//默认行数
    "height"=>300,//表格高度
    "rowList"=>array(20,50,100,200),//每页多少数据
    "sortname"=>"letterdate",//排序的字段名称
    "sortable"=>true,//是否启动排序
    'sortorder'=>'desc'));//指定排序方式 
//嗨网higrid:表格列属性设置结束

$grid->navigator = true;//导航是否显示

//页面编辑设置true可用;false不显示、不可用
$grid->higridsNO('navigator', array("excel"=>true,"add"=>true,"edit"=>false,"del"=>false,"view"=>true, "refresh"=>true,"search"=>true,"pdf"=>false));

//增加数据对话框个性化
$grid->higridsNO('add',array("width"=>500,"height"=>300,"dataheight"=>"auto",
"closeAfterAdd"=>true,"reloadAfterSubmit"=>true));//添加数据完后关闭对话框
//编辑数据对话框个性化
$grid->higridsNO('edit',array("width"=>500,"height"=>300,"dataheight"=>"auto",
"closeAfterEdit"=>true,"reloadAfterSubmit"=>true,"editCaption"=>"编辑数据","bSubmit"=>"更新"));

//最终表格的table div id,pager div id
//本页的html代码<table id='cd_lettergrid'></table><div id='cd_letterpager'></div>
$grid->higridOP('#cd_lettergrid','#cd_letterpager',true, null, null, true,true);
$connhigrid = null;//关闭连接

注册用户有问题请联系我们

]]>
<![CDATA[Windows中配置绿色jekyll]]> http://higrid.net/hi/docs/portable-jekyll-for-windows http://higrid.net/hi/docs/portable-jekyll-for-windows article Sat, 04 Oct 2014 00:00:00 +0800 Github pages并非必须使用 Jekyll 用来搭建,而是使用Jekyll更便捷,当然直接使用Html可以达到同样的效果;网络上很多在Windows中配置jekyll的教程新手感觉抓狂,采用 绿色jekyll 更便捷,还可以配置在u盘上

绿色版jekyll配置环境

Windows 用户到下面的网址下载作者提供的一个省去配置的环境包

https://github.com/madhur/PortableJekyll

PortableJekyll-master.zip 大概是 522M,解压后占用约 1.46G。

解压后运行目录下的 setpath.cmd ,里面只有一句,配置了一下环境变量。由于在 CMD 下对环境变量的修改只对 当前窗口 有效,所以只能自己手动添加了,如下:

x:\PortableJekyll-master\ruby\bin;
x:\PortableJekyll-master\devkit\bin;
x:\PortableJekyll-master\git\bin;
x:\PortableJekyll-master\Python\App;
x:\PortableJekyll-master\devkit\mingw\bin;
x:\PortableJekyll-master\curl\bin

使用时替换你的路径,去掉换行(不然贴不全),补到系统环境变量后面。经测试:如果已安装Git,则此文件夹非必须,不需要用Git则注意对应的Git环境变量也不要加到环境变量path中去

环境变量在添加后不会立即生效,即在 cmd 直接敲下面要用的命令时是不会起效的,把 explorer.exe 重启即可。

其实也不用非要加到系统环境变量里,在同一个 cmd 文件时设置了临时环境变量的同时后面加上 jekyll serve ,效果是一样一样的…(待更新)

开始使用

新建博客

这一步就简单了,打开 cmd,定位到你要建立博客的目录,建立一个名叫 myblog 的博客,敲入如下命令:

jekyll new myblog
cd myblog
jekyll serve

这时你的博客已经建立好了,并且在本地开启了一个服务器,可以通过 localhost:4000 进行访问。

写文章

直接定位到博客目录下的 _posts 目录,可以看到一个以 .markdown 结尾的文件,这就是一篇文章。

写好一篇文章后以 年-月-日-主题名.markdown 的格式命名,不要有中文,等待下一步进行网站的生成。

生成

打开 cmd ,定位到当前博客的根目录,运行命令

jekyll build

结果如下

x:\PortableJekyll-master\myblog>jekyll build
Configuration file: x:/PortableJekyll-master/myblog/_config.yml
            Source: x:/PortableJekyll-master/myblog
       Destination: x:/PortableJekyll-master/myblog/_site
      Generating...
                    done.

生成成功。访问 localhost:4000 ,完成。

接下来…

  • 修改模板,使用全新的样式布局
  • 作为一个知识管理系统,自己留着看
  • 发布网站,需要一些 Git 知识。
  • 碎觉…别想太多

参考 官方网站 学习更多内容

]]>
<![CDATA[Windows下一些好用的工具软件]]> http://higrid.net/hi/docs/recommand-software-in-windows http://higrid.net/hi/docs/recommand-software-in-windows article Wed, 17 Sep 2014 00:00:00 +0800 因此higrid推荐一些Windows下使用的一些难以离手的 好软件,或者好插件,其实选择什么工具 都无所谓,但最主要是能用的顺手,提高效率。作为工具的使用者而不是被工具所束缚,只选对的不选能装逼的:-), 毕竟适合你的,你用的好的不一定适合别人

快捷启动或快捷键AutoHotkey

学会使用快捷键,包括操作系统和软件的,同样的东西别人要点几下,你按几下键盘就Ok了,时间长了这节省很大一块时间 AutoHotkey可以减少鼠标操作和减少重复执行的工作,让工作自动化,比如你每天开机之后都要打开固定的几个软件,比如你每天都要登陆邮箱、登陆ssh啥的。很幸运,AutoHotKey能在两个方面都帮到你,貌似提供很多方便的工具都有些复杂,使用AutoHotKey你可以自定义快捷键,也可以执行一些自动化的操作,这都是需要你写脚本来做的,不过别担心,你可以从最简单的脚本开始写起,比如定义一个快捷键$space:: run http://www.163.com ,这样你执行这个脚本,你按win+space键的时候,你就能打开163网站,我们平时经常上的网站就那么几个,是在是没必要每天输那么多遍网址,如果把他们都搞成快捷键,无疑会大大方便工作,我的键盘是多功能键盘,除了标准键,还有一些我永远都用不到的多媒体键,有了AutoHotKey,我就可以重定义这些键,变废为宝,现在我把其中的几个键设置为我工作中每天都要访问的几个网址,一键到达,我还把在启动里放置了一个AutoHotKey的脚本,启动电脑的时候就会帮我自动打开开发工具和几个常用的软件,趁此机会,还能喝上几口咖啡,岂不乐哉。AutoHotKey的功能异常强大,有兴趣的朋友可以多研读它的帮助文档,写得都很详细

类似的有listary,Launchy,Altrun,或Mac 平台上Alfred

界面美化MacType

MacType能接管Windows系统的字体渲染功能,实现比Mac系统更华丽的字体渲染效果。 MacType 支持 Windows XP ~ Windows 8.1 等操作系统。开启 MacType 之后,你可以明显看到字体显示后果的大幅提升,即使是 Win8、Win7 等较新的系统都不例外,更不用说原来的效果并不好的 WinXP了。重新渲染你的系统和程序的字体!选择注册表加载方式就不拖启动速度了,可以让windows摆脱丑陋的字体

文件搜索Everything

顾名思义,everything的意思就是能找到你电脑上的所有东西,这是目前桌面搜索软件里索引感觉最快的一款,值得试试,文件归类不合理的同学就不说了,就是归类合理的人,需要找文件的时候也不免在受个文件夹中翻来覆去之苦,有了everything,你就可以快速定位到自己的文件,尽量缩短寻找时间了。(everything索引的磁盘貌似必须是ntfs,这点需要注意下)。总之作为本地搜索神器,everything支持各类正则表达式,索引速度非常快,秒搜

文件管理Total Commander

强大、方便的资源管理器。可以集成很多插件(teracopy之类)。刚开始用可能会和Windows自带的Explorer有点区别,个性化设置之后。可以非常方便的管理win下的所有文件。

higrid使用过程中有2点疑问:有时候收藏的文件夹会莫名其妙丢失;另外打开一边界面,另一边界面会莫名其妙变化

剪贴板增强软件Ditto

很是实用,尤其是你在需要大量复制粘贴的时候,类似的有ClipX

文本编辑Gvim

Vim 是 Linux 系统上的最著名的文本/代码编辑器,也是早年的 Vi 编辑器的加强版,而 gVim 则是其 Windows 版。它的最大特色是完全使用键盘命令进行编辑,脱离了鼠标操作虽然使得入门变得困难,但上手之后键盘流的各种巧妙组合操作却能带来极为大幅的效率提升。vim 的优势是它是一个真正编辑器,并且是一个可扩展可定制的编辑器。由于vim的操作有些反人类,你需要付出一些时间来练习。一旦能够享受vim给的自由,你会爱不释手的。higrid.net 上会增加一些vim的小技巧,同时在github上共享gvim的配置文件

流程图绘制 graphviz

graphviz 是基于 dot 语言的绘图工具,对于有向图、无向图、关系图、目录图、流程图等,我认为用 graphviz 比较快捷。好处是:只要描述好对象之间的关系,图的生成是自动的,比 mindmap 还要好用(mindmap 有一个根节点,graphviz 对根节点个数没有限制)。缺点是:图的生成是自动的,有时得到的不是自己想要的。

msysgit Git版本控制系统

msysGit 作为 Window 平台下的原生程序,Windows 平台下是 Git 客户端的不二之选,msysGit 的安装过程很简单同时还提供一个简单的bash。 作为 Git 客户端工具,如果连接不同的 Git 服务,配置过程可能会有所不同。

一台电脑变两台 ASTER拖机

一台电脑变成几台用,各自独立键鼠操控,独立音频和视频输出,和多电脑没有区别——这就是我们要讲的“电脑一变多”

工具神器后记

作为一个关心效率的伪程序员,higrid尝试过很多提高生产力的工具,一些来自于google大神,一些来自于其他网友的推荐,其中有很多给我带来的很大的方便,以至于都无法离开这些工具

LastUpdated: 2014-09-17 08:52

]]>
<![CDATA[基于PHP魔术常量与魔术方法的简介和使用]]> http://higrid.net/hi/docs/php-magic-methods-and-magic-constants http://higrid.net/hi/docs/php-magic-methods-and-magic-constants article Sat, 13 Sep 2014 00:00:00 +0800 php魔术常量(php Magic constants)

PHP中的常量大部分都是不变的,但是有8个常量会随着他们所在代码位置的变化而变化,这8个常量被称为 魔术常量

  • __LINE__,文件中的当前行号
  • __FILE__,文件的完整路径和文件名
  • __DIR__,文件所在的目录
  • __FUNCTION__,函数名称
  • __CLASS__,类的名称
  • __TRAIT__,Trait的名字
  • __METHOD__,类的方法名
  • __NAMESPACE__,当前命名空间的名称

这些php魔术常量常常被用于获得当前环境信息或者记录日志。

php魔术方法(Magic methods)

PHP中把以两个下划线__开头的方法称为魔术方法,这些方法在PHP中充当了举足轻重的作用。 魔术方法包括:

  • __construct(),类的构造函数
  • __destruct(),类的析构函数
  • __call(),在对象中调用一个不可访问方法时调用
  • __callStatic(),用静态方式中调用一个不可访问方法时调用
  • __get(),获得一个类的成员变量时调用
  • __set(),设置一个类的成员变量时调用
  • __isset(),当对不可访问属性调用isset()empty()时调用
  • __unset(),当对不可访问属性调用unset()时被调用。
  • __sleep(),执行serialize()时,先会调用这个函数
  • __wakeup(),执行unserialize()时,先会调用这个函数
  • __toString(),类被当成字符串时的回应方法
  • __invoke(),调用函数的方式调用一个对象时的回应方法
  • __set_state(),调用var_export()导出类时,此静态方法会被调用。
  • __clone(),当对象复制完成时调用

__construct()__destruct()

构造函数和析构函数应该不陌生,他们在对象创建和消亡时被调用。例如我们需要打开一个文件,在对象创建时打开,对象消亡时关闭

<?php 
class FileRead
{
    protected $handle = NULL;

    function __construct(){
        $this->handle = fopen(...);
    }

    function __destruct(){
        fclose($this->handle);
    }
}
?>

这两个方法在继承时可以扩展,例如:

<?php 
class TmpFileRead extends FileRead
{
    function __construct(){
        parent::__construct();
    }

    function __destruct(){
        parent::__destruct();
    }
}
?>

__call()__callStatic()

在对象中调用一个不可访问方法时会调用这两个方法,后者为静态方法。这两个方法我们在可变方法(Variable functions)调用中可能会用到。

<?php
class MethodTest 
{
    public function __call ($name, $arguments) {
        echo "Calling object method '$name' ". implode(', ', $arguments). "\n";
    }

    public static function __callStatic ($name, $arguments) {
        echo "Calling static method '$name' ". implode(', ', $arguments). "\n";
    }
}

$obj = new MethodTest;
$obj->runTest('in object context');
MethodTest::runTest('in static context');
?>

__get()__set()__isset()__unset()

当get/set一个类的成员变量时调用这两个函数。例如我们将对象变量保存在另外一个数组中,而不是对象本身的成员变量

<?php 
class MethodTest
{
    private $data = array();

    public function __set($name, $value){
        $this->data[$name] = $value;
    }

    public function __get($name){
        if(array_key_exists($name, $this->data))
            return $this->data[$name];
        return NULL;
    }

    public function __isset($name){
        return isset($this->data[$name])
    }

    public function unset($name){
        unset($this->data[$name]);
    }
}
?>

__sleep()__wakeup()

当我们在执行serialize()unserialize()时,会先调用这两个函数。例如我们在序列化一个对象时,这个对象有一个数据库链接,想要在反序列化中恢复链接状态,则可以通过重构这两个函数来实现链接的恢复。例子如下:

<?php
class Connection 
{
    protected $link;
    private $server, $username, $password, $db;

    public function __construct($server, $username, $password, $db)
    {
        $this->server = $server;
        $this->username = $username;
        $this->password = $password;
        $this->db = $db;
        $this->connect();
    }

    private function connect()
    {
        $this->link = mysql_connect($this->server, $this->username, $this->password);
        mysql_select_db($this->db, $this->link);
    }

    public function __sleep()
    {
        return array('server', 'username', 'password', 'db');
    }

    public function __wakeup()
    {
        $this->connect();
    }
}
?>

__toString()

对象当成字符串时的回应方法。例如使用echo $obj;来输出一个对象

<?php
// Declare a simple class
class TestClass
{
    public function __toString() {
        return 'this is a object';
    }
}

$class = new TestClass();
echo $class;
?>

这个方法只能返回字符串,而且不可以在这个方法中抛出异常,否则会出现致命错误。

__invoke()

调用函数的方式调用一个对象时的回应方法。如下

<?php
class CallableClass 
{
    function __invoke() {
        echo 'this is a object';
    }
}
$obj = new CallableClass;
var_dump(is_callable($obj));
?>

__set_state()

调用var_export()导出类时,此静态方法会被调用。

<?php
class A
{
    public $var1;
    public $var2;

    public static function __set_state ($an_array) {
        $obj = new A;
        $obj->var1 = $an_array['var1'];
        $obj->var2 = $an_array['var2'];
        return $obj;
    }
}

$a = new A;
$a->var1 = 5;
$a->var2 = 'foo';
var_dump(var_export($a));
?>

__clone()

当对象复制完成时调用。例如在设计模式详解及PHP实现:单例模式一文中提到的单例模式实现方式,利用这个函数来防止对象被克隆。

<?php 
public class Singleton {
    private static $_instance = NULL;

    // 私有构造方法 
    private function __construct() {}

    public static function getInstance() {
        if (is_null(self::$_instance)) {
            self::$_instance = new Singleton();
        }
        return self::$_instance;
    }

    // 防止克隆实例
    public function __clone(){
        die('Clone is not allowed.' . E_USER_ERROR);
    }
}
?>
]]>
<![CDATA[vim使用技巧和一些经验]]> http://higrid.net/hi/docs/vim-tips-and-experiences http://higrid.net/hi/docs/vim-tips-and-experiences article Sun, 07 Sep 2014 00:00:00 +0800 vim选择技巧

假设你有一个字符串,而光标键在第一个 o 的位置。

(map (+) ("foo")).
  • vi” → 会选择 foo.
  • va” → 会选择 “foo”.
  • vi) → 会选择 “foo”.
  • va) → 会选择(“foo”).
  • v2i) → 会选择 map (+) (“foo”)
  • v2a) → 会选择 (map (+) (“foo”))’”
  • 选中括号里的内容 v% 光标在一侧括号

gv 可以再次visually select上次的区域

vim命令技巧

用Vim的方式编辑Command-line(EX mode) 在Ex-mode输入命令时,有时需要调整,不能用Vim的方式来编辑, 这时候可以按「Ctrl-F」,切换进「Command-line window」,随意编辑,回车执行。

  :h c_CTRL-F

也可以使用Command-line补全,在Command-line输入命令时,想不起来命令全称了?Tab不好用?试试 Ctrl-D

  :h c-CTRL-D

宏命名技巧

Vim 宏与yank是共享寄存器的,最好有某种策略保证不会冲突。其实可以qwer四个寄存器用来录制临时用完即弃的宏(靠近q和@比较好按)。uiop四个键预留给yank (靠近”和y,p键。也就是除了常用的“和0号寄存器外,再预留四个寄存器来做复制粘贴,通常够用了),其他字母键用来记录固定宏(也就是关了vim下次打开还会接着用的常用宏)

Undo/Redo技巧

理论上在Vim中可以进行无限层级的Undo/Redo操作。同时Vim提供了一些高级的Undo/Redo操作,即earlier和later命令。例如我想回到四分钟以前的状态,只需执行命令:earlier 4m 。然后我又想前进到30秒后的状态,则执行命令:later 30s 。刚才的两个例子用时间点做参考,那么如果我想回到之前五次修改之前的状态,则执行命令:undo 5 .Vim以树形结构的方式组织undo list,可以用命令:undolist查看。所以从某种意义上讲,Vim不仅是一个文本编辑器,而且还是一台时光机(time machine)。

vim中文输入法切换技巧

在vimrc中进行设置,就不会为频繁切换输入法抓狂了,特别是在Vim下写代码和注释时或者完全采用vim写中文的时候。

    " Input method
       set iminsert=0
       set imsearch=0
       se imd
       au InsertEnter * se noimd
       au InsertLeave * se imd
       au FocusGained * se imd

但这种方式在搜索的时候也不能输入中文,但和使用 Ctrl+F 和I输入

]]>
<![CDATA[PHP命名空间及自动加载]]> http://higrid.net/hi/docs/php-namespace-and-autoload http://higrid.net/hi/docs/php-namespace-and-autoload article Tue, 02 Sep 2014 00:00:00 +0800 假设如果不使用 php命名空间 namespace,那么每个类在一个项目中的名字就必须是固定的。因为php在new的时候不管是调用autoload还是调用已加载过的类,都存在一个类名对应的文件。所以在没有php命名空间namespace的时候,我们会想各种命名规则来区分不同的类,比如project1_school1_class1_Student或者project2_school_class_Student。 引入php namespace 之后就可以将这个有效规避了,一个namespace就相当于对应一个文件路径,查找这个类的时候,就会去对应的文件路径查找类定义文件了。

php命名空间

什么是php命名空间呢?

命名空间(英语:Namespace)表示标识符(identifier)的可见范围。一个标识符可在多个命名空间中定义,它在不同命名空间中的含义是互不相干的。这样,在一个新的命名空间中可定义任何标识符,它们不会与任何已有的标识符发生冲突,因为已有的定义都处于其它命名空间中。

简单说来命名空间 是为了解决不同库在同一个环境下使用时出现的命名冲突。例如我自己有一个函数名叫A,但是系统已经有一个A函数了,那就会出现冲突。

PHP中的命名空间

PHP从5.3版本开始引入了命名空间,之后许多现有PHP类库以及框架都开始支持它。那么PHP的命名空间怎么用呢?

定义命名空间

下面是一个定义命名空间的例子

<?php    
//file a.php
namespace A;

const test = 'Atest'; 

function test() { 
    return __FUNCTION__; 
}

class Test{
    public function __construct(){
        return __METHOD__;
    }
}
?>

上面例子中就是一个典型的命名空间定义方法,只有const, function, class受命名空间的约束。

使用php命名空间

使用php命名空间 的方式如下:

<?php 
namespace B;
use A;

const test = 'Btest';
function test() { 
    return __FUNCTION__; 
}

class Test{
    public function __construct(){
        return __METHOD__;
    }
}

include "a.php";//必须包含A命名空间的文件

// 完全限定
// `\B\test`从绝对位置查找输出,如果是全局函数则`\test`
echo \B\test;   //输出Btest

// 限定名称  
// 这里已经通过`use A`申明了在这个文件可以通过`\A\...`使用A命名空间的函数
echo A\test;    //输出Atest

// 非限定名称
// 非限定名称的函数`test`会从当前命名控件查找,即B
echo test;      //输出Btest

// namespace关键字代表当前命名空间
echo namespace/test;
?>

首先要注意的是命名空间只起申明作用,也就是在使用了命名空间的时候依然得把这个命名空间申明的那个文件包含进来。在使用中可以通过__NAMESPACE__来查看当前命名空间。

更多内容可以查看PHP官方文档

自动加载

每个文件既要申明命名控件又要手动include是非常不智能的事情,所以在自己的PHP系统或者框架中可以使用自动加载技术,让系统自己去找

最简单的方式是利用函数__autoload函数,但是这个函数只能在非命名控件下定义,也就是全局情况下:

function __autoload($class) {
  $dir = './';
  set_include_path(get_include_path().PATH_SEPARATOR.$ids_dir);
  $class = str_replace('\\', '/', $class) . '.php'; 
  require_once($class);

}

如果在已经有了命名空间的类中,可以使用函数spl_autoload_register来注册一个类中的方法来代替__autoload

]]>
<![CDATA[深入理解GitHub工作流]]> http://higrid.net/hi/docs/understanding-the-github-workflow http://higrid.net/hi/docs/understanding-the-github-workflow article Sun, 31 Aug 2014 00:00:00 +0800 github上用先 fork后发 pull request 的方式,参与别人项目。

  1. 要注意的地方

- 不要直接在 master上写代码 - 因为我们本地的 master 主要是用来跟踪上游 master 的

  1. 很有用的 branch操作

- 本地新建分支 git check -b add_sth - 把本地的 add_sth 分支保存的 github 上 git push orign add_sth
- 删除本地 add_sth 分支 git branch -D add_sth
- 删除 github 上的 add_sth 分支 git push orign :add_sth

下文为 github工作流程 的译文,原文见尾部链接

GitHub流是一个轻量级,基于分支的工作流,它使得小组和项目的部署变得标准化。这个向导解释了GitHub流是如何&为什么工作的。

github-flow

创建一个分支

当你工作在一个项目中,你可能会在任何时间产生不同的想法和特性计划—这些都是准备完成的,或者其他不准备完成的。分支的存在可以帮助你管理工作流。

当你在自己的项目中创建一个分支的时候,也就等于创建了一个尝试自己想法的环境。你在这个分支修改的东西不会影响到主分支,所以你可以尽情的测试和提交改变。这些改变直到你的合作伙伴审查过,确保安全才会被合并到主分支中。

分支是Git的一个核心概念,并且GitHub流 完全基于这个概念。只有一个规则,那就是master分支必须是可部署的。

因此,当你在修复bug或者创建新功能时,你的新分支必须创建在master之外。你的分支名称应该是自描述的(如:refactor-authenticationuser-content-cache-keymake-retina-avatars),所以其他人可以了解什么正在进行。

增加提交

一但你的分支创建完成,就可以进行修改了。不管你进行了增加、修改或者删除一个文件,你都可以进行提交代码,将他们增加到分支中去。这个过程可以保持跟踪你对一个特性分支工作的发展。

提交同样为你的项目创建了一个清晰的历史,这样别人就可以了解你做这些的原因以及内容。每一个提交有一个相关的描述,这个描述可以解释你具体做了什么修改。另外,每一个提交都应该是分开的修改单元。这个使得你可以在发现bug的时候回滚修改,或者你决定朝向不同的方向。

提交描述是非常重要的,尤其因为Git跟踪你的改变并且在他们被推送到服务器上的时候显示他们。通过写出清楚的提交描述,你可以使得别人容易遵从和提供反馈。

开启一个Pull Request

Pull Request最初开始于对你的提交的讨论。因为他们紧密集成在Git库下,如果你的请求被接受,所有人可以看到被合并的改变具体包含什么。

你可以开启一个Pull Request在开发过程工任何部分:当你有少量代码,或者你希望分享一些截图或平常的想法,或者当你被卡住希望获得帮助及建议,又或者当你准备好让别人来审查你的工作。通过在请求描述中使用GitHub的 @方式 ,你可以向某一个人或者团队要求反馈,不论他们不在线或者在别的时区。

Pull Request对于开元项目的管理和分享都非常有用。如果你使用一个Fork&Pull模型,Pull Request提供了一个方式来告知项目管理者他们希望关注的改变。如果你使用Shared repository Model,Pull Request有助于开始审查和讨论即将合并到master分支的改变。

讨论并审核你的代码

一但一个Pull Request被开启,负责审核代码改变的人们或团队可能会有一些问题或者评论。可能代码风格不符合项目指导,修改缺少单元测试,或者所有修改都做的非常好。Pull Request被设计来促进和不活这种类型的会话。

在对你提交进行讨论和反馈的过程中,你可以继续推送你的分支。如果有人评论你忘了做一些事情,或者有一些bug在你的代码中,你可以在自己分支中修复并且推送这些修改。GitHub将在统一的Pull Request视图中给你显示新的提交和其他额外的反馈。

Pull Request评论用Markdown写成,所以你可以嵌入图片和表情符号,使用pre-formatted的文字块,和高亮的格式。

合并和部署

一但你的Pull Request审核通过并且分支通过测试,这些代码就可以被合并到master分支以便部署。如果你需要在合并到GitHub库前进行测试,你可以在本地先进行合并。这些在你推送到库中前都是非常容易控制的。

一但被合并,Pull Request会对你的代码保存一个历史修改记录。因为它们是可搜索的,所以所有人都可以回顾到历史纪录去了解一个决定是为什么或者怎么完成的。

通过在Pull Request的文字中包含某些关键字,你可以关联代码和issues。当你的Pull Request被合并,相关的issues同样会被关闭。比如,输入Closes #32将会关闭库中的32号issue。想要获得更多信息,点这里

原文链接:http://guides.github.com/overviews/flow/

]]>
<![CDATA[Markdown中文快速入门]]> http://higrid.net/hi/docs/markdown-simple-example http://higrid.net/hi/docs/markdown-simple-example article Thu, 21 Aug 2014 00:00:00 +0800 对照本文源代码查看

清除样式浏览

关于Markdown

1.Wiki: Markdown

Markdown 是一种轻量级标记语言,创始人为 John Gruber 和 Aaron Swartz。它允许人们“使用易读易写的纯文本格式编写文档,然后转换成有效的 XHTML(或者 HTML)文档”。这种语言吸收了很多在电子邮件中已有的纯文本标记的特性。

2.编写 Markdown 就如同编写纯文本一样简单、纯粹:

  • 它方便修改和发布;
  • 很容易转换为 HTML 代码;
  • 有众多语言及应用的相关扩展;
  • 在 GitHub 等环境中有很好的应用;
  • 是编写文档、记录笔记、撰写文章的合适选择。

3.Markdown 完全兼容 HTML 语法,可以直接在 Markdown 文档中插入 HTML 内容:

1 2
3 4

一、段落与换行

1.段落的前后必须是空行:

空行指的是行内什么都没有,或者只有空白符(空格或制表符)

相邻两行文本,如果中间没有空行 会显示在一行中(换行符被转换为空格)

2.如果需要在段落内强制加入换行(<br />):

可以在前一行的末尾加入至少两个空格
然后换行写其它的文字

3.Markdown 中的多数区块都需要在两个空行之间。

二、标题

1.Setext 形式

大标题

大标题一般显示工程名,类似html的\<h1>
你只要在标题下面跟上=====即可

中标题

中标题一般显示重点项,类似html的\<h2>
你只要在标题下面输入———即可

小标题

小标题类似html的\<h3>
小标题的格式如下 ### 小标题
注意#和标题字符中间要有空格

H1

H2

= 和 - 的数量是没有限制的。通常的做法是使其和标题文本的长度相同,这样看起来比较舒服。

2.atx 形式

① 可以用对称的 # 包括文本:

H1

② 也可以只在左边使用 #:

H1

H2

H3

H4

H5
H6

③ 成对的 # 左侧和只在左变使用的 # 左侧都不可以有任何空白,但其内侧可以使用空白。

###左侧使用了空格###

内侧使用了空格

三、引用

1.引用内容

2.多行内容 可以在每行前加入 >

2.如果仅在第一行使用 >, 后面相邻的行即使省略 >,也会变成引用内容

3.也可以在引用中

使用嵌套的引用

4.或者在引用中 使用其他 Markdown 语法

文字被些字符包围

只要再文字前面加上>空格即可

如果你要换行的话,新起一行,输入>空格即可,后面不接文字 但> 只能放在行首才有效

文字被些字符包围,多重包围

文字被些字符包围开始

只要再文字前面加上>空格即可

如果你要换行的话,新起一行,输入>空格即可,后面不接文字

但> 只能放在行首才有效

四、列表

1.无序列表

  • 可以使用 * 作为标记
  • 也可以使用 +
  • 或者 -

2.有序列表

  1. 有序列表以数字和 . 开始;
  2. 数字的序列并不会影响生成的列表序列;
  3. 但仍然推荐按照自然顺序(1.2.3…)编写。

3.相关事项

  1. 无序列表项的开始是:符号 空格;
  2. 有序列表项的开始是:数字 . 空格;
  3. 空格至少为一个,多个空格将被解析为一个;
  4. 如果仅需要在行前显示数字和 .:

05. 可以使用:数字 \. 来取消显示为列表

五、代码区块

1.可以使用缩进来插入代码块:

<html> // Tab开头
    <title>Markdown</title>
</html>  // 四个空格开头

代码块前需要有至少一个空行,且每行代码前需要有至少一个 Tab 或四个空格;

2.也可以通过 ``,插入行内代码(` 是 Tab 键上边、数字 1 键左侧的那个按键):

例如 <title>Markdown</title>

3.代码块中的文本(包括 Markdown 语法)都会以原格式显示,而特殊字符会被转换为 HTML 实体。

六、分隔线

1.可以在一行中使用三个或更多的 *、- 或 _ 产生分隔线:

***


2.多个 * 之间可以有空格(空白符),但不能有其他字符:

    • *

七、链接

1.行内式

① 普通链接:

Google

② 指向本地文件的链接:

icon.png

③ 包含 title 的链接:

Google

2.参考式

参考式链接的写法相当于行内式拆分成两部分,并通过一个 识别符 来连接两部分。参考式能尽量保持文章结构的简单,也方便统一管理 URL。

① 首先,定义链接:

Google

第二个方括号内为链接独有的 识别符,可以是字母、数字、空白或标点符号。识别符是 不区分大小写 的;

② 然后定义链接内容:

其格式为:[识别符] : 空白符 URL title

其中,URL可以使用 <> 包括起来,title 可以使用 “”、”、() 包括(考虑到兼容性,建议使用 “”),title 部分也可以换行;

链接内容的定义可以放在同一个文件的 任意位置

③ 也可以省略 识别符,使用链接文本作为 识别符

Google

3.自动链接

使用 <> 包括的 URL 或邮箱地址会被自动转换为超链接:

http://www.google.com/

123@email.com

该方式适合行内较短的链接,会使用 UR L作为链接文字。邮箱地址会自动编码,以逃避抓取机器人。

八、图片

插入图片的语法和插入超链接的语法基本一致,也分为行内式和参考式两种。

1.行内式

直接来看例子:

只是显示图片 github

点击某个图片进入一个网页,比如我想点击github的icorn然后再进入www.github.com ![image] 方括号中的部分是图片的替代文本,括号中的 title 部分和链接一样,是可选的。

2.参考式

直接来看例子:

GitHub

3.指定图片的显示大小

目前,Markdown 还不支持指定图片的显示大小,不过可以通过直接插入<img />标签来指定相关属性:

GitHub

九、强调

1.使用 ** 或 __ 包括的文本会被转换为<em></em>,通常表现为斜体:

这是用来演示文本

2.使用 **** 或 ____ 包括的文本会被转换为<strong></strong>,通常表现为加粗:

这是用来演示文本

3.用来包括文本的 * 或 _ 内侧不能有空白,否则 * 和 _ 将不会被转换:

这是用来* 演示*的_文本 _

4.如果需要在文本中显示成对的 * 或 _,可以在符号前加入 \ 即可:

这是用来*演示*的_文本_

5.*、**、_ 和 __ 都必须 成对使用

十、反斜线

反斜线用于插入在 Markdown 语法中有特殊作用的字符。

这是用来*演示*的_文本_

有一些特殊字符如<,#等,只要在特殊字符前面加上转义字符\即可
你想换行的话其实可以直接用html标签\

  • 在行首加点 行首输入*,空格后输入内容即可
]]>
<![CDATA[使用higrid将jqGrid灵活嵌入页面中]]> http://higrid.net/hi/docs/using-higrid-in-different-contexts http://higrid.net/hi/docs/using-higrid-in-different-contexts article Mon, 18 Aug 2014 00:00:00 +0800 设置参数,自动生成所需表格

安装H!Grid 中可以看出,在php中使用输出标记可以自动将表格呈现在网页的任何位置 如letter.php包含的参数如下:

renderGrid( $tblelement, $pager , $script , $summary, $params , $createtbl , $createpg , $echo );

第一个参数指明了html的表格ID,第二个参数为jqgrid所需的分页ID,作为jQuery选择器必须的标识。如果不需要底部页码,第二个参数可忽略。 这些参数在html页面的代码为:

<table id="grid"></table>
<div id="pager"></div>

第三个参数$scriptjqgrid自动包含所需要的参数,渲染后的代码如下:

...
<script type="text/javascript">
jQuery(document).ready(function() {
$("#grid").jqGrid({...});
});
</script>
...

第六个和第七个参数设置为true,自动生成表格和分页的ID

<?php
...
$grid = new jqGridRender($conn);
...
$grid->renderGrid("grid","pager",true,null,null,false, false, true);
?>

生成如下代码:

...
<table id="grid"></table>
<div id="pager"></div>
<script type="text/javascript">
jQuery(document).ready(function() {
$("#grid").jqGrid({...});
});
</script>
...

自定义Table和pager的ID,自动生成javascript

其他情况,可以需要将表格和分页的IDhtml中定义,但需要H!Grid自动生成javascript,这时候需要设置为false

<?php
...
$grid = new jqGridRender($conn);
...
$grid->renderGrid("grid","pager",true,null,null,false, false, true);

生成html:

...
<script type="text/javascript">
jQuery(document).ready(function() {
$("#grid").jqGrid({...});
});
</script>
...
...
<table id="grid"></table>
<div id="pager"></div>

使用JQuery.ready event使用jqGrid

可以使用jQuery的”ready” event (document.ready)使用jqGrid example.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My First PHP jqGrid </title> 
<link rel="stylesheet" type="text/css" media="screen" href="themes/redmond/jquery-ui.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="themes/ui.jqgrid.css" />
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-cn.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
...
<?php include "letter.php";?>
...
});
</script>
</head>
<body>
...
...
<table id="grid"></table>
<div id="pager"></div>
...
</body>
</html>

letter.php 第三、六、七设置为false

<?php
...
$grid = new jqGridRender($conn);
...
$grid->renderGrid("grid","pager",false,null,null,false, false, true);
?>

从AJAX加载jqGrid

从AJAX加载jqGrid,第三个参数设置为true,第六、七参数设置为false

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My First PHP jqGrid </title> 
<link rel="stylesheet" type="text/css" media="screen" href="themes/redmond/jquery-ui.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="themes/ui.jqgrid.css" />
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-cn.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
...
jQuery("#mybutton").click(function(){
   jQuery("#mycontent").load("letter.php");
   return false;
   jQuery(this).remove();
});
...
});
</script>
</head>
<body>
...
<button id="mybutton">Create Grid</button>
...
<div id="mycontent"></div>
...
</body>
</html>

letter.php

<?php
...
$grid = new jqGridRender($conn);
...
$grid->renderGrid("grid","pager",true,null,null,true, true, true);
?>
]]>
<![CDATA[免费编程书籍大全]]> http://higrid.net/hi/docs/free-programming-books http://higrid.net/hi/docs/free-programming-books article Thu, 07 Aug 2014 00:00:00 +0800 本篇免费编程书籍大全持续更新,最后更新时间: 2014-08-17 11:14:01
精选在线开源书籍 .. Git魔法中文版 | 沉浸式学习Git | 笨方法学Vimscript
Higrid api文档
免费编程书籍大全 持续更新网址…

国外程序员推荐的免费的编程书籍

语言无关类免费书籍

操作系统教程

WEB服务器教程

版本控制书籍教程

NoSQL资源

MySQL

项目相关文档

Web教程

大数据

编程艺术

语言相关类

C/C++

CSS

Dart

Fortran

Java

JavaScript

PHP

iOS

Android

Python

Ruby

Shell

Go

Groovy

LISP

Haskell

R

Scala

Swift

Perl

Prolog

Vimscript

读书笔记及其它

]]>
<![CDATA[How to Fix PHP Notice Undefined index]]> http://higrid.net/hi/en/fix-php-undefined-index-notice http://higrid.net/hi/en/fix-php-undefined-index-notice article Thu, 14 Aug 2014 00:00:00 +0800 First of all let us understand the problem.It should be clearly understood that this is NOT an ‘Error’, but a ‘Notice’. A notice can be ignored if it’s not critical while an error must be fixed. You might have observed that even though a notice appears, rest of the output will be displayed on the browser.
Coming back to our topic, when the ‘Undefined index’ notice occurs, most of the time it is a good practice to fix this than ignoring.

How to Fix

One simple answer – isset()!
isset() function in PHP determines whether a variable is set and is not NULL. It returns a Boolean value, that is, if the variable is set it will return true and if the variable value is null it will return false.
More details on this function can be found in PHP Manual.

Example

Let us consider an example.
Below is the HTML code for a comment form in a blog.

<form name="myform" id="myform" method="post" action="add_comment.php">
    <h2>Please leave a comment:</h2>
    <input type="text" id="username" name="username" value="Enter Username" /><br />
    <input type="text" id="email" name="email" value="Enter Email" /><br />
    <textarea id="comment" name="comment">Enter Comment</textarea><br />
    <br /><br />
    <input type="checkbox" id="notify_box" name="notify_box" value="Y">
    Notify me when a new post is published. <br />
    <br />
    <input type="submit" value="Post Comment">
</form>

Here is the PHP file ‘add_comment.php’ which takes the data passed from the comment form.

<?php
    $uName  = $_POST['username'];
    $eMail  = $_POST['email'];
    $comment= $_POST['comment'];
    $notify = $_POST['notify_box'];
    // send the data to the database
?>

What happens is, when the check-box is CHECKED, the code works fine. But when it is not, then I am getting the warning as mentioned above.Warning: Undefined index:
So to fix this, let us make use of the magic function. Now the code appears like this.

<?php
    $notify = "";
    $uName  = $_POST['username'];
    $eMail  = $_POST['email'];
    $comment= $_POST['comment'];
    if(isset($_POST['notify_box'])){ $notify = $_POST['notify_box']; }
    // send the data to the database
?>

What happens here is, I am checking first whether the check box is CHECKED (or set) using a condition. And if the condition is true I am getting the value passed.
The same fix can be used for the above warning when working with $_SESSION, $_POST arrays.

How to ignore

But, there instances where harmless notices can be ignored.
For an example,
I have a page which can be accesses in below 3 ways.
www.someexample.com/comments.php
www.someexample.come/comments.php?action=add
www.someexample.com/comments.php?action=delete
All these URL’s go to the same page but each time performs a different task.
So when I try to access the page through the first URL, it will give me the ‘Undefined index’ notice since the parameter ‘action’ is not set. We can fix this using the isset() function too. But on this instance, we can just ignore it by hiding the notices like this.

error_reporting(E_ALL ^ E_NOTICE);

You can also turn off error reporting in your php.ini file or .htaccess file, but it is not considered as a wise move if you are still in the testing stage.
This is another simple solution in PHP for a common complex problem. Hope it is useful.

]]>
<![CDATA[A curated list of amazingly awesome PHP libraries, resources and shiny things]]> http://higrid.net/hi/en/awesome-php-website http://higrid.net/hi/en/awesome-php-website article Mon, 13 Jan 2014 00:00:00 +0800 Package Management

Libraries for package and dependency management.

Package Management Related

Libraries related to package management.

  • Satis - A static Composer repository generator.
  • Composition - A library to check your Composer environment at runtime.
  • Poser - A Composer class aliasing library.
  • Version - A parsing and comparison library for semantic versioning.
  • NameSpacer - A library to convert from underscores to namespaces.
  • Patch Installer - A library to install patches using Composer.

Frameworks

Web development frameworks.

  • Symfony2 - A framework comprised of individual components.
  • Knp RAD Bundle - A Rapid Application Development (RAD) bundle for Symfony 2.
  • Zend Framework 2 - Another framework comprised of individual components.
  • Laravel 4 - A simple PHP framework.
  • Lithium - Another framework of components.
  • Aura PHP - A framework of independent components.
  • Phalcon - A framework implemented as a C extension.

Framework Components

Web development frameworks’ standalone components.

Micro Frameworks

Micro frameworks and routers.

Content Management Systems

Modern content management systems.

  • Bolt - A simple CMS built with Silex and Twig.

Templating

Libraries and tools for templating and lexing.

  • Twig - A comprehensive templating language.
  • Twig Cache Extension - A template fragment cache library for Twig.
  • Mustache - A PHP implementation of the Mustache template language.
  • Phly Mustache - Another PHP implementation of the Mustache template language.
  • MtHaml - A PHP implementation of the HAML template language.
  • Plates - A native PHP templating library.
  • Lex - A lightweight template parser.

Static Site Generators

Tools for pre-processing content to generate web pages.

  • Sculpin - A tool that converts Markdown and Twig into static HTML.
  • Phrozn - Another tool that converts Textile, Markdown and Twig into HTML.

HTTP

Libraries for working with HTTP and scraping websites.

  • Guzzle - A HTTP client.
  • Buzz - Another HTTP client.
  • Requests - A simple HTTP library.
  • Goutte - A simple web scraper.
  • PHP VCR - A library for recording and replaying HTTP requests.

URL

Libraries for parsing URLs.

Email

Libraries for sending and parsing email.

Files

Libraries for file manipulation and MIME type detection.

Streams

Libraries for working with streams.

  • Streamer - A simple object-orientated stream wrapper library.

Dependency Injection

Libraries that implement the dependency injection design pattern.

  • Pimple - A tiny dependency injection container.
  • Auryn - Another dependency injection container.
  • Orno Di - Another flexible dependency injection container.
  • PHP DI - A dependency injection implementation using annotations.
  • Acclimate - A common interface to dependency injection containers and service locators.

Imagery

Libraries for manipulating images.

Testing

Libraries for testing codebases and generating test data.

  • PHPUnit - A unit testing framework.
  • ParaTest - A parallel testing library for PHPUnit.
  • PHPSpec - A design by specification unit testing library.
  • Codeception - A full stack testing framework.
  • Atoum - A simple testing library.
  • Mockery - A mock object library for testing.
  • Phake - Another mock object library for testing.
  • Parody - Yet another mock object library for testing.
  • Sismo - A continuous testing server library.
  • Faker - A fake data generator library.
  • Samsui - Another fake data generator library.
  • Alice - An expressive fixture generation library.
  • Behat - A behaviour driven development (BDD) testing framework.
  • Pho - Another behaviour driven development testing framework.
  • Mink - Web acceptance testing.
  • HTTP Mock - A library for mocking HTTP requests in unit tests.
  • VFS Stream - A virtual filesystem stream wrapper for testing.
  • Locust - A modern load test library written in Python.
  • Travis CI - A continuous integration platform.
  • PHPCI - An open source continuous integration platform for PHP.

Documentation

Libraries for generating project documentation.

  • Sami - An API documentation generator.
  • APIGen - Another API documentation generator.
  • PHP Documentor 2 - A documentation generator.

Security

Libraries for generating secure random numbers, encrypting data and scanning for vulnerabilities.

  • HTML Purifier - A standards compliant HTML filter.
  • RandomLib - A library for generating random numbers and strings.
  • True Random - A library that generates random numbers using www.random.org.
  • SecurityMultiTool - A PHP security library.
  • Password Compat - A compatibility library for the new PHP 5.5 password functions.
  • PHPAss - A portable password hashing framework.
  • PHP Password Lib - A library for generating and validating passwords.
  • Password Policy - A password policy library for PHP and JavaScript.
  • PHPSecLib - A pure PHP secure communications library.
  • TCrypto - A simple encrypted key-value storage library.
  • PHP IDS - A structured PHP security layer.
  • PHP SSH - An experimental object orientated SSH wrapper library.
  • IniScan - A tool that scans PHP INI files for security.
  • SensioLabs Security Check - A web tool to check your Composer dependecies for security advisories.
  • Zed - An integrated penetration testing tool for web applications.

Code Analysis

Libraries and tools for analysing, parsing and manipulation codebases.

  • PHP Parser - A PHP parser written in PHP.
  • PHPPHP - A PHP VM implementation in PHP.
  • PHPSandbox - A PHP sandbox environment.
  • Dissect - A set of tools for lexical and syntactical analysis.
  • PHP Mess Detector - A library that scans code for bugs, sub-optimal code, unused parameters and more.
  • PHP Code Sniffer - A library that detects PHP, CSS and JS coding standard violations.
  • PHPCPD - A library that detects copied and pasted code.
  • PHP Analyser - A library for analysing PHP code to find bugs and errors.
  • PHP CS Fixer - A coding standard fixer library.
  • PHP Manipulator - A library for analysing and modifying PHP Source Code.
  • PHP Refactoring Browser - A command line utility for refactoring PHP code.
  • UBench - A simple micro benchmark library.
  • Athletic - An annotation based benchmark framework.
  • Mondrian - A code analysis tool using Graph Theory.
  • PHP Debug Bar - A debugging toolbar.
  • PHP Console - A web debugging console.
  • PHPDBG - An interactive PHP debugger.
  • Scrutinizer - A web tool to scrutinise PHP code.

Build Tools

Project build and automation tools.

  • Go - A simple PHP build tool.
  • Bob - A simple project automation tool.
  • Phake - A rake PHP clone library.
  • Box - A utility to build PHAR files.

Asset Management

Tools for managing, compressing and minifying website assets.

  • Assetic - An asset manager pipeline library.
  • Pipe - Another asset manager pipeline library.
  • Munee - An asset optimiser library.
  • JShrink - A JavaScript minifier library.

Geolocation

Libraries for geocoding addresses and working with latitudes and longitudes.

Date and Time

Libraries for working with dates and times.

Event

Libraries that are event-driven or implement non-blocking event loops.

Logging

Libraries for generating and working with log files.

  • Monolog - A comprehensive logger.

E-commerce

Libraries and applications for taking payments and building online e-commerce stores.

  • OmniPay - A framework agnostic multi-gateway payment processing library.
  • Payum - A payment abstraction library.
  • Sylius - An open source e-commerce solution.
  • Thelia - Another open source e-commerce solution.
  • Money - A PHP implementation of Fowler’s money pattern.

PDF

Libraries and software for working with PDF files.

  • Snappy - A PDF and image generation library.
  • WKHTMLToPDF - A tool to convert HTML to PDF.

ORM and Datamapping

Libraries that implement object-relational mapping or datamapping techniques.

NoSQL

Libraries for working with “NoSQL” backends.

  • MongoQB - A MongoDB query builder library.
  • Monga - A MongoDB abstraction library.
  • Predis - A feature complete Redis library.

Queue

Libraries for working with event and task queues.

  • Pheanstalk - A Beanstalkd client library.
  • PHP AMQP - A pure PHP AMQP library.
  • Thumper - A RabbitMQ pattern library.
  • Bernard - A multibackend abstraction library.

Search

Libraries and software for indexing and performing search queries on data.

Command Line

Libraries for building command line utilities.

  • Boris - A tiny PHP REPL.
  • PsySh - Another PHP REPL.
  • GetOpt - A command line opt parser.
  • OptParse - Another command line opt parser.
  • Commando - Another simple command line opt parser.
  • GetOptionKit - Another command line opt parser.
  • Cron Expression - A library to calculate cron run dates.
  • ShellWrap - A simple command line wrapper library.
  • Hoa Console - Another command line library.
  • Shunt - A library for running commands in parallel on multiple remote machines.

Authentication

Libraries for implementing authentications schemes.

  • Sentry - A framework agnostic authentication & authorisation library.
  • Sentry Social - A library for social network authentication.
  • OPAuth - A multi-provider authentication framework.
  • OAuth2 - An OAuth2 authentication server, resource server and client library.
  • PHP oAuthLib - Another OAuth library.
  • TwitterOAuth - A Twitter OAuth library.
  • TwitterSDK - A fully tested Twitter SDK.
  • Hawk - A Hawk HTTP authentication library.

Markup

Libraries for working with markup.

Text and Numbers

Libraries for parsing and manipulating text and numbers.

  • ANSI to HTML5 - An ANSI to HTML5 convertor library.
  • Patchwork UTF-8 - A portable library for working with UTF-8 strings.
  • Hoa String - Another UTF-8 string library.
  • Stringy - A string manipulation library with multibyte support.
  • Numbers PHP - A library for working with numbers.
  • Math - A library for working with large numbers.
  • Color Jizz - A library for manipulating and converting colours.
  • UUID - A library for generating UUIDs.
  • Slugify - A library to convert strings to slugs.
  • Urlify - A PHP port of Django’s URLify.js.
  • Text - A text manipulation library.
  • PHP Units of Measure - A library for converting between units of measure.
  • PHP Conversion - Another library for converting between units of measure.
  • SQL Formatter - A library for formatting SQL statements.
  • Byte - A simple byte conversion library.

Filtering and Validation

Libraries for filtering and validating data.

REST and API

Libraries and web tools for developing REST-ful APIs.

  • Apigility - An API builder built with Zend Framework 2.
  • Hateoas - A HATEOAS REST web service library.
  • HAL - A Hypertext Application Language (HAL) builder library.
  • Negotiation - A content negotiation library.

Caching

Libraries for caching data.

  • Cache - A caching library (part of Doctrine).
  • Stash - Another library for caching.

Data Structure and Storage

Libraries that implement data structure or storage techniques.

Notifications

Libraries for working with notification software.

  • Nod - A notification library (e.g., Growl).
  • Notificato - A library for handling push notifications.
  • Notification Pusher - A standalone library for device push notifications.
  • Notificator - A lightweight notification library.

Third Party APIs

Libraries for accessing third party APIs.

Miscellaneous

Useful libraries or tools that don’t fit in the categories above.

  • Spork - A process forking library.
  • JSON Lint - A JSON lint utility.
  • JSONPCallbackValidator - A library for validating JSONP callbacks.
  • KnpMenu - A menu library.
  • Pagerfanta - A pagination library.
  • Ruler - A simple stateless production rules engine.
  • LiteCQRS - A CQRS (Command Query Responsibility Separation) library.
  • Sslurp - A library that makes dealing with SSL suck less.
  • PHP Option An option type library.
  • Metrics - A simple metrics API library.
  • Sabre VObject - A library for parsing VCard and iCalendar objects.
  • Annotations - An annotations library (part of Doctrine).
  • Whoops - A pretty error handling library.
  • Finite - A simple PHP finite state machine.
  • LadyBug - A dumper library.
  • Plum - A deployer library.
  • Procrastinator - A library for running time consuming tasks.
  • Compose - A function composition library.
  • SuperClosure - A library that allows Closures to be serialized.
  • Jumper - A remote service executor library.
  • Underscore - A PHP port of the Underscore JS library.
  • PHP PassBook - A PHP library for iOS PassBook.
  • PHP Expression - A PHP expression language.
  • RMT - A library for versioning and releasing software.
  • Wise - A configuration manager.
  • Opengraph - An opengraph library.
  • Essence - A library for extracting web media.
  • Embera - An Oembed consumer library.
  • Graphviz - A Graphviz library.
  • Monad PHP - A simple Monad library.
  • Flux - A regular expression building library.
  • Patchwork - A library for redefining userland functions.
  • Galapagos - Evolutionary language transformation.
  • Design Patterns PHP - A repository of software patterns implemented in PHP.
  • PHPCR - A PHP port of the Java Content Repository (JCR).
  • Functional PHP - A functional programming library.
  • ClassPreloader - A library for optimising autoloading.
  • Lib Country - A library for country and subdivision data.
  • Lib Accessor - A library for simplifying accessors.
  • PHPStack - A TCP/IP stack proof of concept written in PHP.
  • Nmap - A PHP wrapper around Nmap.
  • Code Mover - A library for moving code.
  • Country List - A list of all countries with names and ISO 3166-1 codes.
  • PHP-GPIO - A library for playing with the Raspberry PI’s GPIO pins.

Development Software

Software for creating a development environment.

  • HomeBrew - A package manager for OSX.
  • HomeBrew PHP - A PHP tap for HomeBrew.
  • PHP OSX - A PHP installer for OSX.
  • HipHop PHP - A Virtual Machine, Runtime and JIT for PHP by Facebook.
  • Vagrant - A portable development environment utility.
  • Ansible - A radically simple orchestration framework.
  • Puppet - A server automation framework and application.
  • Chef - A systems integration framework.
  • SaltStack - An infrastructure management tool.
  • PuPHPet - A web tool for building PHP development virtual machines.
  • PHP Brew - A PHP version manager and installer.
  • PHP Env - Another PHP version manager.
  • PHP Switch - Another version manager.
  • PHP Build - Another PHP version installer.
  • CodeKit - A general web development tool.
  • HTTPie - A command line alternative to cURL written in Python.
  • Backup - A server backup tool written in Ruby.

Web Tools

Web-based tools.

  • 3V4L - An online PHP shell.
  • DBV - A database version control application.
  • PHP Queue - An application for managing queueing backends.

Resources

Various resources, such as books, websites and articles, for improving your PHP development skills and knowledge.

Websites

Useful web and PHP-related websites and newsletters.

Books

Fantastic books and e-books.

Web Reading

General web-development-related reading materials.

PHP Reading

PHP-releated reading materials.

PHP Internals Reading

Reading materials related to the PHP internals or performance.

Contributing

Please see CONTRIBUTING for details.

]]>
<![CDATA[The Ultimate VIM TODO List]]> http://higrid.net/hi/en/the-ultimate-vim-todo-list http://higrid.net/hi/en/the-ultimate-vim-todo-list article Mon, 11 Nov 2013 00:00:00 +0800 With a TODO list of over 500 items I clearly need advanced software to manage my tasks. And finally I have found just the tool for the job…

After trying web based project trackers, spreadsheets, desktop project management apps, calendar based, email-based, smartphone apps and everything else I could think of, it looks like I’ll be sticking with my plain text todo file with a couple of handy VIM scripts.

Here’s how it works.

My todo.txt is just a tab-separated text file that looks something like this:

1   8   roger   tax return
1   12  seo keyword tools
1   20  web single domain login access
2   1   blog    ultimate VIM TODO list
2   2   web settings page broken
2   2   cms http://en.wikipedia.org/wiki/Website_builder
3   3   blog    glassfish-vs-tomcat-update.txt
3   5   blog    enums in jsf

The first column is priority and the second is a time estimate in hours. I sort by priority then time by using the following VIM command.

:%!sort -k1,1n -k2,2n -s

Which I map to a custom command (S) in my .vimrc file:


:command S %!sort -k1,1n -k2,2n -s

Using a plain text file for my TODO list is the simplest and fastest way I found to manage my jobs. With VIM I can add tasks anywhere in the list and then use VIMs powerful commands to sort, search and filter my tasks. If I ever need to I can also open up my list in a spreadsheet program, although so far I haven’t had to do that.

Give it a try, or let me know if you think you have a better task management system in the comments below.

]]>
<![CDATA[Hicms core content introduction]]> http://higrid.net/hi/en/hicms-content-workflow http://higrid.net/hi/en/hicms-content-workflow article Wed, 16 Oct 2013 00:00:00 +0800 As I have posted before how I am really impressed with H!CMS the flat file, non database content managment system which we use to power this site and which we are now recommending to our clients. However I have come to realise that it has radically changed our workflows and I thought a quick post documenting things might interest a few people, or not, still I have this space on the web so here goes. Up until now we have tended to work in the following way whether it be for a static site or a CMS based system.

Firstly we would mock up a preview of the proposed design, this could be a photoshop comp (yes we still use this method as a picture conveys a thousand words) of the front page with the basics sketched out along with the colours establishing the sites basic identity. Changes could easily be factored in before coding, and the client could sign off the design before coding started.

This also gives us a easily identifiable “stile tile” schema to follow with the key elements and colours having been defined in the photoshop file.

Since going “responsive” if required, we also demonstrate the concept by way of a wireframe or quick mock up to show the various layouts at different resolutions. However we have often found a quick demonstration of a previous design will suffice. The CMS is then set up, the fields defined, and the various CMS tags (or the content if a static site) placed into the coded page.

So far so dandy, this has worked well for a long time then along came H!CMS. Having converted this site from a more traditional database powered CMS the setup was pretty painless, we had the content, we FTP content direct from Sublime Text so no need for the control panel, we had the framework, we just needed to convert it into a theme. However when we came to creating a site from scratch for a client things did not go so smoothly. We followed our normal pattern, added some placeholder content via FTP and then set about the setting up the fields.

Things took ages, the design changed, I pulled out what little hair I have left because it just no longer seemed to work as well, the client was luckily oblivious to our angst and was, and still is, happy as anything. I felt like I was fighting something I could not quite get a hold of. I tried to put it down to the fact I was very used to expressionengine and this was similar (cms placeholder tags,) but different enough to be akward, a bit like moving from windows to mac. I had also had a fair bit of experience with Perch which although database based has similarities in the way it templates specific page output, but no this was not the problem.

Then I finally worked it out. Put the content in first, set up the fields, fieldsets and content structure, create the page.md files, add the content in the control panel (or get the client to do it) and the design sort of works itself out. Yes still create a mockup of the framework, but leave the content areas until after the content exists.

This seems to have been a “eureka moment”. When working in traditional CMS systems the content schema is largely hidden in the database, somehow divorced from you, and something to be spat out via CMS tags. I never saw the content other than in a field in the control panel, I know where it was, database tables, relational linked tables etc. With H!CMS the content is physically there to see, be it in a GIT reo or on the server via FTP. You can see it, work with it , bend it, alter it, move it and make it organically and seamlessly part of the site. In fact it is now the most important part of the site, even when working in the design phase, and easy to change, oh, so easy to change.

Yes I know content is king, I know content is what matters, but yet the design defines the sites identity. H!CMS seems to be changing how we work here, whether we come out better designers, better content curators or just carry on in obscurity time will tell, but it is a journey I am really looking forward to.

]]>
<![CDATA[Navigation in Responsive Design]]> http://higrid.net/hi/en/navigation-in-responsive-design http://higrid.net/hi/en/navigation-in-responsive-design article Tue, 15 Oct 2013 00:00:00 +0800 I’ve looked at a lot of websites on my iPhone. I’ve tried to study how other designers and developers out there are tackling navigation when their website is viewed on a tiny screen. A typical website built for a desktop computer? No problem. You can build whatever the heck you want. Get crazy with Mega Menus and shit. Make your drop downs slide all sexy like - or ease in ever so gently. That’s not the tough part. The tough part is what to do with that huge mega menu once your viewport gets down below let’s say 800px or so. That’s when the fun begins.

So I started to check out what the web had to offer on responsive navigation. I found a few decent resources out there. I found a few interesting techniques (and even made a fancy one myself.) Then I decided I needed to learn more about each technique. So I went ahead and built a little website with a bunch of demos - because we all know that experience is the best teacher.

Here are a few fun things I have learned about how to handle navigation on your responsive projects:

Make ALL of your content accesible from all platforms and devices.

It may be tempting to simply hide something on your website when you get down to a small screen size - but don’t penalize your users just because they are viewing your website from their phone. I know there’s been a debate going on about what context your users are using your website for - but personally I think it’s crap. If someone wants to view your website they want to find out everything you have to offer - they don’t just visit your website on their phone to grab your address. If I’m at looking for info on a restaurant while on my 24” iMac, I want to be able to find their address, menu, and phone number just as I would if I were walking around downtown and considering eating there in half an hour. So don’t hide your content when you get down to small screens - be creative and find a way to display all of the same information. Decide if you really need that information anyway - responsive design is a great reason to re-visit your content strategy.

Make it easy for the user to find your mobile menu!

Sounds simple - but sometimes the use of the hamburger icon isn’t too obvious for your Mom to decipher as the button that activates your menu. Case in point - Microsoft’s menu icon. Some people call the button that twitter bootstrap and the facebook app popularized the “hamburger” icon. If that’s the case then Microsoft’s icon is a club sandwich.

Make your buttons easy to tap.

The average human finger pad is 10-14mm. Apple suggest making your buttons at least 44x44 points (they say points because they can’t technically say pixels due to their high res retina screens). But this is something really simple - just add more padding to your links if they’re hard to click when on a phone or a tablet.

Take advantage of accordions, lists, other creative elements to hide/show content.

There are many elements you can use in your menu to hide and show menus and sub-menus. jQuery UI has a simple accordion - heck you don’t even need jQuery UI - you can just use a simple function to add a class to the parent item and use CSS to hide or show something. There’s also the off-canvas method, which is nice for smaller menus. But don’t forget about the option of keeping your menu really small and utilize landing pages that hold your sub-navigation. This method requires you to really think through your content strategy, but it’s definitely worth it in the end.

There is no hover property on touch devices!

We can pretty much trace the need for responsive web design back to the creation of smart-phones - and smart-phones are touch enabled devices. They don’t have a mouse - therefore there is no hover state. There is only touch.

Try to stay away from the hover property when building responsive websites. For years we have built menus with unordered lists that when hovered over, a drop-down will appear. While this is great for a device with a mouse, what about a device without one? I would rather see a drop-down menu activated with a click or a touch event. This creates consistency across your responsive design. Add a caret or some kind of notification to the user so that she knows something will happen when that menu item is clicked.

I found an interesting bug when I purchased a touch screen Windows 8 Lenovo desktop computer - Internet Explorer did not register touch events. It merely simulated click events. Therefore, hover properties were not handled as they are on iOS devices. I tried to activate a hover-enabled drop-down menu, but it was completely inaccesible. The drop-down wouldn’t stay down long enough for me to click on any of the sub-menus! (Side note: even the Lenovo website wasn’t accesible from their own device! #fail)

So this leads me to tell you this - optimize your website for TOUCH first, hover second. Don’t hide valuable content behind items where “hovering” is needed.

Should I Hide Menu Items to Make My Navigation Responsive?

The quick answer: probably not. The long answer depends on your situation. How big and complex is your navigation? Do you have tertiary navigation? Is your site jam packed with content on the homepage? Do you already have calls to action on the homepage that can get the user to your “hidden” sub-nav?

The reason I don’t like hiding your sub-nav: why hide content from your users just because they are browsing your website from a mobile device? Odds are, they are searching for the same exact content they would be searching when on a desktop. Don’t penalize your users just because they have a smaller screen.

In Conclusion

So after all of this research, here is a link to the site that I built which contains some examples of navigation patterns.

]]>