Codeigniter 2.20 – Autocomplete in Sublime Text

Back to CodeIgniter Tutorials

Sublime text is a powerfully simple text editor that makes coding part of the development easier than it once was. Autocomplete for PHP, HTML, CSS Javascript is handled easily by Sublime text. But as I am writing, there is no native support for Codeigniter.

Do you have to manually type the following lines all the time?

If you suddenly can’t remember the name of a library or you have just started learning Codeigniter and want to explore all commands, you might probably have to find an IDE with autocomplete facility.

Fortunately for us, there is an amazing package for sublime text that allows Autocomplete. In this post, I will show you how to set up Sublime Text to have autocomplete facility for Codeigniter.

  1. Download Sublime Text 2 Completions for CodeIgniter and Unzip.
  2. There will be a file named PHP-codeigniter.sublime-completions.
    You will have to copy this file to two locations (to be sure). One is the sublime packages folder and the other is as according to the Github page.
  3. First, open sublime text and go to Browse Packages as shown below:
    Sublime text browse packages
    Sublime text browse packages

    A folder with the following path will open:

    C:\Users\USERNAME\AppData\Roaming\Sublime Text 3\Packages

    or simply

    …\Sublime Text (n)\Packages

  4. Copy the (PHP-codeigniter.sublime-completions) file and paste the following folder which you can find using:

    ..\Sublime Text (n)\Packages\User

Next, open up Sublime Text and you will be able to use Autocomplete. for example, see the following image.

CodeIgnoter Autocomplete
CodeIgniter Autocomplete

That’s it! You now have autocomplete facility within Sublime Text. Please note that with changes to codeigniter in future, this post might become obsolete. If for some reason, it does not work, then let me know in comments.

I hope this guide helped you.

Please Share and Comment

Back to CodeIgniter Tutorials

Codeigniter 2.20 – Learn how to make live search using Codeigniter

codeigniter live search

Back to CodeIgniter Tutorials

You may have seen live search <input> boxes all over the internet. Here is how to make that live search in reference to the design of the following image using Codeigniter 2.20 and 3.0.

codeigniter_json_encode1
Example of live search using input box

This technique will use the following steps.

  1. User types in an input box.
  2. A call is sent to controller with input parameters taken from input box.
  3. Controller calls model.
  4. Model searches database and returns with or without an input to the controller.
  5. Controller uses json_encode() on result of model and sends the data to view.
  6. View receives data from controller and shows it on the interface.

Please note that you must have a working codeigniter installation and database connection. You can use XAMPP for that if you need to test.

MODEL

Create a table of hotels and use the following model

VIEW

Then set up a view and add jquery and bootstrap support along with bootstrap-typeahead

 Controller

Finally, use the following code in a controller function to call the model from view.

With this done, you will now be able to use live search in your interface.

I hope you find this helpful. If you have any questions, then please post in the comments. I will be glad to help.

Kind Regards,

Codeonion

Back to CodeIgniter Tutorials