Compile CodeIgniter User Guide on Windows

For users following the development of CodeIgniter, the documentation for the upcoming 3.0 release will be in a different format. Previously the CodeIgniter documentation was created and published in html format. The dev at CodeIgniter have switched to using Markdown and Sphinx for creating the source files to be compiled into html format. This allows for easier syntax highlighting as this is taken care of by Markdown and Sphinx.

Some of the components needed to compile the user guide, are not installed by default on Windows. Here are the steps to getting Ruby, Sphinx, and CI-Lexer installed on Windows XP and Vista/7.

I am using WAMP on my Windows computer for development, so I have CodeIgniter installed in the diretory:

c:\wamp\www\codeigniter\

This folder will be referenced a few times in the lines of code below. If you have CodeIgniter running in a different directory, you will need to change references to those directories.
The first step is to install Python. I found Python version 2.7 was best, because it was the easiest to setup one of the necessary dependencies.

1. Download Python 2.7.3 Installer for Windows.

Install this to the default folder which will be c:\Python27. After the installation completes we need to setup easy_install for Python.

2. For 32bit users you can download setuptools-0.6c11.win32-py2.7.exe and run the installer. For 64bit users you need to download ez_setup.py. Save the file to c:\Python27 (default installation directory). click the Start button in the lower left corner and click Run. In the dialog box type:

cmd

Then press the OK buttons. This will open the Windows command prompt. Then type:

cd c:\Python27\

For 64bit users only type:

python ez_setup.py

Now we have easy_install setup and ready to use so we can install Sphinx. To install Sphinx simple type:

cd Scripts
easy_install sphinx

Now we have Sphinx setup we need to install the PHP syntax highligher for Sphinx. Type the following command:

easy_install sphinxcontrib-phpdomain

The next step is to install the CI Lexer to get syntax highlighting support for CodeIgniter. We need to switch to our CodeIgniter folder that has the user guide sr Type the following command:

cd c:\wamp\www\codeigniter\user_guide_src\cilexer
c:\Python27\python.exe setup.py install

Now everything is setup to compile the CodeIgniter user guide from the Markdown source. The first run will take some time, so be patient. If you were wanting to contribute, and update the user guide, the compilation process on runs on pages that are updated after the first run. This usually only takes a few seconds. The Markdown source is located in the user_guide_src/source folder inside of your CodeIgniter setup. To run the compiler use the following command:

c:\Python27\Scripts\sphinx-build -b html c:\wamp\www\codeigniter\user_guide_src\source c:\wamp\www\codeigniter\user_guide_html

The -b html commandline option tells Sphinx to compile in html format. Now if you look inside your CodeIgniter folder you will see a new folder /user_guide_html. This will be the complete html user guide.

If all is you want is the latest user guide for CI 3.0, you can access it as well at http://codeigniter.com/nightly_user_guide/

WAMP + CodeIgniter + Sparks

I was recently decided to give the Get Sparks project a try. If you are not familiar with the Get Sparks project for Codeigniter, it allows you to download packages/modules for quickly installing into your app. Similar to the idea with PEAR extensions for PHP. I am setting this up on my Windows box using WAMP. I followed the setup instructions from the Get Sparks website, and everything went perfectly fine. I decided to download the popular spark “curl”, and kept getting the:

"You have to install PECL ZipArchive or `unzip` to install this spark."

I kept checking in my php.ini file that php_zip.dll was enabled.  Hmmm…..

So, I decided to create a test script to test the code that was creating this error message. Running the PHP script in the browser ran ZipArchive() successfully. Next, I ran this test PHP script from the command line (CLI). I got a “Fatal Error:  Class ZipArchive not found in …” error. I couldn’t quite figure out why PHP was throwing an error on the CLI and not when run in the browser. A little digging found that PHP run from the command line uses relative paths including php.ini. This the part where WAMP comes into play. For those using WAMP, your php.ini file that is used is located in C:\wamp\bin\apache\Apache2.2.11\bin not where PHP is being executed from. Ah ha! So I went and opened C:\wamp\bin\php\php5.2.9-2 and scrolled down to find:

