Codeigniter

Codeigniter

Easy and Best Framework of PHP
Write

Recent Post's in Profession

2019 OTT trends in live streaming
Streaming videos at great quality without losing service can be pristine in this digital
era. Because quality matters a lot in todays world from 4k tv screens to 4G
smart devices. Streaming with low latency and good video quality, especially
during live events can be critical. A small lapse in the video can cost you viewers.
This year latency errors have been reduced by almost many great streaming
platforms. One of such streaming
platform is Appkodes’ Livza
. This live streaming app has many advancements,
like content-aware encoding solutions, OTT service providers can deliver a
video quality of experience matching traditional cable and satellite
benefactions.

Adopting for cloud processing

As OTT service providers are always looking forward to increase their operational
efficiencies, flexibility and scalability, 2019 will be the year where
cloud-based video processing and delivery models are deployed in lot. With
cloud-based SaaS solutions
, OTT providers can instantly launch and scale
their services swiftly. Streaming service providers can use flexible cloud
architectures to distribute location-targeted content, make ad replacements and
provide UHD-HDR in order to boost monetization. Cloud-based video processing
and delivery will break the gap between the monetization slant by supporting
these next-generation capabilities.

local broadcast channels

One of the challenges that national streaming services have been facing these years is
how to find, create and distribute OTT-ready local broadcast channels.
Cloud-based broadcast affiliate channels and distribution solutions allow broadcasters
to seamlessly create schedule and manage content rights, ensuring exceptional
video quality via the internet and cloud.
 
You can keep up with all of these trends from our blog. Try our live streaming SaaS
solution. 
ProtonBits Software - USA
Protonbits is a leading mobile application & Website development company providing expert services of mobile app, android app development, magento development, wordpress development, joomla development, cakephp development, php development, yii development & codeigniter development.

We first think business value and then execute the development. As a professional and experienced company, we have an expert team, defined processes and robust infrastructure to deliver exceptional software solutions.

Effective project management and a pool of talented developers, makes Protonbits a one-stop destination for top-notch software development services for mobile app, web and cloud. Small to medium size enterprises rely on us for complex projects in backend development, API development and more. We also have dedicated teams which expertise in every aspect of ecommerce development.

We are based in the US, India, Poland & Dubai and have served 100+ clients globally. Our team of expert developers have extensive experience of developing customized software that generates high return on investment for our clients.

For each solutions, we offer Hire Dedicated Developer on hourly basis. Our hourly rate starts at USD 12/hr.

Reach us on http://www.protonbits.com to discuss your next software development project and ensure its success.

Services We offer:

- Wordpress Development Solutions 

- Joomla Development Solutions

- CakePHP Development Solutions 

- API Development Solutions

- CodeIgniter Development Solutions 

- Magento Development Solutions 

- Shopify Development Solutions

- Laravel Development Solutions 

- Ruby on Rails Development Solutions 

- CorePHP Development Solutions 

- BlockChain Development Solutions 

- Yii Development Solutions 

- WooCommerce Development Solutions 

- PhoneGap App Development Solutions 

- Mobile App Development Solutions 

- Android App Development Solutions 

- iOS App Development Solutions 

- Python Development Solutions 

- SquareSpace Development Solutions 

- Custom Software Development Solutions 

- Search Engine Optimization Solutions 

- Prestashop Development Solutions 

- Social Media Optimization Solutions 

- Drupal Development Solutions
Differences Between Magento 1 & Magento 2
Magento 1
was released in 2008. I was introduced as an open source platform, magento was first based on small &
medium size business. Their careful aim paid off over the past 8 years, Magento
took control of SMB eCommerce Industry. Now more than 30% of eCommerce shops
run on some version of Magento.

There are three edition of Magento:
     
I. Magento 1 Community Edition (CE)
   
II. Magento 1 Enterprise Edition (EE)

III. And newly Magento 2


Magento 1 has many updates from 2008 to 2015, then after Magento 2 was launched in
November 2015. 

We secretly heard about Magento 2 was launching in
2010, but unfortunately, it didn’t happen due to some major issues was going behind
the scenes. However slowly Magento 2 was released on November 17, 2015. But it
was mostly different from Magento 1. Magento 2 came with his own set of issues.

       
I. Difficult to install        

II. Product speed was lacking        

