I'm enthusiastic and passionate about web development and design in all it's forms and love to build application with efficient and simple methods

Monday, October 5, 2015

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu

8:40 PM Posted by Codeinterpreter No comments
About LAMP

LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Since the virtual private server is already running Ubuntu, the linux part is taken care of. Here is how to install the rest.

Wednesday, July 8, 2015

Vagrant Rails Puppet. Organizing Manifests with Modules

6:41 PM Posted by Codeinterpreter No comments
Built Puppet Manifests using modules allow us to organize our manifests into logical pieces, much as we do with modules in Ruby or packages in Java. We’ve already gotten started on a module structure for our Apache-related Puppet configuration by creating a modules/apache2/files directory holding our customized apache2.conf


in your puppet folder create this filer manifests/site.pp

apply your puppet and check it's working: sudo puppet apply --verbose manifests/site.pp

 Exec {
  path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
 include apache2

create your virtual host in here: modules/apache2/files/massiveapp.conf

  ServerName myapp
  DocumentRoot "/var/myapp/current/public/"
  CustomLog /var/log/apache2/myapp-access_log combined
  ErrorLog /var/log/apache2/myapp-error_log

In your puppet folder built this directory files: modules/apache2/manifests/init.pp
in init.pp create this config:

package {
  ensure => present,
  before => File["/etc/apache2/apache2.conf"]

service {
  ensure => true,
  enable => true,
  subscribe => File["/etc/apache2/apache2.conf"]

file {
  owner => root,
  group => root,
  mode => 644,
  source => "puppet:///modules/apache2/apache2.conf";

  source => "puppet:///modules/apache2/massiveapp.conf",
  owner => root,
  group => root,
  notify => Service["apache2"],
  require => Package["apache2"];

file {
  owner => root,
  group => root,
  mode => 644,
  source => "puppet:///modules/apache2/apache2.conf";
  source => "puppet:///modules/apache2/massiveapp.conf",
  owner => root,
  group => root,
  notify => Service["apache2"],
  require => Package["apache2"];

Wednesday, July 1, 2015

Deploy Code with Capistrano

7:34 AM Posted by Codeinterpreter No comments
Developing a web application isn’t going to do much good if we aren’t able to find a way for the world to see it. For other web frameworks,this can often be a tedious and time-consuming process. Application code needs to be updated, database schemas need to be migrated, and application servers must be restarted. We could do all of this manually by ssh into the server, pulling the latest code from the repository, running database migration tasks, and restarting the application server. Even better, we could write some shell scripts that would automatically perform these tasks for us. But why do all that when we could be spending time improving App instead?

The good news is that we don’t have to do all that.Battle-tested and used for deploying many of today’s Rails apps, Capistrano (originally authored by Jamis Buck and now ably maintained by Lee Hambley) is the tool that Rails developers have used for years to get their applications from development to production on a daily basis. It was built from the start for deploying Rails applications, and it has all the tools we need to get App deployed and to help keep deployments running smoothly afterward. Capistrano’s library of tasks, plugins, and utilities has also evolved over the years with the rest of the Rails ecosystem, and thus Capistrano continues to meet the deployment needs of Rails applications both new and old.


Add capistrano gem to development environment

group :development do
gem 'capistrano', '~> 2.11.2'

Don't forget to bundle update. and check your capistrano instalation by: cap -H

Generate necessarily file with :

capify .

// Will generate:
[add] writing './Capfile' // created in project’s root directory and takes care of loading Capistrano’s default tasks
[add] writing './config/deploy.rb' // Rails asset pipeline tasks, and our primary deployment script
[done] capified!


Example of config settings in /config/deploy.rb
require 'bundler/capistrano'

// Configurations from repository
set :application, "massiveapp"
set :scm, :git
set :repository, "git://github.com/myapp/myapp.git"

// Tell capistrano about server address host
server "localhost", :web, :app, :db, :primary => true
// port running in server
ssh_options[:port] = 2222
// path to private key
ssh_options[:keys] = "~/.vagrant.d/insecure_private_key"

set :user, "vagrant"
set :stages, %w(staging production)
set :default_stage, 'staging'
set :use_sudo, false
set :group, "vagrant"
set :deploy_to, "/var/myapp"
set :deploy_via, :copy
set :copy_strategy, :export

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  desc "Restart the application"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  desc "Copy the database.yml file into the latest release"
  task :copy_in_database_yml do
    run "cp #{shared_path}/config/database.yml #{latest_release}/config/"
// task that copy database.yml file into place, so we’ll put that here as well as a before directive that will force that task to be called as part of a deployment
before "deploy:assets:precompile", "deploy:copy_in_database_yml"

Setting in Server

From console application
cap deploy:setup

- /releases
- /shared
|- /log
|- /system
|- /pids

Each time we deploy, Capistrano will create a new subdirectory in the releases directory and place the source code for Application there. The shared directory will contain various, well, shared resources. Thus, shared/log will contain Application log files, and shared/system will contain any files that need to be kept from deployment to deployment. We also have shared/config, which we created with Puppet and which contains Application database.yml.

Push Command from Local

// as describe in /config/deploy.rb set_staging.
cap deploy staging

Vagrant Rails Puppet

1:02 AM Posted by Codeinterpreter No comments
Vagrant & Puppet to easily provision virtual machines that can be used as isolated development environments for your projects. You'll keep your development machine fast, your environments isolated, and any developer will be able to get up and running on a new project in less than 5 minutes.

Puppet automates server provisioning by formalizing a server’s configuration into manifests. Puppet’s manifests are text files that contain declarations written in Puppet’s domain-specific language (DSL). When we’ve defined our configuration using this DSL, Puppet will ensure that the machine’s files, packages, and services match the settings we’ve specified


// Initialize vagrant
vagrant up

// Enter Vagrant SSH
vagrant ssh
// Built Git repository for manifest. built it if not exist
ls -l /etc/puppet/.git/
// First we need to create a user and group for Puppet to use
sudo useradd --comment "Puppet" --no-create-home \ --system --shell /bin/false puppet

// Installing puppet as ruby gem. This will install puppet and facter
sudo gem install puppet -v 2.7.12 --no-rdoc --no-ri

facter is the tool that Puppet uses to gather information about the system in order to populate variables and determine which parts of our.

// Run Facter

// Built manifests and site.pp in /etc/puppet
cd /etc/puppet
mkdir manifests
cd manifests
sudo nano site.pp

write this configuration:
Exec {
  path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

// Commit this change
git add .
git commit -m "Init Puppet manifests"

Puppet Configurations

puppet help apply

// Run puppet
sudo puppet apply --verbose manifests/site.pp

When developing a Puppet configuration, it’s helpful to pass the --verbose flag to Puppet so that it displays any extended information that might be available if an error happens. We’ll see output like this from puppet apply:

 info: Applying configuration version '1319427535' info: Creating state file /var/lib/puppet/state/state.yaml notice: Finished catalog run in 0.02 seconds We’ll also see a few lines of output like the following ones.

This is because the Puppet developers are still bringing the codebase up-to-date for Ruby 1.9.3; these should go away in future Puppet releases.

 Could not load confine test 'operatingsystem': cannot load such file \ --  puppet/provider/confine/operatingsystem

 We’ve successfully built a tiny Puppet repository and executed Puppet on our VM. Now we’ll build out the VM with a standard Rails application stack. That is, we’ll configure Apache, MySQL, and Passenger, and we’ll put the Rails application directory tree into place. Along the way, we’ll learn all about how Puppet helps us manage our VM’s services and configuration.

Study Case

Installing Apache  on a server

In our site.pp. add this conf:
Exec {
path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
package {
ensure => present
service {
ensure => true,
enable => true

This package declaration is a fine example of the Puppet DSL. There’s a type declaration, package, followed by a block delimited by curly braces. That block contains a title for the instance of the type that we’re configuring, apache2.
That title is associated with various parameters that affect how Puppet will act on the type. In this case, we’ve declared an ensure parameter that’s set to present. This declaration is our way to tell Puppet that it should ensure there is a package called apache2 installed on the system.

service apache ensure true it means setting Puppet to attempt the service if it’s not running. And enable means ensures the service will start on boot

// Apply puppet
sudo puppet apply --verbose manifests/site.pp

If there's error message: "Could not load confine test 'operatingsystem' ". That's just update issue and harmless. If affecting your process just update your RoR versions.

Tuesday, June 30, 2015

Vagrant: Built Customize Vagrant Box

7:25 PM Posted by Codeinterpreter No comments

Built Customize Vagrant Box

We can make customize box from our vagrant existed box. With this, we can change our environment in existing box and customize it according our need.


// In your Vagrant Init file directory
vagrant up
// Get in to your vagrant environment
vagrant ssh

 * Do your custumize in here
 * For example. I will remove my existing ruby version from vagrant box and change it to new one

sudo apt-get update -y

sudo apt-get install build-essential zlib1g-dev libssl-dev libreadline-dev \
git-core curl libyaml-dev libcurl4-dev libsqlite3-dev apache2-dev -y

curl --remote-name http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz

tar zxf ruby-1.9.3-p194.tar.gz

cd ruby-1.9.3-p194/



sudo make install

// Check if my new ruby version successfully installed
ruby -v

// If succeed quit from vagrant ssh

// Adding your customize box to new box
vagrant package

// Name it
vagrant box add lucid64_with_ruby193 package.box

// Check for your new box
vagrant box list

- lucid32
- lucid64
- lucid64_with_ruby193

// Activate your vagrant 
vagrant init lucid64_with_ruby193

Tuesday, June 23, 2015

Use arsduo/koala in Rails for Facebook Connect

10:44 PM Posted by Codeinterpreter No comments
 Koala is a Facebook library for Ruby, supporting the Graph API (including the batch requests and photo uploads), the REST API, realtime updates, test users, and OAuth validation.


In Gemfile:
gem "koala", "~> 2.0"
gem 'oauth', '~> 0.4.7'

Never forget to bundle install

Build Callback URL route:
 get '/facebook_callback' => 'facebook#callback', as: :facebook_callback

Facebook Configurations

Get App ID and Secret Key:

  1. Go to https://developers.facebook.com/
  2. In My Apps, add or go to your New App
  3. Get your App ID and App secret

App Configurations

In config/environments/{{your-environments}}  add this line

  ENV["facebook_app_id"] = "{{your-app-id}}"
  ENV["facebook_secret_key"] = "{{your-secret-id}}"
  ENV["facebook_callback"] = "{{your-facebook-callback}}"


This process will built redirect function to permission page user account in Facebook and return with App Token and App Token Secret. Facebook doesn't recognize localhost with port, if we want to built this connectivity it's better to do it in staging or live servers. Only to get Token and Secret Token Code.
// Connect
facebook_connect = Koala::Facebook::OAuth.new({{your-app-id}},{{your-secret-id}}, {{callback URL}})

// This function will automatically redirecting user to Facebook permission page and redirect it back to your Callback URL
redirect_to facebook_connect.url_for_oauth_code(:permissions => ["publish_actions", "user_posts"])

About Permission can be found in here https://developers.facebook.com/docs/facebook-login/permissions/v2.2

In Return Process built this functions

// Get Token Accces Code
code = facebook.get_access_token(params[:code])

// Get Token Access Secret Code
app_code = facebook.get_app_access_token

// Sample of Get my profile from Facebook
client = Koala::Facebook::API.new(code, {{your -secret-key}})
me = client.get_object("me")

// Save code and app_code to database. This tokens needed for REST API Process

REST API From Facebook Get Status, Profile,etc

Get Status and Profile

// Connect
client = Koala::Facebook::API.new({{ Token Accces }}, {{Token Access Secret}} )
// Get Profile and Feed/Status
facebook_data = client.get_connections("me", "feed", {}, api_version: "v2.0")

Post Status and Comment

// Connect
client = Koala::Facebook::API.new(g{{ Token Accces }}, {{Token Access Secret}})
// Post Status
post_content = client.put_wall_post(params[:description])

Thursday, June 18, 2015

Understanding Rubycritic Smells

9:17 PM Posted by Codeinterpreter No comments
Rubycritic is gem that wraps around static analysis gems such as Reek, Flay and Flog to provide a quality report of your Ruby code.

Because this gem was uses as Audit guidelines code quality in my company, I often faced hard time to adjust, optimizing and refactor my code.

I began to summarize Rubycritic detecting behavior and implement it in my code to avoid Smells and easier get at least Grade C to bare pass.

A few my conclusion things to consider when developing code according Rubycritic :

  1. Don't! Never! Avoid! Duplicity Code. Rubycritic love this think and will give you sudden great high score, enough to drop your Code Rating Grade.
  2. Evade complicated nested logic with multiple if, switch, etc. It's saver to use functions to handle logic rather than nested logic. Fox example

    // Rather than this
     if obj == "a"
       if obj1 == "1" && obj2 == "2"
         // Process
       elsif obj1 == "3" && obj2 == "4"
         // Process
         // Process
     elsif obj1 == "b"
       if obj1 == "1" && obj2 == "2"
         // Process
       elsif obj1 == "3" && obj2 == "4"
         // Process
         // Process
      // Process
    // Use this
     if obj == "a"
     elsif obj1 == "b"
      // Process
  3. Evade complicated nested loops with multiple each, for, etc. It's saver to use functions to handle loops rather than nested loops. Fox example

    // Rather than this
     data_sources.each do |data_source|
      data_source.each do |data|
    // Use This
     data_sources.each do |data_source|
  4. If your function using nested hash, redeclare multiple used nested hash using variable.

    // rather than
    if params[:id] == '1'
      user = User.where('id = ?',params[:id])
    // Used This
    id = params[:id]
    if id == '1'
      user = User.where('id = ?',id)

  5.  To combine Hash uses:  .merge!()

          params_data_assign = {}
          params_data_assign[:password_salt] = BCrypt::Engine.generate_salt
          params_data_assign[:password_hash] = BCrypt::Engine.hash_secret(password, self.password_salt)

  6. Use method = const_get(method) to change string into Model Constant. (surprisingly isn't it?).

      def myfunction
       my_return = obj == 'User' ? 'User' : 'Member'
      def process_my_return(my_return)
        method = const_get(my_return)
        data = method.where('id = ?',1)
        // Process
If you have found something more than this or have more effective way. Please, tell us so we can share about this problem more.

Veritrans Rails 4 with dynamic server_key and client_key

1:44 AM Posted by Codeinterpreter No comments
Veritrans is Indonesian Payment Gateway. Veritrans accepts Credit Card, Direct Debit, e-Wallet,Bank Transfer and Convenience Store. That's why this Payment Gateway is famous in Indonesia. Further explanations about Veritrans https://veritrans.co.id/ .

Veritrans has multiple products with different integration method and pricing. About Veritrans Products https://veritrans.co.id/product.html

Veritrans Products:


VT-Link facilitates a payment feature for your online store by redirecting the customer to Veritrans payment page through a link.


VT-Web facilitatess merchant to use Veritrans payment system, by redirecting the customer to the Veritrans payment page.


VT-Direct is Veritrans product that allows you to use our payment system directly on your website

Integration Tool Kit

  • Rails 4
  • gem veritrans


Add gem Veritrans to Gem File and bundle install

    gem 'veritrans';

In Console generate veritrans.yml

rails g veritrans:install

Generate Veritrans Form

rails g veritrans:payment_form

This command will generate controller and view for Veritrans.
Because we will built dynamic key for this integrations. You can keep veritrans.yml configurations like this:

  # Register in sandbox veritrans and get your keys here:
  # https://my.sandbox.veritrans.co.id/settings/config_info
  client_key: ""
  server_key: ""
  api_host: ""

  # Register and get your keys here:
  # https://my.veritrans.co.id/settings/config_info
  client_key: ""
  server_key: ""
  api_host: ""

  # Register and get your keys here:
  # https://my.veritrans.co.id/settings/config_info
  client_key: ""
  server_key: ""
  api_host: ""


VT-Web Integrations

In VT-Web Integrations, you just need to obtain redirect URL to Veritrans . After last check out process, put this function for directing page to veritrans:

@result = Veritrans.charge(
  payment_type: "VTWEB",
  transaction_details: {
    order_id: "order-id",
    gross_amount: 100_000
// For Automatically redirect
redirect_to @result.redirect_url

VT-Direct Integrations

VT-Direct Integrations is a little bit complicated because a lot of sensitive data involved in this process.

Preparing The Form

In /views/shared/_credit_card_form   put your last checkout data in here. For example:

<%= form_for @payment, html: {class: "veritrans-payment-form", id:"card_form"} do |f| %>
<% if @settings.client_key.present? && @settings.server_key.present? && @settings.api_host.present? %>

Payments Page

<%= render "layouts/notification" %> <%= f.hidden_field :token_id, id:"card_token" %>
<%= label_tag "Length Of Membership" %> <%= number_field_tag :length_of_membership, 1,in: 1..10000 ,size: 5,class:"form-control", id:"length_of_membership",style:"width:10%;float:left;margin-right:10px;" %>
<%= label_tag "Membership Expired" %> <%= text_field_tag :membership_expired, (@company[:membership_expired] + 1.month).strftime('%Y-%m-%d'),size: 5,:readonly => true,class:"form-control", id:"date_expired",style:"width:75%;" %>
<%= f.number_field :amount, id:"gross_amount", size: 25,:readonly => true,class:"form-control",style:"width:75%;" %>
<%= label_tag :credit_card_number %> <%= text_field_tag :credit_card_number, '',:required => true,:placeholder => "4811 1111 1111 1114", name: nil, size: 25,class:"form-control", id:"card_number" %>
<%= label_tag :credit_card_cvv %> <%= text_field_tag :credit_card_cvv, '',:required => true,:placeholder => "123", name: nil,class:"form-control", id:"card_cvc" %>
<%= label_tag :credit_card_expire %> <%= text_field_tag :credit_card_expire, '',:required => true, placeholder: "MM / YY", name: nil,class:"form-control", id:"card_exp" %>
<%= f.label :credit_card_secure, "3D-secure" %> <%= f.check_box :credit_card_secure %>
<%= f.label :notes %> <%= text_area(:notes, :text, class:"form-control", size: "20x30") %>
<%= link_to (image_tag "undo-logo.png", title: :back).html_safe, users_path() %> <%= f.submit "Pay via VT-Direct", class:"btn green-btn" %>
<% else %>
<%= link_to (image_tag "undo-logo.png", title: :back).html_safe, users_path() %>
<% end %> <% end %>

Return Process

In Return Process build this functions

    veritrans_callback = {
      transaction_details: {
        order_id: payment.order_id,
        gross_amount: params[:payment][:amount].presence || @payment.amount
    // Get setting from database
    setting = Setting.first
    // Set key and host for Veritrans

    params[:type] = "Credit Card"
    veritrans_callback[:payment_type] = "credit_card"
    veritrans_callback[:credit_card] = {}
    veritrans_callback[:credit_card][:token_id] = params[:payment][:token_id]
    result = Veritrans.charge(veritrans_callback)

    transaction_params = {}
    transaction_params = {

    // If Transaction Success
    if result.data[:status_code] == "200"
      // Success Process 
      // Failed Process

That's All. I hope this will help anyone out there. :D

Tuesday, June 16, 2015

Laravel 4 Scheduller with dispatcher

8:31 PM Posted by Codeinterpreter No comments

Dispatcher is a Laravel artisan command scheduling tool used to schedule artisan commands within your project so you don't need to touch your crontab when deploying.

For Futher Information go to this link Dispatcher.

  • Do you hate to touch crontab to add scheduller in laravel?
  • Do you hate with all crontab configuration when add scheduller in different servers?
Congratulations,  Laravel has package to handle this problem using Dispatcher. Everthing become simple and easy with this package. Doubt? Here we go!

Tool Kit

  • PHP 5.3+ or HHVM
  • Laravel 4


In your application add this to your "require" :{} composer.json

    "indatus/dispatcher": "1.4.*@dev"

remember to do composer update.
In your app/config/app.php providers array add this line:



  scheduled:make              Create a new scheduled artisan command
  scheduled:run               Run scheduled commands
  scheduled:summary           View a summary of all scheduled artisan commands

Build scheduled command

php artisan scheduled:make yourCommands

Register scheduled command

In Your app/start/artisan.php add this line depend on Your Command :

Artisan::add(new yourCommands);


Go to your command app/command/yourCommands and change 

// my artisan command will be php artisan cron:mycommands
protected $name = 'cron:yourCommands';

// Configure this functions to change schedule time
public function schedule(Schedulable $scheduler)
  // Change this function to change time
  return $scheduler->daily();

This is Scheduler Changes time function example list:

//every day at 4:17am
return $scheduler->daily()->hours(4)->minutes(17);

//every Monday/Friday at 8:30am
return $scheduler->daysOfTheWeek([

// Using Raw Commands
//every other day at 1:59am, 13:59pm and 23:59pm
return $scheduler->setSchedule(59, [1,13,23], '*/2', '*', '*');

// Every minutes
return $scheduler->everyMinutes();

// Every 20 minutes
return $scheduler->everyMinutes(10);

// Every hours
return $scheduler->everyHours();

Cron Setup

In console add

crontab -e
* * * * * php {{ path to your app}}/artisan scheduled:run 1>> /dev/null 2>&1


If your cron not running check this

// Via console, check your mcrypt
php -i | mcrypt.

// Via console
php artisan scheduled:run --debug 
backup:avatars: No schedules were due
     command:name: No schedules were due
     myTestCommand:name: No schedules were due
     cache:clean: /usr/bin/env php /Users/myUser/myApp/artisan cache:clean > /dev/null &
     mail:subscribers: /usr/bin/env php /Users/myUser/myApp/artisan mail:subscribers > /dev/null &

// Via Console
php artisan scheduled:summary
//It works if output something like this:
| Environment(s) | Name             | Args/Opts | Minute | Hour | Day of Month | Month | Day of Week | Run as |
| *              | schedule:test    |           | */5    | *    | *            | *     | *           |        |

Sunday, June 14, 2015

Laravel 4 Queue with Beanstalk and Supervisor

9:06 PM Posted by Codeinterpreter No comments

Queue  is great tools in laravel for implementing delayed job. Queue allowing system to put task in background so it can become faster and make users skip waiting until tasks is finished.
Queue can be implemented to handle big process such as generating reports, image processing, sending email, or even heavy CRUD process.

Tool Kit


Installing Queue

In your application add this to your "require" :{} composer.json

    "pda/pheanstalk": "2.0.*"


You can create new class or use controller/model/any class to execute function with Queue. Below is function in controller class executed by Queue.


class ReportsController extends \BaseController {
  function fire($job,$data){
    //Function Process

To execute this method with queue use this command

Queue::push('ReportsController', $data);

Other alternative is to execute function without fire method


class ReportsController extends \BaseController {
  function generateReport($job,$data){
    //Function Process

To execute this method with queue use this command

Queue::push('ReportsController@generateReport', $data);

Queue::push() command can be use in Route, Controller, or even Command.

Running Queue

To running Queue we need Beanstalk as a worker. To activate beanstalk running this command in console

  // To fire last job
  php artisan queue:work

  // To fire running job and listen it
  php artisan queue:listen

  // add listener with flag (you can choose or implement all of this)
  php artisan queue:work --timeout=0 --queue="default" --delay=0 --memory=128 --sleep=3 --tries=0

Install and Configure Beanstalk

Install Beanstalk

sudo apt-get update
// Install in Debian or ubuntu
sudo apt-get install beanstalkd

Configure Beanstalk

sudo nano /etc/default/beanstalkd

// Add or uncomment this line

Start Beanstalk
sudo service beanstalkd start

Configure Beanstalk in Our Laravel App

Set default queue in app to Beanstalk. Go to app/config/queue.php

// Change This
'default' => 'beanstalkd',

// This is default beanstalk configurations
'connections' => array(

    'beanstalkd' => array(
        'driver' => 'beanstalkd',
        'host'   => 'localhost', 
        'queue'  => 'default',
        'ttr'    => 60,



We use php artisan queue:work or php artisan queue:work as listener, but we know that impossible for us to running this command every time we push job to Queue or when we start servers.

To overcome this we use Supervisor to listen all of active worker. Supervisor will listen all of our queue:work --daemon and restart it if failed.

Install Supervisor

// Install Supervisor in Debian or ubuntu
sudo apt-get install supervisor

// Adding configurations
sudo nano /etc/supervisor/conf.d/reportqueue.conf

command=php artisan queue:work --daemon --env=your_environment

Add Configuration to Supervisor

sudo supervisorctl
reread # Tell supervisord to check for new items in /etc/supervisor/conf.d/
add reportqueue       # Add reportqueue process to Supervisord
start reportqueue     # Let's Rock

Check Supervisor

// In Console
ps aux | grep php

# You should see some output similarish this:
php artisan queue:work --daemon --env=your_environment
sh -c php artisan queue:work  --queue="default" --delay=0 --memory=128 --sleep --env=your_environment
php artisan queue:work --queue=default --delay=0 --memory=128 --sleep --env=your_environment

Tuesday, April 21, 2015

Setting Vagrant with VHOST

1:07 AM Posted by Codeinterpreter , No comments

1. Install Vagrant in this article.

2. Log to your Vagrant from directory projects with Vagrantfile.
  •  vagrant ssh
3. From your Vagrant server type: 
  • sudo nano /etc/apache2/apache2.conf
4. Add this text in apache2.conf

<Directory /home/vagrant/public_html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted

Directory /home/vagrant/public_html/ : I put my vagrant directory sync in this path. If you use /var/www/ you can skip this step.

5. From your Vagrant server go to: 
  • cd /etc/apache2/sites-available/
6. Create vhost file for example: sample.conf

7. In sample.conf create this configuration:

<VirtualHost *:80>
        ServerName sample.notcom

        ServerAdmin webmaster@localhost
        DocumentRoot /home/vagrant/public_html/php/sample

        ErrorLog ${APACHE_LOG_DIR}/error-sample.log
        CustomLog ${APACHE_LOG_DIR}/access-sample.log combined

ServerName: Use this to access app from browser.
DocumentRoot: path to your sync projects registered in Vagrantfile
ErrorLog and CustomLog: Log Apache2

8. Register sample.conf to sites-enabled
  • sudo a2ensite sample.conf

9. Restart your apache
  • sudo service apache2 restart
10. Access your app using:
  • sample.notcom
  • IP registered in Vagrantfile. config.vm.network "private_network", ip: ""
  • If, it's still not works use registered PORT in Vagrantfile:
11. Remember that you need to install some PHP extensions, PHPMYADMIN, composer, etc in your Vagrant server environment.

Saturday, April 11, 2015

Linkedin Gem: LinkedIn OAuth 2.0 add_share Error

7:27 AM Posted by Codeinterpreter No comments
LinkedIn OAuth 2.0 is Rails Gems to integrate Linked Social Media to our Apps through API. This Gem is easy to integrated and use, we can directly GET and POST data from  Linkedin.

But, theres a problem when using add_share API using https://github.com/emorikawa/linkedin-oauth2  documentations. api.add_share(content: "hi") will always generated error.

I've search, read Linkedin documentation, and customize the library but it always generated error. After a few times I found that doing a little change in add_share comments it will works. 

Changes the command into: 
api.add_share(comment: "hi")
Voila, it works... :D

Thursday, April 9, 2015

CodeIgniter 3 Released !

8:44 PM Posted by Codeinterpreter , No comments
Codeigniter 3 has released in March,30 2015. It's available to download in here.

There's a a lot of huge changes from Codeigniter Version 2 to Codeigniter Version 3. Here is some of the changes I take from Codeigniter sites.

  • License
    • CodeIgniter has been relicensed with the MIT License, eliminating its old proprietary licensing.
  • General Changes
    • PHP 5.1.6 is no longer supported. CodeIgniter now requires PHP 5.2.4 and recommends PHP 5.4+ or newer to be used.
    • Changed filenaming convention (class file names now must be Ucfirst and everything else in lowercase).
    • Changed the default database driver to ‘mysqli’ (the old ‘mysql’ driver is DEPRECATED).
    • $_SERVER['CI_ENV'] can now be set to control the ENVIRONMENT constant.
    • Added an optional backtrace to php-error template.
    • Added Android to the list of user agents.
    • Added Windows 7, Windows 8, Windows 8.1, Android, Blackberry, iOS and PlayStation 3 to the list of user platforms.
    • Added Fennec (Firefox for mobile) to the list of mobile user agents.
    • Ability to log certain error types, not all under a threshold.
    • Added support for pem, p10, p12, p7a, p7c, p7m, p7r, p7s, crt, crl, der, kdb, rsa, cer, sst, csr Certs to mimes.php.
    • Added support for pgp, gpg, zsh and cdr files to mimes.php.
    • Added support for 3gp, 3g2, mp4, wmv, f4v, vlc Video files to mimes.php.
    • Added support for m4a, aac, m4u, xspf, au, ac3, flac, ogg, wma Audio files to mimes.php.
    • Added support for kmz and kml (Google Earth) files to mimes.php.
    • Added support for ics Calendar files to mimes.php.
    • Added support for rar, jar and 7zip archives to mimes.php.
    • Updated support for xml (‘application/xml’) and xsl (‘application/xml’, ‘text/xsl’) files in mimes.php.
    • Updated support for doc files in mimes.php.
    • Updated support for docx files in mimes.php.
    • Updated support for php files in mimes.php.
    • Updated support for zip files in mimes.php.
    • Updated support for csv files in mimes.php.
    • Added Romanian, Greek, Vietnamese and Cyrilic characters in application/config/foreign_characters.php.
    • Changed logger to only chmod when file is first created.
    • Removed previously deprecated SHA1 Library.
    • Removed previously deprecated use of $autoload['core'] in application/config/autoload.php. Only entries in$autoload['libraries'] are auto-loaded now.
    • Removed previously deprecated EXT constant.
    • Updated all classes to be written in PHP 5 style, with visibility declarations and no var usage for properties.
    • Added an Exception handler.
    • Moved error templates to application/views/errors/ and made the path configurable via $config['error_views_path'].
    • Added support non-HTML error templates for CLI applications.
    • Moved the Log class to application/core/
    • Global config files are loaded first, then environment ones. Environment config keys overwrite base ones, allowing to only set the keys we want changed per environment.
    • Changed detection of $view_folder so that if it’s not found in the current path, it will now also be searched for under the application folder.
    • Path constants BASEPATH, APPPATH and VIEWPATH are now (internally) defined as absolute paths.
    • Updated email validation methods to use filter_var() instead of PCRE.
    • Changed environment defaults to report all errors in development and only fatal ones in testingproduction but only display them in development.
    • Updated ip_address database field lengths from 16 to 45 for supporting IPv6 address on Trackback Library and Captcha Helper.
    • Removed cheatsheets and quick_reference PDFs from the documentation.
    • Added availability checks where usage of dangerous functions like eval() and exec() is required.
    • Added support for changing the file extension of log files using $config['log_file_extension'].
    • Added support for turning newline standardization on/off via $config['standardize_newlines'] and set it to FALSE by default.
    • Added configuration setting $config['composer_autoload'] to enable loading of a Composer auto-loader.
    • Removed the automatic conversion of ‘programmatic characters’ to HTML entities from the URI Library.
    • Changed log messages that say a class or file was loaded to “info” level instead of “debug”, so that they don’t pollute log files when $config['log_threshold'] is set to 2 (debug).
  • Helpers
    • Date Helper changes include:
      • Added an optional third parameter to timespan() that constrains the number of time units displayed.
      • Added an optional parameter to timezone_menu() that allows more attributes to be added to the generated select tag.
      • Added function date_range() that generates a list of dates between a specified period.
      • Deprecated standard_date(), which now just uses the native date() with DateTime constants.
      • Changed now() to work with all timezone strings supported by PHP.
      • Changed days_in_month() to use the native cal_days_in_month() PHP function, if available.
    • URL Helper changes include:
      • Deprecated separator options dash and underscore for function url_title() (they are only aliases for ‘-‘ and ‘_’ respectively).
      • url_title() will now trim extra dashes from beginning and end.
      • anchor_popup() will now fill the href attribute with the URL and its JS code will return FALSE instead.
      • Added JS window name support to the anchor_popup() function.
      • Added support for menubar attribute to the anchor_popup().
      • Added support (auto-detection) for HTTP/1.1 response codes 303, 307 in redirect().
      • Changed redirect() to choose the refresh method only on IIS servers, instead of all servers on Windows (when auto is used).
      • Changed anchor()anchor_popup(), and redirect() to support protocol-relative URLs (e.g. //ellislab.com/codeigniter).
    • HTML Helper changes include:
      • Added more doctypes.
      • Changed application and environment config files to be loaded in a cascade-like manner.
      • Changed doctype() to cache and only load once the doctypes array.
      • Deprecated functions nbs() and br(), which are just aliases for the native str_repeat() with &nbsp; and <br />respectively.
    • Inflector Helper changes include:
    • Download Helper changes include:
      • Added an optional third parameter to force_download() that enables/disables sending the actual file MIME type in the Content-Type header (disabled by default).
      • Added a work-around in force_download() for a bug Android <= 2.1, where the filename extension needs to be in uppercase.
      • Added support for reading from an existing file path by passing NULL as the second parameter to force_download()(useful for large files and/or safely transmitting binary data).
    • Form Helper changes include:
    • Security Helper changes include:
    • Smiley Helper changes include:
      • Deprecated the whole helper as too specific for CodeIgniter.
      • Removed previously deprecated function js_insert_smiley().
      • Changed application and environment config files to be loaded in a cascade-like manner.
      • The smileys array is now cached and loaded only once.
    • File Helper changes include:
      • set_realpath() can now also handle file paths as opposed to just directories.
      • Added an optional paramater to delete_files() to enable it to skip deleting files such as .htaccess and index.html.
      • Deprecated function read_file() - it’s just an alias for PHP’s native file_get_contents().
    • String Helper changes include:
      • Deprecated function repeater() - it’s just an alias for PHP’s native str_repeat().
      • Deprecated function trim_slashes() - it’s just an alias for PHP’s native trim() (with a slash as its second argument).
      • Deprecated randomization type options unique and encrypt for funcion random_string() (they are only aliases formd5 and sha1 respectively).
    • CAPTCHA Helper changes include:
      • Added word_length and pool options to allow customization of the generated word.
      • Added colors configuration to allow customization for the backgroundbordertext and grid colors.
      • Added filename to the returned array elements.
      • Updated to use imagepng() in case that imagejpeg() isn’t available.
      • Added font_size option to allow customization of font size.
      • Added img_id option to set id attribute of captcha image.
    • Text Helper changes include:
    • Directory Helper directory_map() will now append DIRECTORY_SEPARATOR to directory names in the returned array.
    • Array Helper element() and elements() now return NULL instead of FALSE when the required elements don’t exist.
    • Language Helper lang() now accepts an optional list of additional HTML attributes.
    • Deprecated the Email Helper as its valid_email()send_email() functions are now only aliases for PHP native functionsfilter_var() and mail() respectively.
  • Database
    • DEPRECATED the ‘mysql’, ‘sqlite’, ‘mssql’ and ‘pdo/dblib’ (also known as ‘pdo/mssql’ or ‘pdo/sybase’) drivers.
    • Added dsn configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID).
    • Added schema configuration setting (defaults to public) for drivers that might need it (currently used by PostgreSQL and ODBC).
    • Added save_queries configuration setting to application/config/database.php (defaults to TRUE).
    • Removed autoinit configuration setting as it doesn’t make sense to instantiate the database class but not connect to the database.
    • Added subdrivers support (currently only used by PDO).
    • Added an optional database name parameter to db_select().
    • Removed protect_identifiers() and renamed internal method _protect_identifiers() to it instead - it was just an alias.
    • Renamed internal method _escape_identifiers() to escape_identifiers().
    • Updated escape_identifiers() to accept an array of fields as well as strings.
    • MySQL and MySQLi drivers now require at least MySQL version 5.1.
    • Added a $persistent parameter to db_connect() and changed db_pconnect() to be an alias for db_connect(TRUE).
    • db_set_charset() now only requires one parameter (collation was only needed due to legacy support for MySQL versions prior to 5.1).
    • db_select() will now always (if required by the driver) be called by db_connect() instead of only when initializing.
    • Replaced the _error_message() and _error_number() methods with error(), which returns an array containing the last database error code and message.
    • Improved version() implementation so that drivers that have a native function to get the version number don’t have to be defined in the core DB_driver class.
    • Added capability for packages to hold config/database.php config files.
    • Added MySQL client compression support.
    • Added encrypted connections support (for mysqlsqlsrv and PDO with sqlsrv).
    • Removed Loader Class from Database error tracing to better find the likely culprit.
    • Added support for SQLite3 database driver.
    • Added Interbase/Firebird database support via the ibase driver.
    • Added ODBC support for create_database()drop_database() and drop_table() in Database Forge.
    • Added support to binding arrays as IN() sets in query().
    • Query Builder changes include:
      • Renamed the Active Record class to Query Builder to remove confusion with the Active Record design pattern.
      • Added the ability to insert objects with insert_batch().
      • Added new methods that return the SQL string of queries without executing them: get_compiled_select(),get_compiled_insert()get_compiled_update()get_compiled_delete().
      • Added an optional parameter that allows to disable escaping (useful for custom fields) for methods join(),order_by()where_in()or_where_in()where_not_in()or_where_not_in()insert()insert_batch().
      • Added support for join() with multiple conditions.
      • Added support for USING in join().
      • Added support for EXISTS in where().
      • Added seed values support for random ordering with order_by(seed, 'RANDOM').
      • Changed limit() to ignore NULL values instead of always casting to integer.
      • Changed offset() to ignore empty values instead of always casting to integer.
      • Methods insert_batch() and update_batch() now return an integer representing the number of rows affected by them.
      • Methods where()or_where()having() and or_having() now convert trailing = and <>!= SQL operators toIS NULL and IS NOT NULL respectively when the supplied comparison value is NULL.
      • Added method chaining support to reset_query()start_cache()stop_cache() and flush_cache().
      • Added an optional second parameter to count_all_results() to disable resetting of QB values.
    • Database Results changes include:
      • Added a constructor to the DB_result class and moved all driver-specific properties and logic out of the baseDB_driver class to allow better abstraction.
      • Added method unbuffered_row() for fetching a row without prefetching the whole result (consume less memory).
      • Renamed former method _data_seek() to data_seek() and made it public.
    • Improved support for the MySQLi driver, including:
      • OOP style usage of the PHP extension is now used, instead of the procedural aliases.
      • Server version checking is now done via mysqli::$server_info instead of running an SQL query.
      • Added persistent connections support for PHP >= 5.3.
      • Added support for configuring socket pipe connections.
      • Added support for backup() in Database Utilities.
      • Changed methods trans_begin()trans_commit() and trans_rollback() to use the PHP API instead of sending queries.
    • Improved support of the PDO driver, including:
      • Added support for create_database()drop_database() and drop_table() in Database Forge.
      • Added support for list_fields() in Database Results.
      • Subdrivers are now isolated from each other instead of being in one large class.
    • Improved support of the PostgreSQL driver, including:
      • pg_version() is now used to get the database version number, when possible.
      • Added db_set_charset() support.
      • Added support for optimize_table() in Database Utilities (rebuilds table indexes).
      • Added boolean data type support in escape().
      • Added update_batch() support.
      • Removed limit() and order_by() support for UPDATE and DELETE queries as PostgreSQL does not support those features.
      • Added a work-around for dead persistent connections to be re-created after a database restart.
      • Changed db_connect() to include the (new) schema value into Postgre’s search_path session variable.
      • pg_escape_literal() is now used for escaping strings, if available.
    • Improved support of the CUBRID driver, including:
      • Added DSN string support.
      • Added persistent connections support.
      • Improved list_databases() in Database Utility (until now only the currently used database was returned).
    • Improved support of the MSSQL and SQLSRV drivers, including:
      • Added random ordering support.
      • Added support for optimize_table() in Database Utility.
      • Added escaping with QUOTE_IDENTIFIER setting detection.
      • Added port handling support for UNIX-based systems (MSSQL driver).
      • Added OFFSET support for SQL Server 2005 and above.
      • Added db_set_charset() support (MSSQL driver).
      • Added a scrollable property to enable configuration of the cursor to use (SQLSRV driver).
      • Added support and auto-detection for the SQLSRV_CURSOR_CLIENT_BUFFERED scrollable cursor flag (SQLSRV driver).
      • Changed default behavior to not use SQLSRV_CURSOR_STATIC due to performance issues (SQLSRV driver).
    • Improved support of the Oracle (OCI8) driver, including:
      • Added DSN string support (Easy Connect and TNS).
      • Added support for drop_table() in Database Forge.
      • Added support for list_databases() in Database Utilities.
      • Generally improved for speed and cleaned up all of its components.
      • num_rows() is now only called explicitly by the developer and no longer re-executes statements.
    • Improved support of the SQLite driver, including:
    • Database Forge changes include:
      • Added an optional second parameter to drop_table() that allows adding the IF EXISTS condition, which is no longer the default.
      • Added support for passing a custom database object to the loader.
      • Added support for passing custom table attributes (such as ENGINE for MySQL) to create_table().
      • Added support for usage of the FIRST clause in add_column() for MySQL and CUBRID.
      • Added partial support for field comments (MySQL, PostgreSQL, Oracle).
      • Deprecated add_column()‘s third method. AFTER clause should now be added to the field definition array instead.
      • Overall improved support for all of the drivers.
    • Database Utility changes include:
      • Added support for passing a custom database object to the loader.
      • Modified the class to no longer extend Database Forge, which has been a deprecated behavior for awhile.
      • Overall improved support for all of the drivers.
      • Added foreign_key_checks option to MySQL/MySQLi backup, allowing statement to disable/re-enable foreign key checks to be inserted into the backup output.
  • Libraries
    • Added a new Encryption Library to replace the old, largely insecure Encrypt Library.
    • Encrypt Library changes include:
      • Deprecated the library in favor of the new Encryption Library.
      • Added support for hashing algorithms other than SHA1 and MD5.
      • Removed previously deprecated sha1() method.
    • Session Library changes include:
      • Completely re-written the library to use self-contained drivers via $config['sess_driver'].
      • Added ‘files’, ‘database’, ‘redis’ and ‘memcached’ drivers (using ‘files’ by default).
      • Added $config['sess_save_path'] setting to specify where the session data is stored, depending on the driver.
      • Dropped support for storing session data in cookies (which renders $config['sess_encrypt_cookie'] useless and is therefore also removed).
      • Dropped official support for storing session data in databases other than MySQL and PostgreSQL.
      • Changed table structure for the ‘database’ driver.
      • Added a new tempdata feature that allows setting userdata items with expiration time (mark_as_temp()tempdata(),set_tempdata()unset_tempdata()).
      • Changed method keep_flashdata() to also accept an array of keys.
      • Changed methods userdata()flashdata() to return an array of all userdata/flashdata when no parameter is passed.
      • Deprecated method all_userdata() - it is now just an alias for userdata() with no parameters.
      • Added method has_userdata() that verifies the existence of a userdata item.
      • Added debug level log messages for key events in the session validation process.
      • Dropped support for the sess_match_useragent option.
    • File Uploading Library changes include:
      • Added method chaining support.
      • Added support for using array notation in file field names.
      • Added max_filename_increment and file_ext_tolower configuration settings.
      • Added min_width and min_height configuration settings for images.
      • Added mod_mime_fix configuration setting to disable suffixing multiple file extensions with an underscore.
      • Added the possibility pass allowed_types as an array.
      • Added an $index parameter to the method data().
      • Added a $reset parameter to method initialize().
      • Removed method clean_file_name() and its usage in favor of Security Library‘s sanitize_filename().
      • Removed method mimes_types().
      • Changed CI_Upload::_prep_filename() to simply replace all (but the last) dots in the filename with underscores, instead of suffixing them.
    • Calendar Library changes include:
      • Added method chaining support.
      • Added configuration to generate days of other months instead of blank cells.
      • Added auto-configuration for next_prev_url if it is empty and show_prev_next is set to TRUE.
      • Added support for templating via an array in addition to the encoded string.
      • Changed method get_total_days() to be an alias for Date Helper days_in_month().
    • Cart Library changes include:
      • Deprecated the library as too specific for CodeIgniter.
      • Added method remove() to remove a cart item, updating with quantity of 0 seemed like a hack but has remained to retain compatibility.
      • Added method get_item() to enable retrieving data for a single cart item.
      • Added unicode support for product names.
      • Added support for disabling product name strictness via the $product_name_safe property.
      • Changed insert() method to auto-increment quantity for an item when inserted twice instead of resetting it.
      • Changed update() method to support updating all properties attached to an item and not to require ‘qty’.
    • Image Manipulation Library changes include:
      • The initialize() method now only sets existing class properties.
      • Added support for 3-length hex color values for wm_font_color and wm_shadow_color properties, as well as validation for them.
      • Class properties wm_font_colorwm_shadow_color and wm_use_drop_shadow are now protected, to avoid breaking thetext_watermark() method if they are set manually after initialization.
      • If property maintain_ratio is set to TRUE, image_reproportion() now doesn’t need both width and height to be specified.
      • Property maintain_ratio is now taken into account when resizing images using ImageMagick library.
      • Added support for maintaining transparency for PNG images when watermarking.
      • Added a file_permissions setting.
    • Form Validation Library changes include:
      • Added method error_array() to return all error messages as an array.
      • Added method set_data() to set an alternative data array to be validated instead of the default $_POST.
      • Added method reset_validation() which resets internal validation variables in case of multiple validation routines.
      • Added support for setting error delimiters in the config file via $config['error_prefix'] and $config['error_suffix'].
      • Internal method _execute() now considers input data to be invalid if a specified rule is not found.
      • Removed method is_numeric() as it exists as a native PHP function and _execute() will find and use that (theis_numeric rule itself is deprecated since 1.6.1).
      • Native PHP functions used as rules can now accept an additional parameter, other than the data itself.
      • Updated method set_rules() to accept an array of rules as well as a string.
      • Fields that have empty rules set no longer run through validation (and therefore are not considered erroneous).
      • Added rule differs to check if the value of a field differs from the value of another field.
      • Added rule valid_url.
      • Added rule in_list to check if the value of a field is within a given list.
      • Added support for named parameters in error messages.
      • Language line keys must now be prefixed with form_validation_.
      • Added rule alpha_numeric_spaces.
      • Added support for custom error messages per field rule.
      • Added support for callable rules when they are passed as an array.
      • Added support for non-ASCII domains in valid_email rule, depending on the Intl extension.
      • Changed the debug message about an error message not being set to include the rule name it is about.
    • Caching Library changes include:
      • Added Wincache driver.
      • Added Redis driver.
      • Added a key_prefix option for cache IDs.
      • Updated driver is_supported() methods to log at the “debug” level.
      • Added option to store raw values instead of CI-formatted ones (APC, Memcache).
      • Added atomic increment/decrement feature via increment()decrement().
    • E-mail Library changes include:
      • Added a custom filename parameter to attach() as $this->email->attach($filename, $disposition, $newname).
      • Added possibility to send attachment as buffer string in attach() as$this->email->attach($buffer, $disposition, $newname, $mime).
      • Added possibility to attach remote files by passing a URL.
      • Added method attachment_cid() to enable embedding inline attachments into HTML.
      • Added dsn (delivery status notification) option.
      • Renamed method _set_header() to set_header() and made it public to enable adding custom headers.
      • Successfully sent emails will automatically clear the parameters.
      • Added a return_path parameter to the from() method.
      • Removed the second parameter (character limit) from internal method _prep_quoted_printable() as it is never used.
      • Internal method _prep_quoted_printable() will now utilize the native quoted_printable_encode()imap_8bit()functions (if available) when CRLF is set to “rn”.
      • Default charset now relies on the global $config['charset'] setting.
      • Removed unused protected method _get_ip() (Input Library‘s ip_address() should be used anyway).
      • Internal method _prep_q_encoding() now utilizes PHP’s mbstring and iconv extensions (when available) and no longer has a second ($from) argument.
      • Added an optional parameter to print_debugger() to allow specifying which parts of the message should be printed (‘headers’, ‘subject’, ‘body’).
      • Added SMTP keepalive option to avoid opening the connection for each send() call. Accessible as $smtp_keepalive.
      • Public method set_header() now filters the input by removing all “\r” and “\n” characters.
      • Added support for non-ASCII domains in valid_email(), depending on the Intl extension.
    • Pagination Library changes include:
      • Deprecated usage of the “anchor_class” setting (use the new “attributes” setting instead).
      • Added method chaining support to initialize() method.
      • Added support for the anchor “rel” attribute.
      • Added support for setting custom attributes.
      • Added support for language translations of the first_linknext_linkprev_link and last_link values.
      • Added support for $config['num_links'] = 0 configuration.
      • Added $config['reuse_query_string'] to allow automatic repopulation of query string arguments, combined with normal URI segments.
      • Added $config['use_global_url_suffix'] to allow overriding the library ‘suffix’ value with that of the global$config['url_suffix'] setting.
      • Removed the default &nbsp; from a number of the configuration variables.
    • Profiler Library changes include:
      • Database object names are now being displayed.
      • The sum of all queries running times in seconds is now being displayed.
      • Added support for displaying the HTTP DNT (“Do Not Track”) header.
      • Added support for displaying $_FILES.
    • Migration Library changes include:
      • Added support for timestamp-based migrations (enabled by default).
      • Added $config['migration_type'] to allow switching between sequential and timestamp migrations.
    • XML-RPC Library changes include:
      • Added the ability to use a proxy.
      • Added Basic HTTP authentication support.
    • User Agent Library changes include:
      • Added check to detect if robots are pretending to be mobile clients (helps with e.g. Google indexing mobile website versions).
      • Added method parse() to allow parsing a custom user-agent string, different from the current visitor’s.
    • HTML Table Library changes include:
      • Added method chaining support.
      • Added support for setting table class defaults in a config file.
    • Zip Library changes include:
      • Method read_file() can now also alter the original file path/name while adding files to an archive.
      • Added support for changing the compression level.
    • Trackback Library method receive() will now utilize iconv() if it is available but mb_convert_encoding() is not.
  • Core
    • Routing changes include:
      • Added support for multiple levels of controller directories.
      • Added support for per-directory default_controller and 404_override classes.
      • Added possibility to route requests using HTTP verbs.
      • Added possibility to route requests using callbacks.
      • Added a new reserved route (translate_uri_dashes) to allow usage of dashes in the controller and method URI segments.
      • Deprecated methods fetch_directory()fetch_class() and fetch_method() in favor of their respective public properties.
      • Removed method _set_overrides() and moved its logic to the class constructor.
    • URI Library changes include:
      • Added conditional PCRE UTF-8 support to the “invalid URI characters” check and removed the preg_quote() call from it to allow more flexibility.
      • Renamed method _filter_uri() to filter_uri().
      • Changed method filter_uri() to accept by reference and removed its return value.
      • Changed private methods to protected so that MY_URI can override them.
      • Renamed internal method _parse_cli_args() to _parse_argv().
      • Renamed internal method _detect_uri() to _parse_request_uri().
      • Changed _parse_request_uri() to accept absolute URIs for compatibility with HTTP/1.1 as per RFC2616 <http://www.ietf.org/rfc/rfc2616.txt>.
      • Added protected method _parse_query_string() to URI paths in the the QUERY_STRING value, like_parse_request_uri() does.
      • Changed URI string detection logic to always default to REQUEST_URI unless configured otherwise or under CLI.
      • Removed methods _remove_url_suffix()_explode_segments() and moved their logic into _set_uri_string().
      • Removed method _fetch_uri_string() and moved its logic into the class constructor.
      • Removed method _reindex_segments().
    • Loader Library changes include:
      • Added method chaining support.
      • Added method get_vars() to the Loader to retrieve all variables loaded with $this->load->vars().
      • _ci_autoloader() is now a protected method.
      • Added autoloading of drivers with $autoload['drivers'].
      • $config['rewrite_short_tags'] now has no effect when using PHP 5.4 as <?= will always be available.
      • Changed method config() to return whatever CI_Config::load() returns instead of always being void.
      • Added support for library and model aliasing on autoload.
      • Changed method is_loaded() to ask for the (case sensitive) library name instead of its instance name.
      • Removed $_base_classes property and unified all class data in $_ci_classes instead.
      • Added method clear_vars() to allow clearing the cached variables for views.
    • Input Library changes include:
      • Deprecated the $config['global_xss_filtering'] setting.
      • Added method() to retrieve $_SERVER['REQUEST_METHOD'].
      • Added support for arrays and network addresses (e.g. for use with the proxy_ips setting.
      • Added method input_stream() to aid in using php://input stream data such as one passed via PUT, DELETE and PATCH requests.
      • Changed method valid_ip() to use PHP’s native filter_var() function.
      • Changed internal method _sanitize_globals() to skip enforcing reversal of register_globals in PHP 5.4+, where this functionality no longer exists.
      • Changed methods get()post()get_post()cookie()server()user_agent() to return NULL instead of FALSE when no value is found.
      • Changed default value of the $xss_clean parameter to NULL for all methods that utilize it, the default value is now determined by the $config['global_xss_filtering'] setting.
      • Added method post_get() and changed get_post() to search in GET data first. Both methods’ names now properly match their GET/POST data search priorities.
      • Changed method _fetch_from_array() to parse array notation in field name.
      • Changed method _fetch_from_array() to allow retrieving multiple fields at once.
      • Added an option for _clean_input_keys() to return FALSE instead of terminating the whole script.
      • Deprecated the is_cli_request() method, it is now an alias for the new is_cli() common function.
      • Added an $xss_clean parameter to method user_agent() and removed the $user_agent property.
      • Added property $raw_input_stream to access php://input data.
    • Common functions changes include:
      • Added function get_mimes() to return the application/config/mimes.php array.
      • Added support for HTTP code 303 (“See Other”) in set_status_header().
      • Removed redundant conditional to determine HTTP server protocol in set_status_header().
      • Renamed _exception_handler() to _error_handler() and replaced it with a real exception handler.
      • Changed _error_handler() to respect php.ini display_errors setting.
      • Added function is_https() to check if a secure connection is used.
      • Added function is_cli() to replace the CI_Input::is_cli_request() method.
      • Added function function_usable() to work around a bug in Suhosin <http://www.hardened-php.net/suhosin/>.
      • Removed the third ($php_error) argument from function log_message().
      • Changed internal function load_class() to accept a constructor parameter instead of (previously unused) class name prefix.
      • Removed default parameter value of is_php().
      • Added a second argument $double_encode to html_escape().
      • Changed function config_item() to return NULL instead of FALSE when no value is found.
      • Changed function set_status_header() to return immediately when run under CLI.
    • Output Library changes include:
      • Added a second argument to method set_content_type() that allows setting the document charset as well.
      • Added methods get_content_type() and get_header().
      • Added method delete_cache().
      • Added configuration option $config['cache_query_string'] to enable taking the query string into account when caching.
      • Changed caching behavior to compress the output before storing it, if $config['compress_output'] is enabled.
    • Config Library changes include:
      • Changed site_url() method to accept an array as well.
      • Removed internal method _assign_to_config() and moved its implementation to CodeIgniter.php instead.
      • item() now returns NULL instead of FALSE when the required config item doesn’t exist.
      • Added an optional second parameter to both base_url() and site_url() that allows enforcing of a protocol different than the one in the base_url configuration setting.
      • Added HTTP “Host” header character validation to prevent cache poisoning attacks when base_url auto-detection is used.
    • Security Library changes include:
      • Added $config['csrf_regeneration'], which makes CSRF token regeneration optional.
      • Added $config['csrf_exclude_uris'], allowing for exclusion of URIs from the CSRF protection (regular expressions are supported).
      • Added method strip_image_tags().
      • Added method get_random_bytes() and switched CSRF & XSS token generation to use it.
      • Modified method sanitize_filename() to read a public $filename_bad_chars property for getting the invalid characters list.
      • Return status code of 403 instead of a 500 if CSRF protection is enabled but a token is missing from a request.
    • Language Library changes include:
      • Changed method load() to filter the language name with ctype_alpha().
      • Changed method load() to also accept an array of language files.
      • Added an optional second parameter to method line() to disable error logging for line keys that were not found.
      • Language files are now loaded in a cascading style with the one in system/ always loaded and overridden afterwards, if another one is found.
    • Hooks Library changes include:
      • Added support for closure hooks (or anything that is_callable() returns TRUE for).
      • Renamed method _call_hook() to call_hook().
      • Class instances are now stored in order to maintain their state.
    • UTF-8 Library changes include:
      • UTF8_ENABLED now requires only one of Multibyte String or iconv to be available instead of both.
      • Changed method clean_string() to utilize mb_convert_encoding() if it is available.
      • Renamed method _is_ascii() to is_ascii() and made it public.
    • Log Library changes include:
      • Added a $config['log_file_permissions'] setting.
      • Changed the library constructor to try to create the log_path directory if it doesn’t exist.
      • Added support for microseconds (“u” date format character) in $config['log_date_format'].
    • Added compatibility layers <general/compatibility_functions> for:
      • Multibyte String (limited support).
      • Hash (hash_equals()hash_pbkdf2()).
      • Password Hashing.
      • Standard Functions ``array_column()`array_replace()array_replace_recursive()hex2bin(),quoted_printable_encode().
    • Removed CI_CORE boolean constant from CodeIgniter.php (no longer Reactor and Core versions).
    • Added support for HTTP-Only cookies with new config option cookie_httponly (default FALSE).
    • $config['time_reference'] now supports all timezone strings supported by PHP.
    • Fatal PHP errors are now also passed to _error_handler(), so they can be logged.