A CSS3 404 Error Page for your Codeigniter Application

How would this look ?

CSS3 404 Error Page for Codeigniter

Instead of the boring

Boring Codeigniter Error Page

Want the Code ? There you go ! Just paste the  code in your application/errors/error404.php.

 

There’s CSS3 Drop Shadow, Text Shadow and Gradient. Nowadays people are using latest browsers and it’s likely that people will see the page like the image for most of the popular browsers .

Of course you can use it for any 404 page for any PHP app OR if you like it you can even replace your apache 404 page (hosting specific) with this one [Just remove the php codes from top]

Killing session on browser close in Codeigniter

It may be well known to some people how to kill sessions on browser close but the default config in codeigniter doesn’t provide so. In lot of application which has admin interface, we don’t want browser to store the session. So it needs to kill the session when browser is closed. Example behavior can be found in yahoo email page.

So how do we do that in Codeigniter ? It’s simple, although this feature is not well commented or documented. Ok, now open system/application/config/config.php file

And find the settings called $config[‘sess_expiration’] under the section Session Variables and put the value like this

That’s it. Now your session will be killed in the event of browser closing.

Form Validation Callbacks in HMVC in Codeigniter

Many of us are using the HMVC extension (Hierarchical Model View Controller) in codeigniter which is available. http://codeigniter.com/wiki/Modular_Extensions_-_HMVC

HMVC helps developing modular apps in a very convenient way. All the things work simply fine just like a clean CI installation. There’re 1 or two exceptions which i have found. One is the callback of Form_validation class. If we are making some forms like registration we check emails and usernames and we do it in the form validation class using callbacks. If we look at the basic callback structure when validating forms from CI documentation, it appears like.

 

But this callback will not simply work. Some of my precious hours went why it was not working. Then i navigated the Form_validation.php in /system/libraries folder around line 580 which looks like

 

The function – method_exists returns false even if the callback function is there in the Controller and after all in the CI loader object. So it came out from the forum that you have to do a little extension to Form Validation class which is

 

And when running the validation like in earlier code

you have to provide an addition $this as a parameter to run method. which will look like

Now, your validation callbacks will work perfectly.

Another note, if you’re trying to access a public variable of a controller via the get_instance() in hooks , you’ll have to write in your controller like this.

CI::instance()->var_name = “Some Value”;

May be there are some other required adjustments when using HMVC, but i came across this two time killing adjustments.

Python for Codeigniter developers

So, you use codeigniter and  want to develop something in python ? And you have following things in mind :

1. An MVC framework which has almost zero installation.

2. A framework that behaves quite in the same fashion like Codeigniter.

3. Small footprint

4. Has Similar or even easier libraries than codeigniter.

5. And you want something which works both in Windows/mac/Linux.

You have probably heard of developing web apps using python and python frameworks like django. But the installation on your windows machine or linux machine along with apache is a big headache. You want something short and sweet, something works out of the box.

OKKEYS, the name is web2py – an enterprise web development framework – entirely written in python. If i start to write all good things about it, the post might become really big. So let’s jump into the installing of this framework and see some actions.

Things needed

Python 2.5.2

web2py Framework

Steps :

1. For windows XP, install python 2.5.2 – the .msi package. It’ll probably install in your c:/Python25 directory. Now you have to add 2 environment variables.  Right click “My Computer” -> Properties ->Advanced -> Environment Variables (at the bottom).  Under the “System Variables” double click “Path” and put ;C:\python25;C:\python25\scripts at end of the Variable Value.  For windows users, a restart is sometimes necessary to propagat

For Ubuntu, if you have already installed python latest version which is 3.X, you have to install python 2.5.2. They can run simultanously. So in terminal,

sudo apt-get install python2.5

2. Unzip the folder from you have downloaded http://www.web2py.com/examples/static/web2py_src.zip to some place. May be c:/web2py or in Ubuntu /home/username/web2py [or anything you like ]

3. Now it’s assumed that python runs from command prompt or terminal. To verify type python in command prompt in windows (not in CYGWIN or any Bash Shell) or in terminal in linux. If you get something like this

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on
win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>>

It means you have successfully installed python. Now from the command prompt go to your web2py directory using cd web2py

4. TIME FOR ACTION!!! Now that you’re into the web2py directory, simply type

python web2py.py

You’ll get a greeting screen and the a screen like this both in windows and linux.


web2py_server

It asks for an admin password. Choose anything simple for the time being and hit “Start Server”. That’s it. A window will open with the web2py admin panel like this.

welcome_1247640873997

Alright, from this point, i think you can start playing with the links and most of the options are self explanatory. Click the links, go deeper and have fun with an easy MVC framwork in Python.

Keep discovering!!

Upload all your files in lowercase in Codeigniter

You might all probably know that *nix systems treat myPic.jpg and MYpic.jpg different while windows systems don’t . So there’s always been a need to deal with filenames across different systems. We upload files which may be in lower case, uppercase or a mixture of both. This sometimes kills our valuable time and effort. To deal with files uploading, edit and delete if we always assume that file names are in lowercase, it’s lot better unless we have significant reasons to keep the case of the files intact.  Codeigniter has a good uploading library which resides at /system/libraries/Upload.php. But unfortunately there’s no property of the uploading class that lets us to upload the file in lower case. So, the shortcut is to override the native method by your own library. When we initialize a library CI tries to find it within your application directory and then it’s System directory. So if we make a class MY_Upload extending CI_Upload, it can do the job. This is no trick, it’s documented on CI. So, now , we just need to override two functions in the CI_Upload class. These are _prep_filename and get_extension Here is how it looks




		


The code can be downloaded from here

my_upload

Unzip and put it in your /system/application/libraries directory.

Now for any upload you do using CI’s uploading class, will produce lowercased filenames.

Is Kohana moving faster than Codeigniter ?

Traffic Codeigniter VS KohanaPHP

Look at the Alexa graph above. What do u think ?  

I’ve been using Codeigniter in Mid and Fairly Big project for over a year and a half. Kohana was released before i started but the amount of online support and tutorials and an active company development (EllisLab) made me decide using CodeIgniter. But I keep checking updates on Kohana because it has lot of extra features over CI. It’s Strictly PHP5 OOP and has libraries like ORM which doesn’t exist CI’s distribution. Just out of curiosity, i went to Alexa and compared the traffic for CI and KohanaPHP and it really surprised me. Kohana is way ahead in terms of traffic. What does that mean? People are more involved with Kohana than CI ? Well, apparently YES. Kohana is community driven development. In CI, user contributes as addons to the Framework, which is ok. But when there’s an active driving force by the community, it’s better, at least i think. 

Moreover I read some articles how to easily use Zend in Kohana in the beyondcoding.com. So that makes me think of leaning towards Kohana for my next projects. There are of course ways to use CI with Zend though but the integration method of Kohana with Zend looked neat. It won’t get much tough to switch to Kohana because it was originally based on CI. And default design pattern in Kohana is Factory (as it appears) while CI is singleton. Of course I’ll need to analyze some more benchmarks for scalability and other features before shifting focus. 

Partners Section:

depfile password Depfile Premium Account Depfile Premium Depfile Premium Account Depfile Premium Depfile Premium Account Depfile Premium Account dep file Dep file dep file dep file dep file dep file Depfile Premium Account Depfile Premium yify torrent empire torrent yify vikings season 4 auto clicker autoclicker slender the eight pages he gift torrent walking dead torrent the walking dead torrent fl studio 12 torrent