Program
FuelPHP FrameWork 進入! Enter~~
by admin on 一月.05, 2012, under PHP & MYSQL
安裝之前有說過哩:請參考 FuelPHP FrameWork 初體驗~~
之前說過 作者將APP 整個包在FrameWork 內的蠢話. 我可以不承認嗎XDD
其實算是給開發人員快速進入,實作體驗FrameWork用的.
如果要自行快速分離請先參考 同事強做:【程式筆記】建立一個FuelPHP的應用程式Git Repository
如果這樣不能滿足你,接下來江示範如何調整.
(continue reading…)

FuelPHP FrameWork 初體驗~~
by admin on 十二月.27, 2011, under PHP & MYSQL
FuelPHP is a simple, flexible, community driven PHP 5.3 web framework based on the best ideas of other frameworks with a fresh start.
FuelPHP 衝著他以php 5.3 並以namespace 方式開發,輕量化FrameWork趕快來試用看看吧.
安裝
安裝方式不免俗來了,快速按裝.(不錯唷)
1 2 3 4 5 6 7 | $ curl get.fuelphp.com/oil | sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 244 100 244 0 0 240 0 0:00:01 0:00:01 --:--:-- 1257 Password: $ |
Gearman Install on Ubuntu
by admin on 十一月.18, 2011, under PHP & MYSQL
gearman 在ubuntu 上不知哪個版本已無提供libdrizzlea模組.
導致要使用myql作為資料源已無法使用.
以下是自行編譯安裝方式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | $ sudo -s $ add-apt-repository ppa:gearman-developers/ppa $ apt-get update $ apt-get install libevent-dev gearman libgearman4 libgearman-dev libdrizzle0 libboost-program-options-dev libboost1.46-dev libboost-program-options-dev uuid-dev g++ libmemcache-dev libcloog-ppl0 $ wget https://launchpad.net/ubuntu/lucid/+source/libdrizzle/0.7-1/+files/libdrizzle_0.7.orig.tar.gz $ tar zxvf libdrizzle_0.7.orig.tar.gz $ cd libdrizzle-0.7/ $ ./configure $ make $ make install $ cd.. $ wget http://launchpad.net/gearmand/trunk/0.14/+download/gearmand-0.14.tar.gz $ tar zxvf gearmand-0.14.tar.gz $ cd gearmand-0.14/ $ ./configure libdrizzle_CFLAGS="-I/usr/local/include" libdrizzle_LIBS="-L/usr/local/lib -ldrizzle" $ make $ make install $ cd .. $ wget http://pecl.php.net/get/gearman-0.8.0.tgz $ pecl install gearman-0.8.0.tgz $ vi /etc/php5/conf.d/gearman.ini ==== 加入 ==== extension=gearman.so $ vi /etc/init.d/gearman-job-server =====編輯==== prefix=/usr/local PARAMS="--queue-type=libdrizzle --libdrizzle-host=mysql主機ip --libdrizzle-user=mysql帳號 --libdrizzle-password=mysql主機ip --libdrizzle-db=gearman --libdrizzle-table=gearman_queue --libdrizzle-mysql" ====加上註解==== #test -f /etc/default/gearman-job-server && . /etc/default/gearman-job-server ======================== DB gearman 要自行在mysql新增 資料表他自行會建立 $ service gearman-job-server start |
MongoDB Sharing
by admin on 八月.18, 2011, under PHP & MYSQL
MongoDB Sharing