III. A newly training was needed for all part of the platforms        

 If you looking for Magento ecommerce Development Company you can simply contact ProtonBits Software. 
ProtonBits is a Top & Best Magento Development
Company having successfully deployed several successful Magento ecommerce website. We are based in India, USA & Dubai. Our Talented Team of Magento helps you to deliver a best of ecommerce store with amazing facilities to manage your invoices, orders, and
products. 
Javascript sort array of object
Follow the below code for sort array of objects in java-script

Code Sample: 

<!doctype html>
<head></head>
<body>
<script>
var arr_objects = [   
    {
        name: 'Devil',       
        age: 36
    },
    {
       name: 'Prashad',       
        age: 20
    },
    {            
       name: 'Rajendra',       
        age: 26
    },    
    {
      name: 'Allu',       
       age: 30
    }
];

var names = arr_objects.slice(0);
names.sort(function(a,b) {
    var x = a.name.toLowerCase();
    var y = b.name.toLowerCase();
    return x < y ? -1 : x > y ? 1 : 0;
});
console.log("Sorted array of objects:");
console.log(names);
</script>
</body>
</html>	
Sorted array result: 






Export data from mysql to csv file using php codeigniter
This tutorial is shows how to export data into csv file using codeigniter. Below are the step by step implementation to download mysql data into csv file.



This tutorial uses employee table :
employee mysql table:
CREATE TABLE IF NOT EXISTS `employee` (
  `id` int(11) NOT NULL,
  `first_name` varchar(50) NOT NULL,
  `last_name` varchar(50) NOT NULL,
  `email` varchar(100) NOT NULL,
  `age` int(11) NOT NULL,
  `status` enum('A','D') NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

Table structure and data looks like :

Employee Details View 

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Employee Listing</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>
    <body>
        <form name="export_data" id="export_data" method="post" action="<?php echo base_url("employee/export_csv"); ?>">
            <div class="container">
                <h2>Employee Listing</h2>
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>Id</th>
                            <th>First Name</th>
                            <th>Last Name</th>                        
                            <th>Email</th>
                            <th>Age</th>
                            <th>Status</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        if (isset($employee_details) && !empty($employee_details)) {
                            foreach ($employee_details as $employee) {
                                ?>
                                <tr>
                                    <td><?php echo $employee->id; ?></td>
                                    <td><?php echo $employee->first_name; ?></td>
                                    <td><?php echo $employee->last_name; ?></td>
                                    <td><?php echo $employee->email; ?></td>
                                    <td><?php echo $employee->age; ?></td>
                                    <td><?php
                                        if ($employee->status == "A")
                                            echo "Active";
                                        else
                                            "Inactive";
                                        ?></td>
                                </tr>
                                <?php
                            }
                        }
                        ?>
                    </tbody>
                </table>
                <button class="btn btn-primary pull-right">Export</button>
            </div>
        </form>
    </body>
</html>



This view displays the employee details in table format.

Employee Controller: 

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Employee extends CI_Controller {

    public $page_data;

    public function __construct() {
        parent::__construct();
        $this->load->model('employee_m');
    }

    public function listing() {
        $this->page_data['employee_details'] = $this->employee_m->get();
        $this->load->view('display_employee', $this->page_data);
    }

    public function export_csv() {
        $this->load->helper('csv');
        $export_arr = array();
        $employee_details = $this->employee_m->get();
        $title = array("Id", "First Name", "Last Name", "Email", "Age", "Status");
        array_push($export_arr, $title);
        if (!empty($employee_details)) {
            foreach ($employee_details as $employee) {
                $status = $employee->status == "A" ? "Active" : "Inactive";
                array_push($export_arr, array($employee->id, $employee->first_name, $employee->last_name, $employee->email, $employee->age, $status));
            }
        }
        convert_to_csv($export_arr, 'employee' . date('F d Y') . '.csv', ',');
    }

}

This controller has two methods: 1] listing method is used to fetch data from mysql table and display it on browser. 2] export_csv function is used to export the data into csv. After clicking on export button this function gets executed. For exporting data, here csv helper is used.

Employee_m model:

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Employee_m extends CI_Model {

    public function get() {
        $sql = "SELECT * FROM employee";
        $q = $this->db->query($sql);
        if ($q->num_rows() > 0) {
            foreach ($q->result() as $row) {
                $data[] = $row;
            }
            return $data;
        }
    }

}

