Sep 28, 2015

Codeigniter Installation


Codeigniter installation :

 1. Download the latest codeigniter file from https://codeigniter.com/ 

2. Unzip the package and move into htdocs(xampp) or Www(wamp)
3. Type the installtion path in URL http://localhost/demo_codeigniter 
4. Change base_url path in config/config.php as http://localhost/demo_codeigniter

5. change the database name, database username, database password and host.
6. change the autoload file in config/autoload.php file .
         Include url in $autoload['helper'] = array('url'); 

7. Then create controller at application/controllers/demo_file.php

8. Create view file at application/views/demo_view.php and load the view file into the controller $this->load->view('demo_view').

9. Run the http://localhost/demo_codeigniter/demo_file.

Sep 24, 2015

codeigniter multiple file upload

public function save_multiple_images()
{
         for($i=0; $i<$total_items; $i++)
        {
           if(!empty($_POST['item_name'][$i]) && !empty($_POST['item_name'][$i]))
           {
               if(isset($_FILES['item_image']['name'][$i]))
               {
                  $this->load->library('upload');
                  $files = $_FILES;
                  $_FILES['userfile']['name'] = $files['item_image']['name'][$i];
                  $_FILES['userfile']['type']= $files['item_image']['type'][$i];
                  $_FILES['userfile']['tmp_name']= $files['item_image']['tmp_name'][$i];            
                  $_FILES['userfile']['error']= $files['item_image']['error'][$i];
                  $_FILES['userfile']['size']= $files['item_image']['size'][$i];
                  $fileName = $_FILES['userfile']['name'];
                 //Calls set upload funtions
                   $this->upload->initialize($this->set_upload_options($i));
                    if($fileName!='')
                   {
                      $this->upload->do_upload();
                      $upload_data = $this->upload->data();
                      $fileSize = $upload_data['file_size'];
                      if($this->upload->display_errors())
                      {
                        echo json_encode($this->upload->display_errors()); exit;
                      }
                      $fileName = base_url('files/reward_images/'.$upload_data['file_name']);
                  }
                 else{
                      $fileName = base_url('files/reward_images/no_image.png');
                  }
               }
               $reward_image = $fileName;
               $item_id =0;
               $res = $this->rewards_model->save_reward_item($reward_image);
           }
        }
    }
}
private function set_upload_options($i)
 {
      //upload an image options
      $config = array();
      $config['upload_path'] = './files/reward_images/';
      $config['file_name'] = 'File'.time().$i;
     $config['allowed_types'] = '*'; \
     $config['max_size'] = '52528800';
     $config['overwrite'] = FALSE;
     return $config;
}

Laravel 5 Installation On Windows


Laravel Installation Steps :

1. Download composer File from https://getcomposer.org/ 

2. install the composer where the php.exe file located.

3. In command prompt enter the location of project. D:\xampp\htdocs\projects

 4. type in cmd prompt D:\xampp\htdocs\projects > composer create-project laravel/laravel laravel-demo (laravel-demo is your project name).

5. After creating project you have to run the project http://localhost/projects/laravel-demo/public (All public files must reside in this ex. js, css etc.. )

6. You can create controller via composer through cmd prompt D:\xampp\htdocs\projects\laravel-demo> php artisan make: controller controllerName.(like model also can create via same instead of controller we will put php artisan make:model modelName). Note : You can also create a controller manually and model also.

7. After creating controller and model you should create file for view page or folder at
 \\localhost\projects2\demo-laravel\resources\views
       i. Ex. : index.blade.php (blade is must while create php file)

8. To include external css and html file you should install
          D:\xampp\htdocs\projects > composer require illuminate/html.

 After installed this you have to include in config /app.php under provider :
       i. Illuminate\Html\HtmlServiceProvider::class,

 and in b. Alias :
       i. 'Html' => Illuminate\Html\HtmlFacade::class, 
      ii. 'Form' => Illuminate\Html\FormFacade::class 

To include css like
         { !! Html::style(‘css/style.css’) !! }
 
To include Js like
         { !! Html::script(‘js/jquery.js’) !! }

 9. Then update the composer via D:\xampp\htdocs\projects > composer update. 

10. You can create a table via migration file. To create migration file via
        D:\xampp\htdocs\projects >php artisan make:migration table_name

11. After creating migration file that resides in database/migrations.
       To create table
     
       Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('full_name', 100);
        $table->string('username', 100);
        $table->string('password', 100);
        $table->timestamps(); 
      });

12. Before creating table you must change the database name, username, password in .env file.

Laravel Framwork

Laravel Framwork:

 Laravel PHP Framework is built with the focus of writing code syntax that is simple and expressive. This will provide the advantage of having a Web Application that is developer friendly and code that is maintainable.

Taylor Otwell created Laravel as an attempt to provide a more advanced alternative to the CodeIgniter framework, which did not provide certain features such as built-in support for user authentication and authorization.

It has been built with a focus of being superior over the other PHP frameworks, with better code foundation, maintainability and more robust features.

 When it comes to code reliability and maintainability, Laravel has a good foundation and great community support behind its PHP Framework.