Tutorials

How do I deploy my CodeIgniter applications using Subversion

Posted in Tutorials on April 16th, 2010 by admin – Be the first to comment

This little guide is intended to explain how do I update some of my applications running on development environment or production using Subversion and a simple hook.

This idea was based on the great article published time ago by Imran Nazar about automating deployment with Subversion.

Basically it updates a SVN repository in your development environment each time you commit a message with a signal string like *DEPLOY*. This assumes that you have a copy of your repository in your development environment.

read more »

Related searches:

  • codeigniter deployment
  • how to deploy svn from remote server
  • svn deployment
  • svn deploy linux
  • how to deploye codeigniter in customer server
  • codeigniter SVN
  • php svn post-commit deploy script
  • codeigniter db deployment
  • php remote deploying ssh
  • script deployment with subversion

How do I display result or error messages in CodeIgniter application

Posted in Tutorials on September 18th, 2009 by admin – 12 Comments

Sometimes we need to display general messages or error messages to the user noticing about certain action, for example on success or failure.

Imagine you are submitting a form and then creating or updating the data in the database. You may be interested in noticing the user about the result for that action.

This is the way I use to display general messages (and error messages) in CodeIgniter application.

The result

This is how my message looks.

codeigniter-display-message

How to display the message?

Now, in order to display that information message, I do the following:

First, when submitting the form, after validating it, in the controller I call the model function that will save the entity (license in this case). I make sure that model function returns a result, and FALSE result in case of error (I usually return an array result on success with an ID element with the last inserted identifier if the result was an insert, or the just updated entity identifier if it was an update, but that is out of this article’s scope).

Controller

Imagine we are calling the following method in the controller:

$result = $this->license_model->create_or_update_license($agent_id, $state, $data);

Then, we need to see if that was an error or not. Based on that result, I will use CodeIgniter’s set_flashdata function in the Session library, as follows:

if ($result)
{
	$this->session->set_flashdata( 'message', array( 'title' => 'License created', 'content' => 'License has been saved sucessfully', 'type' => 'message' ));
	redirect('agent/licenses');	

} else
{
	$this->session->set_flashdata( 'message', array( 'title' => 'License error', 'content' => 'License could not be saved', 'type' => 'error' ));
	redirect('agent/licenses');
}

Once the Flash message has been set, I redirect the user to the form or a list of results. That is needed in order to get the flash working (you cannot just load the view in this case… well, you can but this method will not work in such case). When comparing $result TRUE or FALSE, please notice the different value for type. I am using type=message for successful messages, and type=error for error mesages.

View

In the view, just above the form, I use this snippet.



<?= @flash_message() ?>

To keep it simple, I just added @ to avoid any error message, but probably if you are looking for a better coding practice and you may not do that.

A Helper

Then, I put this flash message function as a helper function, so it is available when calling from the view.


function flash_message()
{
	// get flash message from CI instance
	$ci =& get_instance();
	$flashmsg = $ci->session->flashdata('message');

	$html = '';
	if (is_array($flashmsg))
	{
		$html = '<div id="flashmessage" class="'.$flashmsg[type].'">
			<img style="float: right; cursor: pointer" id="closemessage" src="'.base_url().'images/cross.png" />
			<strong>'.$flashmsg['title'].'</strong>
			<p>'.$flashmsg['content'].'</p>
			</div>';
	}
	return $html;
}

jQuery part

Finally, I added a simple effect to slide down and blink the message box, and adding the close functionality with a simple jQuery function. You can do something like this. Of course, you can modify it or just avoid using the jQuery effect if it is desired.


// first slide down and blink the message box
$("#flashmessage").animate({top: "0px"}, 1000 ).show('fast').fadeIn(200).fadeOut(100).fadeIn(100).fadeOut(100).fadeIn(100);

Some CSS styling

Finally, just add some CSS styling for #flashmessage, using message or error class names.


.message{
    border:1px solid #CCCCCC;
    width:300px;
    border:1px solid #c93;
    background:#ffc;
    padding:5px;
    color: #333333;
    margin-bottom:10px;
}

Enjoy it.

Related searches:

  • codeigniter error to email
  • codeigniter flash message
  • codeigniter error message
  • codeigniter error messages
  • codeigniter set_flashdata
  • codeigniter message
  • codeigniter messages
  • flash message in CodeIgniter
  • flash message codeigniter
  • codeigniter flash messages

Simple Form Generation in CodeIgniter

Posted in Tutorials on August 2nd, 2009 by admin – 12 Comments

If you are using CodeIgniter, as well as any other PHP framework, you may notice that building CRUD forms is one of the most bother and routine tasks. Probably 80% of general web applications uses CRUD (create/read/update/delete).

In CodeIgniter, you can use any of the form generation libraries.

One of my preferred libraries is Form Generation Library by Frank Michel (see @macigniter’s thread here). It allows you to create clean XHTML forms with CodeIgniter. See demo here.

Using Form Generation Library

So, in order to use this library, you need to download it from here (library files only is enough if you don’t want the entire site structure).

read more »

Related searches:

  • codeigniter crud generator
  • codeigniter form library
  • codeigniter form
  • codeigniter 2 crud
  • crud codeigniter 2 0
  • codeigniter form generation library
  • CRUD codeigniter 2
  • codeigniter form generation
  • crud codeigniter download
  • CODEIGNITER CRUD

Debug CodeIgniter AJAX applications with FireIgnition

Posted in Tutorials on July 26th, 2009 by admin – Be the first to comment

image

If you are building rich AJAX applications with CodeIgniter, you may encounter that traditional debug utilities may not be suitable for debugging tasks that involve AJAX function calls.

Firebug addon with its FirePHP plugin can enhance your debugging process.

read more »

Related searches:

  • codeIgniter ajax
  • how to debug codeigniter
  • debug codeigniter
  • codeigniter debug ajax
  • how to debug with ci
  • codeigniter ajax debug
  • debugging codeigniter ajax with firebug
  • debug codeigniter jquery
  • debug codeigniter firephp
  • codeigniter and firephp

Remove index.php from URL in CodeIgniter application

Posted in Tutorials on July 25th, 2009 by admin – 9 Comments

CodeIgniter is designed to be search-engine and human friendly. By default, index.php will be included in the URLs, but it can be easily removed using .htaccess file with some rules.

read more »

Related searches:

  • codeigniter no index php
  • inurl:index php?from=
  • codeigniter iis
  • codeigniter 2 0 index php headache
  • index php rename in codeigniter without htaccess
  • iis hide index php
  • htaccess codeigniter iis
  • hide index php from URL
  • hide index php codeigniter 1 7 2
  • config php codeigniter iis