使用CI(codeigniter)框架时要注意的地方

特别强调:

使用CI(http://codeigniter.org.cn/)框架时,整个项目中,文件的命名决不可相同,即使这个同名的文件内容不同,或存放在不同的位置。

惨痛经历:

①在controller、model目录中,均有同名文件test.php时,在controller/test.php文件中使用 $this->load->model('test'); 会发生错误,可能服务器只是返回500错误,很难通过日志、报错等方式找到此错误原因。

②在使用phpqrcode(https://github.com/dwisetiyadi/CodeIgniter-PHP-QR-Code)来制作二维码时,controller目录中有qrcode.php文件,在此文件中,即使单纯引用phpqrcode使用示例也会不成功,服务器返回500错误,很难通过日志、报错等方式找到此错误原因(与该资源目录中的/bindings/tcpdf/qrcode.php重名)。

Working with RESTful Services in CodeIgniter

Part 1 – Creating a RESTful API

Step 1: Setting up the Demo

Firstly you need to download the codeigniter-restserver code from GitHub and extract it and move the code to your server.

When you open the folder, you will see an entire CodeIgniter install, which is there to power the demo. This allows people to have a play with the REST demo before integrating with your existing application.

Open up “application/config/config.php” and set the base_url to get links working. This base_url will be different for everyone and depends entirely on where you uploaded your files.

Step 2: The URLs

With the files extracted and the base_url set, we are ready to load up our RESTful CodeIgniter installation, and have a look at the demo supplied with it. Browse the base URL, which by default is: 继续阅读“Working with RESTful Services in CodeIgniter”

KNDB Session For CodeIgniter

KNDB Session

Native Session makes good use of PHP’s native session handling abilities, but it does not allow the use of a database for session storage. KNDB Session (which stands for Kirilisa’s Native Database session) is a hybrid which is based upon Native Session (with some notable changes) but allows use of databases via PHP’s ability to store sessions in a DB. 继续阅读“KNDB Session For CodeIgniter”

Replacing CodeIgniter’s session by PHP’s Native Session

For last 8 months, I have been working on a web application. We are developing the application based onCodeIgniter framework. In our project there are normal web version and mobile view version. Some days ago we noticed that, some people can’t login their account via mobile version though there username & password are correct. After debugging and digging the problem we found that in iPod Touch 2G/3GS Safari browser, this problem is happening.

We are using CodeIgniter’s built in session library and that is different than normal PHP’s session. We found that for each visit of the user, the server can’t track the session and regenerating new session id each time. Very weird situation for us. As we coded all over based on CodeIginter’s session library’s function so its not optimal solution for us to remove the codes and use PHP’s native session. Because in that case there is high possibility to generate new bugs. After lots of searching in the net at last we found a wrapper class for CodeIgniter. 继续阅读“Replacing CodeIgniter’s session by PHP’s Native Session”