;extension=php_zip.dll

So I changed this to:

extension=php_zip.dll
php tools\spark install -v1.2.0 curl

Enabling php_zip.dll in the PHP folder of WAMP, and ran the Sparks command again. Success! The spark was downloaded, unzipped, and installed with no more error.

CodeIgniter + UPS Worldship

This is a post I have been to get around to for quite awhile. At work we have UPS Worldship installed on our desktops for shipping out packages. I had written a small php script that could open the UPS Worldship database, and report all of our tracking numbers with links. UPS had switched from being an unprotected Microsoft Access database file, to using a Microsoft SQL (MSSQL database). This kind of broke my little php script I had written, but I was eventual able to work something together. Recently, I installed the latest update UPS Worldship 2010 Version 12. Wouldn’t you know it, broken again. I couldn’t get my little script working again. ODBC access had been removed from this version. I could no longer connect to the MS SQL  dabatabe for UPS Worldship.

Continue reading CodeIgniter + UPS Worldship

CodeIgniter + Chargify

I recently began integrating the Chargify service into a web app I am coding for codeigniter. Chargify is seems to be a slick web service for creating subscription based services. They provide a strong API, and along with a slick web based dashboard (GUI). One of the points on using the API are Chargify postbacks. I did some quick googling and didn’t turn up much in the way of chargify and codeigniter. I did find a great library for integrating the API called ChargeIgniter.

Chargify will send a json array back a POST var to your site. The docs for Chargify don’t state what variable they are submitted as. This is what I came up with.

function post_back(){
 
        $body = file_get_contents("php://input");
 
        $replace = array('[', ']');
        $replacements = array('', '');
 
        $body = explode(',', str_replace($replace, $replacements, $body));
 
       //$body now contains array of subscription ID's
       //Iterate through returned subscription IDs
       foreach($body as $subscription_id){
            $subscription = $this->chargify->get_subscription($subscription_id);
            //Do something here with $subscription details
      }
}

CodeIgniter + Whitepages.com API Library

I was recently working on another Codeigniter project that I needed to grab some phone, address, & map information for plotting on a map. After doing a little searching I found Whitepages.com has provided an API interface for retrieving data via REST. The methods seemed simple enough, and provided an easy way to create a CodeIgniter library to due the dirty work. Continue reading CodeIgniter + Whitepages.com API Library

Codeigniter + Geshi

Geshi is a PHP class to do the heavy lifting for syntax highlighting output to your browswer. Geshi started originally to help users highlight code posted on bulletin board sites. I converted the standard Geshi class into a Codeigniter library. Just a simple as renaming the class and created a few methods to conform to some of the options you’ll find in codeigniter.
Continue reading Codeigniter + Geshi

jQuery Uploadify 2 + CodeIgniter

uploadify-logoCreating useful upload forms having become very popular on the web these days. Many people have found that flash based options create a more rich user experience. I was working on a project recently to allow a user to upload images to a CodeIgniter application. I enjoy using jQuery, and found an excellent flash based uploader in Uploadify. Continue reading jQuery Uploadify 2 + CodeIgniter

CodeIgniter Shopping Cart Library

CodeIgniter is a great PHP framework to work with. One of the items several CodeIgniter Logodevelopers have been asking to be included in the next CodeIgniter release, is a core library for a shopping cart. The library is being added for CI version 1.7.2, and is currently available via SVN on the CodeIgniter website.

UPDATE 09/12/2009: The shopping cart library has now been released as part of the Code Igniter stable release version 1.7.2. You can dowload it at CodeIgniter.com

Continue reading CodeIgniter Shopping Cart Library

Open Flash Chart 2 + CodeIgniter

Many of you maybe familiar with the CodeIgniter (CI) PHP framework. I was asked by a client recently about creating a graph for some data in a report. CodeIgniter LogoLooking through several charting libraries at the CI website, I found a few options listed in the wiki. Open Flash Chart 2 (OFC) seemed like a nice option and was also open source. There was a couple libraries written for CI using Open Flash Chart, but the recent code for OFC has recently changed. Continue reading Open Flash Chart 2 + CodeIgniter