Tag Archives: codeigniter

How to remove (redirect) trailing slashes from URLs using .htaccess

Created at: December 22, 2015; Last update: February 19, 2016

Well… I see a lot of questions regarding SEO friendly URLs, and also regarding the problem with URLs that have trailing slashes which show the same content as the URLs without trailing slashes. Although I really hope that the search engines are smarter than treating those URLs as duplicate content, I feel there is the need to know how to redirect them to the non-trailing slashes URLs.

So here it is. You open .htaccess, and you should have in it the following:

This should work for anything, not just CodeIgniter. Hope this helps…

Multiple file upload in CodeIgniter using MY_Upload – meet my library extension

Created at: January 12, 2015; Last update: January 15, 2015

The CodeIgniter’s upload library is great. But it only works for single file uploads. So I thought that an extension to allow for multiple files upload would be a nice addition to CI’s upload library. Hence, allow me to present you MY_Upload. The extension is hosted on Github. So go there and download it. Continue reading

Image_nation – a new CodeIgniter image library for automatic cropping and/or resizing of images

Created at: December 17, 2014; Last update: December 18, 2014

Please allow me to introduce to you another one of my libraries. This one is good for manipulating images. Every site that has images for products/posts/pages use at least two different sizes (if not more…): one for a thumbnail and one for featured images (and maybe one for a slideshow, etc.).

This library will allow you to automatically create the different dimensions of the images right after you upload it. All you have to do is set the width and height of the images you want created and give the library the path to the image that you want processed. Continue reading

Meet my Matches – a PHP CLI script meant to expedite Codeigniter development

Created at: June 6, 2014; Last update: June 6, 2014

matches-logoMaybe it’s too early to make the announcement, so I hope you will all be gentle with this script. I’m not saying this is THE SOLUTION to your needs, but if you use it, I sure hope that you will also help further its development with a pull request or maybe some advice. Continue reading

Codeigniter – Convert an array to object

Created at: May 15, 2014; Last update: May 15, 2014

I usually use the results that come from the models as objects (not as arrays). However, there are moments when I need to work with the results before sending them to the view. In this case, getting the results from the model as an array is preferable. But, when I send them to the view, I would like to work with objects. So now I need to convert the array into an object. Continue reading

How to use a “Cookbook” with Codeigniter

Created at: April 18, 2014; Last update: April 18, 2014

cookbookI was asked to do a review for Codeigniter 2 Cookbook, written by Rob Foster and published by Packt Publishing (to be honest, I actually asked to review the book to get it for free).

I haven’t managed to keep the promise of reviewing the book in due time, but suddenly I realised that every now and then I return to the book to uncover a new programming style that makes me say: “Ahaaa”. Continue reading

Codeigniter: Install Swift Mailer using Composer

Created at: March 11, 2014; Last update: March 12, 2014

Composer is the new kid on the block. Composer is a tool used to distribute and manage packages. I first heard of it while taking a look at Laravel. Composer’s power consists in the fact that the packages distributed by it are framework agnostic. Continue reading

Forms? Keep the validation rules inside the model

Created at: February 14, 2014; Last update: May 15, 2014

As always, when talking about forms we also talk about validation. For a long time I’ve validated the forms inside the controllers because it is fast and simple – no more browsing between files.

But after a while you find yourself having a controller which is becoming more complex and bigger. So why not keep at least the validation rules somewhere else? Continue reading

Codeigniter: My MY_Model or “How not to repeat yourself”

Created at: December 5, 2013; Last update: December 5, 2013

Often times I find myself doing the same queries over and over again for each table used by an application. This is why I needed to create an “universal” model in order to avoid repetition. Codeigniter lets you do that by allowing you to create a “MY_Model” inside the core folder of your application. Continue reading