This model is used for getting employee data from mysql table and passes that data to the controller.

CSV Helper :

<?php

defined('BASEPATH') OR exit('No direct script access allowed');


if (!function_exists('convert_to_csv')) {

    function convert_to_csv($input_array, $output_file_name, $delimiter) {
        /** open raw memory as file, no need for temp files */
        $temp_memory = fopen('php://memory', 'w');
        /** loop through array */
        foreach ($input_array as $line) {
            /** default php csv handler * */
            fputcsv($temp_memory, $line, $delimiter);
        }
        /** rewrind the "file" with the csv lines * */
        fseek($temp_memory, 0);
        /** modify header to be downloadable csv file * */
        header('Content-Type: application/csv');
        header('Content-Disposition: attachement; filename="' . $output_file_name . '";');
        /** Send file to browser for download */
        fpassthru($temp_memory);
    }

}


This is the final output you see in csv file.

This tutorial may be helpful for you:)
Remove 'index.php' from url in codeingiter
By using .htaccess we can remove index.php from url in codeigniter.

First step you have to create .htaccess file and keep it in main folder where index.php file is there(outside application folder).

Add this code in .htaccess file

RewriteEngine on

RewriteCond $1 !^(index\.php|assets|uploads) 
#Your public folder names

RewriteRule ^(.*)$ index.php?/$1 [L]
Second step is edit your config.php 


Open config.php and do following replaces

$config['index_page'] = "index.php";
to
$config['index_page'] = "";
change the uri_protocol
$config['uri_protocol'] ="AUTO";
to 
$config['uri_protocol'] = "REQUEST_URI";
After changes config.php and .htaccess looks like this:
Upload file, image using curl in codeigniter with ajax call
This is tutorial regarding upload image on third party server using curl in codeigniter php framework also used ajax call to upload.
View file code looks like :
<form name="file_upload_form" id="file_upload_form" method="post" action="" enctype="multipart/form-data" onsubmit="return false;">
<input type="file" name="file_upload" id="file_upload" class="file-input" />
<input type="submit" name="file" id="file_save" value="Upload File"> 
</form>
Jquery code :

$(document).on("click", "file_save", function () {
    formData = new FormData(document.forms.namedItem("file_upload_form"));
    $.ajax({
        url: base_url + '/user/upload_file',
        type: 'POST',
        data: formData,
        cache: false,
        contentType: false,
        processData: false,
        dataType: 'json',
        success: function (data) {
            if (data.Result == "Success") {
                console.log("File uploaded successfully");
            } else {
                console.log("Server problem try again");
            }

        }
    });
});
User Controller code:
<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class User extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->library('uploadFiles');
    }

    public function upload_file() {
        $file = $_FILES['file'];
        $data = array('apikey' => 'key',
            'mode' => 'document_photo',
            'file' => new CurlFile($file['tmp_name']));
        $output = $this->uploadFiles->upload_userdata($data);
        echo json_encode(array("Result" => "Success", "msg" => $output));
    }

}

?>
Create Library for CURL call this lib contains reusable code
 uploadFiles.php lib code:
<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class uploadFiles {

    private $CI_instance;  // CI Instance created
    private $curl_base_url; //This is curl base url where you store your images[Server path]

    public function __construct() {

        $this->CI_instance = & get_instance();
        $this->curl_base_url = $this->CI_instance->config->item('curl_base_url'); //Actual path is stored in config/config.php file
    }

    public function upload_userdata($data, $url = "your server file name") {
        $content = $data;
        $url = $this->curl_base_url . $url;
        $curl_handle = curl_init();
        curl_setopt($curl_handle, CURLOPT_URL, $url);
        curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array("Content-Type:multipart/form-data"));
        curl_setopt($curl_handle, CURLOPT_POST, 1);
        curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $content);
        curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
        $output = curl_exec($curl_handle);
        $status = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
        if ($status != 200) {
            die("Error: call to URL $url failed with status $status, curl_error " . curl_error($curl_handle) . ", curl_errno " . curl_errno($curl_handle));
        }
        curl_close($curl_handle);
        return json_decode($output);
    }

}
and this works perfectly :), this might be helpful for you , Thank you :)
×