2015年6月12日 星期五
編譯php時指定php.ini位置
在compile php時,可以透過--with-config-file-path 參數來指定位置,可以從原始碼複製php.ini 通常有兩個選擇 一個是開發階段的參數 一個則是生產階段的參數
2015年5月7日 星期四
getConstants
php中反射(ReflectionClass)的語法
如果想要取得物件中取得const的陣列可以使用
const STATE0 = 'open';
const STATE1 = 'close';
const STATE2 = 'run1';
const STATE3 = 'run2';
const STATE4 = 'run3';
static function getConstants() {
$oClass = new ReflectionClass(__CLASS__);
return $oClass->getConstants();
}
如果想要取得物件中取得const的陣列可以使用
const STATE0 = 'open';
const STATE1 = 'close';
const STATE2 = 'run1';
const STATE3 = 'run2';
const STATE4 = 'run3';
static function getConstants() {
$oClass = new ReflectionClass(__CLASS__);
return $oClass->getConstants();
}
2014年6月14日 星期六
生為ZF的擁護者 來看一下Fedora 20 Yum lib的收藏清單
該如何下手呢?先看一下Fedora20 的Yum 收藏清單
yum search ZendFramework2
php-ZendFramework2 : Zend Framework 2
php-ZendFramework2-Authentication : Zend Framework 2: Authentication Component
php-ZendFramework2-Barcode : Zend Framework 2: Barcode Component
php-ZendFramework2-Cache : Zend Framework 2: Cache Component
php-ZendFramework2-Cache-apc : Zend Framework 2: Cache Component: APC
php-ZendFramework2-Cache-memcached : Zend Framework 2: Cache Component: Memcached
php-ZendFramework2-Captcha : Zend Framework 2: CAPTCHA Component
php-ZendFramework2-Code : Zend Framework 2: Code Component
php-ZendFramework2-Config : Zend Framework 2: Config Component
php-ZendFramework2-Console : Zend Framework 2: Console Component
php-ZendFramework2-Crypt : Zend Framework 2: Crypt Component
php-ZendFramework2-Db : Zend Framework 2: DB Component
php-ZendFramework2-Debug : Zend Framework 2: Debug Component
php-ZendFramework2-Di : Zend Framework 2: DI Component
php-ZendFramework2-Dom : Zend Framework 2: DOM Component
php-ZendFramework2-Escaper : Zend Framework 2: Escaper Component
php-ZendFramework2-EventManager : Zend Framework 2: EventManager Component
php-ZendFramework2-Feed : Zend Framework 2: Feed Component
php-ZendFramework2-File : Zend Framework 2: File Component
php-ZendFramework2-Filter : Zend Framework 2: Filter Component
php-ZendFramework2-Form : Zend Framework 2: Form Component
php-ZendFramework2-Http : Zend Framework 2: HTTP Component
php-ZendFramework2-I18n : Zend Framework 2: i18n Component
php-ZendFramework2-InputFilter : Zend Framework 2: InputFilter Component
php-ZendFramework2-Json : Zend Framework 2: JSON Component
php-ZendFramework2-Ldap : Zend Framework 2: LDAP Component
php-ZendFramework2-Loader : Zend Framework 2: Loader Component
php-ZendFramework2-Log : Zend Framework 2: Log Component
php-ZendFramework2-Mail : Zend Framework 2: Mail Component
php-ZendFramework2-Math : Zend Framework 2: Math Component
php-ZendFramework2-Memory : Zend Framework 2: Memory Component
php-ZendFramework2-Mime. : Zend Framework 2: MIME Component
php-ZendFramework2-ModuleManager : Zend Framework 2: ModuleManager Component
php-ZendFramework2-Mvc : Zend Framework 2: MVC Component
php-ZendFramework2-Navigation : Zend Framework 2: Navigation Component
php-ZendFramework2-Paginator : Zend Framework 2: Paginator Component
php-ZendFramework2-Permissions-Acl : Zend Framework 2: Permissions ACL Component
php-ZendFramework2-Permissions-Rbac : Zend Framework 2: Permissions RBAC Component
php-ZendFramework2-ProgressBar : Zend Framework 2: ProgressBar Component
php-ZendFramework2-Serializer : Zend Framework 2: Serializer Component
php-ZendFramework2-Server : Zend Framework 2: Server Component
php-ZendFramework2-ServiceManager : Zend Framework 2: ServiceManager Component
php-ZendFramework2-Session : Zend Framework 2: Session Component
php-ZendFramework2-Soap : Zend Framework 2: SOAP Component
php-ZendFramework2-Stdlib : Zend Framework 2: Stdlib Component
php-ZendFramework2-Tag : Zend Framework 2: Tag Component
php-ZendFramework2-Test : Zend Framework 2: Test Component
php-ZendFramework2-Text : Zend Framework 2: Text Component
php-ZendFramework2-Uri : Zend Framework 2: URI Component
php-ZendFramework2-Validator : Zend Framework 2: Validator Component
php-ZendFramework2-Version : Zend Framework 2: Version Component
php-ZendFramework2-View : Zend Framework 2: View Component
php-ZendFramework2-XmlRpc : Zend Framework 2: XML-RPC Component
yum search ZendFramework2
php-ZendFramework2 : Zend Framework 2
php-ZendFramework2-Authentication : Zend Framework 2: Authentication Component
php-ZendFramework2-Barcode : Zend Framework 2: Barcode Component
php-ZendFramework2-Cache : Zend Framework 2: Cache Component
php-ZendFramework2-Cache-apc : Zend Framework 2: Cache Component: APC
php-ZendFramework2-Cache-memcached : Zend Framework 2: Cache Component: Memcached
php-ZendFramework2-Captcha : Zend Framework 2: CAPTCHA Component
php-ZendFramework2-Code : Zend Framework 2: Code Component
php-ZendFramework2-Config : Zend Framework 2: Config Component
php-ZendFramework2-Console : Zend Framework 2: Console Component
php-ZendFramework2-Crypt : Zend Framework 2: Crypt Component
php-ZendFramework2-Db : Zend Framework 2: DB Component
php-ZendFramework2-Debug : Zend Framework 2: Debug Component
php-ZendFramework2-Di : Zend Framework 2: DI Component
php-ZendFramework2-Dom : Zend Framework 2: DOM Component
php-ZendFramework2-Escaper : Zend Framework 2: Escaper Component
php-ZendFramework2-EventManager : Zend Framework 2: EventManager Component
php-ZendFramework2-Feed : Zend Framework 2: Feed Component
php-ZendFramework2-File : Zend Framework 2: File Component
php-ZendFramework2-Filter : Zend Framework 2: Filter Component
php-ZendFramework2-Form : Zend Framework 2: Form Component
php-ZendFramework2-Http : Zend Framework 2: HTTP Component
php-ZendFramework2-I18n : Zend Framework 2: i18n Component
php-ZendFramework2-InputFilter : Zend Framework 2: InputFilter Component
php-ZendFramework2-Json : Zend Framework 2: JSON Component
php-ZendFramework2-Ldap : Zend Framework 2: LDAP Component
php-ZendFramework2-Loader : Zend Framework 2: Loader Component
php-ZendFramework2-Log : Zend Framework 2: Log Component
php-ZendFramework2-Mail : Zend Framework 2: Mail Component
php-ZendFramework2-Math : Zend Framework 2: Math Component
php-ZendFramework2-Memory : Zend Framework 2: Memory Component
php-ZendFramework2-Mime. : Zend Framework 2: MIME Component
php-ZendFramework2-ModuleManager : Zend Framework 2: ModuleManager Component
php-ZendFramework2-Mvc : Zend Framework 2: MVC Component
php-ZendFramework2-Navigation : Zend Framework 2: Navigation Component
php-ZendFramework2-Paginator : Zend Framework 2: Paginator Component
php-ZendFramework2-Permissions-Acl : Zend Framework 2: Permissions ACL Component
php-ZendFramework2-Permissions-Rbac : Zend Framework 2: Permissions RBAC Component
php-ZendFramework2-ProgressBar : Zend Framework 2: ProgressBar Component
php-ZendFramework2-Serializer : Zend Framework 2: Serializer Component
php-ZendFramework2-Server : Zend Framework 2: Server Component
php-ZendFramework2-ServiceManager : Zend Framework 2: ServiceManager Component
php-ZendFramework2-Session : Zend Framework 2: Session Component
php-ZendFramework2-Soap : Zend Framework 2: SOAP Component
php-ZendFramework2-Stdlib : Zend Framework 2: Stdlib Component
php-ZendFramework2-Tag : Zend Framework 2: Tag Component
php-ZendFramework2-Test : Zend Framework 2: Test Component
php-ZendFramework2-Text : Zend Framework 2: Text Component
php-ZendFramework2-Uri : Zend Framework 2: URI Component
php-ZendFramework2-Validator : Zend Framework 2: Validator Component
php-ZendFramework2-Version : Zend Framework 2: Version Component
php-ZendFramework2-View : Zend Framework 2: View Component
php-ZendFramework2-XmlRpc : Zend Framework 2: XML-RPC Component
2012年12月14日 星期五
安裝 composer
curl -s http://getcomposer.org/installer| php
由網頁安裝 composer
vim composer.json
編輯使用參數
php composer.phar install
安裝套件包
由網頁安裝 composer
vim composer.json
編輯使用參數
php composer.phar install
安裝套件包
2012年6月27日 星期三
Zend Framework多資料庫設定
因為在ZF中資料庫是以資源的方式提供
所以在application.ini中設置
所以在application.ini中設置
[production]
resources.multidb.db1.adapter = "pdo_mysql"
resources.multidb.db1.host = "localhost"
resources.multidb.db1.username = "webuser"
resources.multidb.db1.password = "XXXX"
resources.multidb.db1.dbname = "db1"
resources.multidb.db2.adapter = "pdo_pgsql"
resources.multidb.db2.host = "example.com"
resources.multidb.db2.username = "dba"
resources.multidb.db2.password = "notthatpublic"
resources.multidb.db2.dbname = "db2"
resources.multidb.db2.default = true
再由Bootstrap取得資料庫
$resource = $bootstrap->getPluginResource('multidb');
$db1 = $resource->getDb('db1');
$db2 = $resource->getDb('db2');
$defaultDb = $resource->getDb();
2012年6月22日 星期五
ZendFramework的bootstrap
在ZendFramework的bootstrap中,如果方法名稱以_init為前綴,將被當成資源方法
來自動執行,如果你手上有現成的資源插件(Pluging),可以透過前導的方法 將該資源
排定執行 但該注意的是 當你是使用module模式時 所有module下的bootstrap將會全部
執行 造成 資源重載 效能低下 後來是以取得該module name為判斷 當非執行該module就return 不繼續執行執行非該module的pluging
來自動執行,如果你手上有現成的資源插件(Pluging),可以透過前導的方法 將該資源
排定執行 但該注意的是 當你是使用module模式時 所有module下的bootstrap將會全部
執行 造成 資源重載 效能低下 後來是以取得該module name為判斷 當非執行該module就return 不繼續執行執行非該module的pluging
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initView()
{
$view = new Zend_View();
// more initialization...
return $view;
}
}
class FooController extends Zend_Controller_Action
{
public function init()
{
$bootstrap = $this->getInvokeArg('bootstrap');
$view = $bootstrap->getResource('view');
// ...
}
}
2011年11月15日 星期二
Linux Pipe小工具
Linux sort的常用
按照第5個字段進行排序
[root@test2 smartlsData]# ll | sort -t : +5n-rwxrwxrwx 1 root root 178718700 12月22 18:40 Poi.bal-rwxrwxrwx 1 root root 182348152 12月22 18:40 Poi.bas-rwxrwxrwx 1 root root 18441600 12月22 18:40 Poi.ndx-rwxrwxrwx 1 root root 194056 2006-08-29 wordTableEntry.txt-rwxrwxrwx 1 root root 194056 9月15 16:31 GeoWordTableEntry.txt-rwxrwxrwx 1 root root 20580 12月22 18:40 ACode.ndx-rwxrwxrwx 1 root root 338304 2006-08-10 AnTable.txt-rwxrwxrwx 1 root root 43680 2006-08-10 CnTable.txt-rwxrwxrwx 1 root root 4929920 2006-08-29 wordTable.txt-rwxrwxrwx 1 root root 4929920 9月15 16:31 GeoWordTable.txt-rwxrwxrwx 1 root root 6664 9月14 16:25 data.xml-rwxrwxrwx 1 root root 9220800 12月22 18:40 LsID.idx
按照純數字進行排序(否則按照字母方式進行排序)
[root@test2 smartlsData]# ll | sort -n-rwxrwxrwx 1 root root 178718700 12月22 18:40 Poi.bal-rwxrwxrwx 1 root root 182348152 12月22 18:40 Poi.bas-rwxrwxrwx 1 root root 18441600 12月22 18:40 Poi.ndx-rwxrwxrwx 1 root root 194056 2006-08-29 wordTableEntry.txt-rwxrwxrwx 1 root root 194056 9月15 16:31 GeoWordTableEntry.txt-rwxrwxrwx 1 root root 20580 12月22 18:40 ACode.ndx-rwxrwxrwx 1 root root 338304 2006-08-10 AnTable.txt-rwxrwxrwx 1 root root 43680 2006-08-10 CnTable.txt-rwxrwxrwx 1 root root 4929920 2006-08-29 wordTable.txt-rwxrwxrwx 1 root root 4929920 9月15 16:31 GeoWordTable.txt-rwxrwxrwx 1 root root 6664 9月14 16:25 data.xml-rwxrwxrwx 1 root root 9220800 12月22 18:40 LsID.idx總用量 390484
Linux wc 的使用
wc -l 行號
wc -m
wc -w
[root@test2 smartlsData]# ll | wc -l13
替換
[root@test2 smartlsData]# ll | tr -d 'A'總用量 390484-rwxrwxrwx 1 root root 20580 12月22 18:40 Code.ndx-rwxrwxrwx 1 root root 338304 2006-08-10 nTable.txt-rwxrwxrwx 1 root root 43680 2006-08-10 CnTable.txt-rwxrwxrwx 1 root root 6664 9月14 16:25 data.xml-rwxrwxrwx 1 root root 194056 9月15 16:31 GeoWordTableEntry.txt-rwxrwxrwx 1 root root 4929920 9月15 16:31 GeoWordTable.txt-rwxrwxrwx 1 root root 9220800 12月22 18:40 LsID.idx-rwxrwxrwx 1 root root 178718700 12月22 18:40 Poi.bal-rwxrwxrwx 1 root root 182348152 12月22 18:40 Poi.bas-rwxrwxrwx 1 root root 18441600 12月22 18:40 Poi.ndx-rwxrwxrwx 1 root root 194056 2006-08-29 wordTableEntry.txt-rwxrwxrwx 1 root root 4929920 2006-08-29 wordTable.txt
[root@test2 smartlsData]# ll | cut -d " " -f 4
rootrootrootrootrootrootrootrootrootrootrootroot
拆分 按照大小 和 行 來拆分
split -b 1m detailWebsite.htm detailWebsite.htm_split -l 5 detailWebsite.htm detailWebsite.htm_
按照第5個字段進行排序
[root@test2 smartlsData]# ll | sort -t : +5n-rwxrwxrwx 1 root root 178718700 12月22 18:40 Poi.bal-rwxrwxrwx 1 root root 182348152 12月22 18:40 Poi.bas-rwxrwxrwx 1 root root 18441600 12月22 18:40 Poi.ndx-rwxrwxrwx 1 root root 194056 2006-08-29 wordTableEntry.txt-rwxrwxrwx 1 root root 194056 9月15 16:31 GeoWordTableEntry.txt-rwxrwxrwx 1 root root 20580 12月22 18:40 ACode.ndx-rwxrwxrwx 1 root root 338304 2006-08-10 AnTable.txt-rwxrwxrwx 1 root root 43680 2006-08-10 CnTable.txt-rwxrwxrwx 1 root root 4929920 2006-08-29 wordTable.txt-rwxrwxrwx 1 root root 4929920 9月15 16:31 GeoWordTable.txt-rwxrwxrwx 1 root root 6664 9月14 16:25 data.xml-rwxrwxrwx 1 root root 9220800 12月22 18:40 LsID.idx
按照純數字進行排序(否則按照字母方式進行排序)
[root@test2 smartlsData]# ll | sort -n-rwxrwxrwx 1 root root 178718700 12月22 18:40 Poi.bal-rwxrwxrwx 1 root root 182348152 12月22 18:40 Poi.bas-rwxrwxrwx 1 root root 18441600 12月22 18:40 Poi.ndx-rwxrwxrwx 1 root root 194056 2006-08-29 wordTableEntry.txt-rwxrwxrwx 1 root root 194056 9月15 16:31 GeoWordTableEntry.txt-rwxrwxrwx 1 root root 20580 12月22 18:40 ACode.ndx-rwxrwxrwx 1 root root 338304 2006-08-10 AnTable.txt-rwxrwxrwx 1 root root 43680 2006-08-10 CnTable.txt-rwxrwxrwx 1 root root 4929920 2006-08-29 wordTable.txt-rwxrwxrwx 1 root root 4929920 9月15 16:31 GeoWordTable.txt-rwxrwxrwx 1 root root 6664 9月14 16:25 data.xml-rwxrwxrwx 1 root root 9220800 12月22 18:40 LsID.idx總用量 390484
Linux wc 的使用
wc -l 行號
wc -m
wc -w
[root@test2 smartlsData]# ll | wc -l13
替換
[root@test2 smartlsData]# ll | tr -d 'A'總用量 390484-rwxrwxrwx 1 root root 20580 12月22 18:40 Code.ndx-rwxrwxrwx 1 root root 338304 2006-08-10 nTable.txt-rwxrwxrwx 1 root root 43680 2006-08-10 CnTable.txt-rwxrwxrwx 1 root root 6664 9月14 16:25 data.xml-rwxrwxrwx 1 root root 194056 9月15 16:31 GeoWordTableEntry.txt-rwxrwxrwx 1 root root 4929920 9月15 16:31 GeoWordTable.txt-rwxrwxrwx 1 root root 9220800 12月22 18:40 LsID.idx-rwxrwxrwx 1 root root 178718700 12月22 18:40 Poi.bal-rwxrwxrwx 1 root root 182348152 12月22 18:40 Poi.bas-rwxrwxrwx 1 root root 18441600 12月22 18:40 Poi.ndx-rwxrwxrwx 1 root root 194056 2006-08-29 wordTableEntry.txt-rwxrwxrwx 1 root root 4929920 2006-08-29 wordTable.txt
[root@test2 smartlsData]# ll | cut -d " " -f 4
rootrootrootrootrootrootrootrootrootrootrootroot
拆分 按照大小 和 行 來拆分
split -b 1m detailWebsite.htm detailWebsite.htm_split -l 5 detailWebsite.htm detailWebsite.htm_
訂閱:
文章 (Atom)