可以先看看官網介紹:Sharding Introduction
Shards 類似 Mysql 的Data nodes.
Config Servers 類似 Mysql 的Management node.
Routing Processes 類似 Mysql 的SQL node.
(continue reading…)
MongoDB VS Mysql 簡單測試.
by admin on 八月.03, 2011, under PHP & MYSQL, 未分類
廢話不多說.
MongoDB 使用 MongoDB Object Document Mapper測試.
Mysql 使用 Object Relational Mapper測試.
MongoDB部分:
config.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | < ?php require_once __DIR__ . '/../../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php'; use Doctrine\Common\ClassLoader, Doctrine\Common\Annotations\AnnotationReader, Doctrine\ODM\MongoDB\Configuration, Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver, Doctrine\MongoDB\Connection, Doctrine\ODM\MongoDB\DocumentManager; $classLoader = new ClassLoader('Doctrine\Common', __DIR__ . '/../../lib/vendor/doctrine-common/lib'); $classLoader->register(); $classLoader = new ClassLoader('Doctrine\ODM\MongoDB', __DIR__ . '/../../lib'); $classLoader->register(); $classLoader = new ClassLoader('Doctrine\MongoDB', __DIR__ . '/../../lib/vendor/doctrine-mongodb/lib'); $classLoader->register(); $classLoader = new ClassLoader('Symfony', __DIR__ . '/../../lib/vendor'); $classLoader->register(); $classLoader = new ClassLoader('Documents', __DIR__); $classLoader->register(); $config = new Configuration(); $config->setProxyDir(__DIR__ . '/Proxies'); $config->setProxyNamespace('Proxies'); $config->setHydratorDir(__DIR__ . '/Hydrators'); $config->setHydratorNamespace('Hydrators'); $config->setDefaultDB('doctrine_odm_sandbox'); //使用safe模式 $con = new Connection('localhost',array('safe'=>true, 'w' => 2,'wtimeoutMS' => 2000)); //使用一般模式 //$con = new Connection('localhost'); $reader = new AnnotationReader(); $reader->setDefaultAnnotationNamespace('Doctrine\ODM\MongoDB\Mapping\\'); $config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents')); $dm = DocumentManager::create($con, $config); |
Lua for PHP 實測
by admin on 八月.02, 2011, under Lua, PHP & MYSQL
繼上一篇 Lua for PHP 安裝,現在來是實測Lua 速度.
素聞Lua 執行效能速度之優異不論是陣列字串運算處理皆在PHP之上,這篇先主要針對Array做實測.
index.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | < ?php $array_a = array(); for($i=1; $i<100000; $i++) { $array_a[$i]= rand(1,9999); } //新增Lua物件 並載入test.lua $lua=new plua('test.lua'); //複製一個陣列並丟到Lua 物件內 $array_b = $array_a; $lua->array_b = $array_b; //測試PHP物件排序效能 $mtime = explode(' ', microtime()); $starttime = $mtime[1] + $mtime[0]; //var_dump($array_a); rsort($array_a); //var_dump($array_a); $mtime = explode(' ', microtime()); $times=number_format(($mtime[1] + $mtime[0] - $starttime), 8); //顯示PHP執行結果所需時間 echo "PHP rsort time $times \n"; $mtime = explode(' ', microtime()); $starttime = $mtime[1] + $mtime[0]; //var_dump($array_b); //測試Lua物件排序效能 $array_b = $lua->test(); //var_dump($array_b); $mtime = explode(' ', microtime()); $times=number_format(($mtime[1] + $mtime[0] - $starttime), 8); //顯示Lua執行結果所需時間 echo "Lua array sort time $times \n"; |
test.lua
1 2 3 4 | function test()
table.sort( array_b )
return array_b
end |
Lua for Windows 開發 筆記
by admin on 八月.01, 2011, under Lua
下載:Lua 5.2.0-work2 – Release 1
先參考此篇教學Using Lua with C#並去 LuaInterface 下載回來,看了一下注意事項好像必須 Microsoft Visual C++ 2008 可轉散發套件 (x86) 一併下載回來比較保險.
後來找到 luaforwindows Windows底下Lua整合套件.
(continue reading…)
MongoDB 新手入門筆記~
by admin on 七月.28, 2011, under PHP & MYSQL
Linux 安裝:
1 2 | $ apt-get install mongodb-server mongodb-dev $ sudo pecl install mongo |
編輯php設定檔 加入 extension=mongo.so
php -m 即可以看到安裝好的擴充套件.
FreeBSD 安裝:
1 2 | $ cd /usr/ports/databases/mongodb ; make install clean ; $ cd /usr/ports/databases/pecl-mongo ; make install clean ; |
php -m 即可以看到安裝好的擴充套件.
編輯/etc/rc.conf:
1 2 | #mongodb mongod_enable="YES" |
管理工具:
可先參考 Admin + UIs
個人推薦:Rock Mongo
JMongoBrowser
介面漂亮又方便.
Lua for PHP 安裝
by admin on 七月.20, 2011, under FreeBSD, Lua, PHP & MYSQL
主要安裝擴充套件資訊 LUA for PHP
使用 Plua 為安裝源.
Linux 安裝方式:
先安裝好 lua:
1 | $apt-get install lua5.1 liblua5.1-0-dev |
先下載並解開:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | $ cd /tmp $ wget http://plua.googlecode.com/files/plua-1.0.0.zip $ tar zxvf plua-1.0.0.zip $ cd plua $ phpize $ whereis php-config php-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz $ rm -f include $ ln -s /usr/include/lua5.1 include $ ln -s /usr/lib lib $ cd lib $ ln -s /usr/lib/liblua5.1.a liblua.a $ ln -s /usr/lib/liblua5.1.so liblua.so $ cd .. $ make $ make install Installing shared extensions: /usr/lib/php5/20090626/ $ |
自行編輯php 設定 增加extension=plua.so
FreeBSD 安裝方式:
先安裝好 lua:
1 | $cd /usr/port/lang/lua ; make install clean ; |
先下載並解開:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | $ cd /tmp $ wget http://plua.googlecode.com/files/plua-1.0.0.zip $ tar zxvf plua-1.0.0.zip $ cd plua $ phpize $ whereis php-config php-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz $ rm -f include $ ln -s /usr/local/include/lua51 include $ ln -s /usr/local/lib/lua51 lib $ cd .. $ make $ make install Installing shared extensions: /usr/lib/php5/20090626/ $ |
自行編輯/usr/local/etc/php/extension.ini 設定 增加extension=plua.so
Doctrine 2 Stable Release!!
by admin on 十二月.29, 2010, under Doctrine
2010-12-21 這天 Doctrin2 釋出正式穩定版.
Doctrine 2 First Stable Release
這個版本工程之浩大於2008就開始開發,歷經2年半的時間努力.核心開發團隊五人於最後一年最後整合應用保有 Doctrine 1功能並重構並且導入新的DataMapper.
What is new in Doctrine 2?
* DQL is now a real language inside Doctrine, based on an EBNF that is parsed and transformed to SQL. Benefits of this refactoring are readable error messages, the generation of an AST that allows us to support many different vendors and powerful hooks for developers to modify and extend the DQL language to their needs. DQL can either be written as a string or be generated using a powerful QueryBuilder object.
* Your persistent objects (called entities in Doctrine 2) are not required to extend an abstract base class anymore. Doctrine 2 allows you to use Plain old PHP Objects.
* The UnitOfWork is not an alibi-pattern as implemented in Doctrine 1. It is the most central pattern in Doctrine 2. Instead of calling save() or delete() methods on your Doctrine_Record instances you now pass objects to the data mapper object called EntityManager and it keeps track of all changes until you request a synchronisation between database and the current objects in memory. This process is very efficient and has consistent semantics. This is a significant improvement over Doctrine 1 in terms of performance and developer ease-of-use.
* There are no code-generation steps from YAML to PHP involved in the library anymore. YAML, XML, PHP and Doc-Block Annotations are four first-class citizens for defining the metadata mapping between objects and database. A powerful caching layer allows Doctrine 2 to use runtime metadata without relying on code-generation.
* A clean architecture and powerful algorithms make Doctrine 2 magnitudes faster than Doctrine 1.
* Doctrine 2 supports an API that allows you to transform an arbitrary SQL statements into an object-structure. This feature is used by the Doctrine Query Language itself and is a first-class citizen of the library. It essentially allows you to make use of powerful vendor-specific features and complex SQL statements without having to cirumvent the ORM completely.
* Inheritance is not akward anymore. There are now three different types of inheritance to choose from: Mapped Superclasses, Single-Table- and Joined-Table-Inheritance.
* Many more features, just see the reference guide on what is possible with Doctrine 2.
(continue reading…)