Tuesday 29 March 2022

How to install Switch Between Composer Version 1 and 2 in ubuntu

 How to install Switch Between Composer Version 1 and 2 in ubuntu

Install Composer

Link for reference : Download Link

-> Hits below command in open ubuntu terminal

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"


php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"


php composer-setup.php


php -r "unlink('composer-setup.php');"

->install composer globally hit below command

Command hits : sudo mv composer.phar /usr/local/bin/composer

->check composer version

Command hits : composer

Switching Versions

you can change the version using composer self-update command. 

if you want to switch composer 1 to composer 2 then you can hits below command

Hit command Name: composer self-update --2

if you want to switch composer 2 to composer 1 then you can hists below command

Hit command Name: composer self-update --1

Switching Specific Version

if you want to switch specific Versions. then hits below reference command

syntax : composer self-update (version name which you want to switch)

For Example

Hit command -> composer self-update 1.10.22


Hit Command -> composer self-update 2.1.3

Update and Revert Version

if you want to update composer version using command line

you can hit below command

Command Name : composer self-update

if you want to revert install version using command line

you can hit below command

composer self-update --rollback

Preview Version

The command below will allow you to get the pre-released version.

command name : composer self-update --preview

View Current Version 

if you want to check current version

Command name : composer


How to change php version like 7.2 to 7.4 ?

How to change php versions like 7.2 to 7.4 ?

 Important note while change php version one two another

My current php version php 7.2 in terminal

but when i check using phpinfo() function it display php7.4

so the same version setup check below step it's a very useful process for doing this.

step 1
fire this command and change php version php 7.2 to php 7.4
sudo update-alternatives --config php


step2
check php version and restart the apache2
- php -v
-sudo service apache2 restart


step3
enable previous version using a2dimod and a2enmod command and apache2 restart
-sudo a2dismod php7.2
-sudo a2enmod php7.4
-sudo sudo service apache2 restart


step4
check php version in using phpinfo() function and terminal


Tuesday 2 March 2021

How to get pull particular commit id in git and push in git

 Hello 

Please check below step


mkdir -p projectFolder

cd projectFolder

git init

git remote add origin repoUrl

git fetch origin

git reset --hard gitcommitID

this command use when we want to push our rever

git push --force origin master


Monday 28 December 2020

how to install php 7.2 to php 7.4 step in php

sudo apt-get update

sudo apt -y install software-properties-common

sudo add-apt-repository ppa:ondrej/php

sudo apt-get update

sudo apt-get install php7.4

sudo apt-get install php7.4-mysql

php -v (check to make sure PHP 7.4 is installed)

sudo apt install php7.4-fpm php7.4-common php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-mysql php7.4-cli php7.4-zip php7.4-curl

sudo a2dismod php7.0

sudo a2enmod php7.4

sudo service apache2 restart 

Thursday 16 July 2020

Mac safari open a URL in new tab/window using javascript

Hello

Mac safari open a URL in new tab/window using javascript

i have search many in but i can not get anything. one of my friend give me this code
let a= document.createElement('a');
a.target= '_blank';
a.href= 'https://example.com/';
a.click();

Friday 17 April 2020

Create listing with handlebars js with ajax pagination in codeigniter

 Simple Example for Handlebar js with ajax pagination in codeigniter

Create test controller .php




class Test extends MY_Controller
{
function __construct()
{

parent::__construct();
$this->load->model('Test_model');
$this->load->library('pagination');
    $this->load->helper('url'); 
}



public function list()
{
$this->db->select('member_id,first_name,last_name');
$result = $this->db->get('tbl_member', 10, 20);
//echo $this->db->last_query();
$data['data'] = $result->result_array();
echo json_encode($data);

}

public function memberlist()
{
$this->load->view('memberlist');

}

public function loadRecord($rowno=0)
{
   // Row per page
$rowperpage = 5;

    // Row position
if($rowno != 0){
$rowno = ($rowno-1) * $rowperpage;
}

//print_r($rowno);exit;
    // All records count
$allcount = $this->Test_model->getrecordCount();
//print_r([$rowno,$rowperpage]);
    // Get records
$users_record = $this->Test_model->getData($rowno,$rowperpage);
// echo "
";

// print_r($users_record);exit;
//echo $this->db->last_query();exit;
    // Pagination Configuration
$config['base_url'] = base_url().'/test/loadRecord';
$config['use_page_numbers'] = TRUE;
$config['total_rows'] = $allcount;
$config['per_page'] = $rowperpage;

    // Initialize
$this->pagination->initialize($config);

    // Initialize $data Array
$data['pagination'] = $this->pagination->create_links();;
$data['result'] = $users_record;
$data['data'] = $rowno;

echo json_encode($data);
}
}
?>
after create test model .php


class Test_model extends CI_Model
{

public function __construct() {
    parent::__construct(); 
  }

  // Fetch records
  public function getData($rowno,$rowperpage) {
    $this->db->select('*');
    $this->db->from('tbl_member');
    $this->db->limit($rowperpage, $rowno);  
    $query = $this->db->get();
    return $query->result_array();
  }

  // Select total records
  public function getrecordCount() {

    $this->db->select('count(*) as allcount');
    $this->db->from('tbl_member');
    $query = $this->db->get();
    $result = $query->result_array();
    return $result[0]['allcount'];
  }
}

after create view memberlist.php


<html>
<head> <title></title> <script src="https://code.jquery.com/jquery-1.12.4.js" integrity="sha256-Qw82+bXyGq6MydymqBxNPYTaUXXq7c8v3CwiYwLLNXU=" crossorigin="anonymous"></script> </head> <body> <script id="handlebars-demo" type="text/x-handlebars-template"> <table width="100%" style="border: 1px solid;"> <thead> <tr><th style="border: 1px solid;">Memnber id</th> <th style="border: 1px solid;">First Name</th> <th style="border: 1px solid;">Last Name</th></tr> </thead> <tbody> {{#result}} <tr> <td style="border: 1px solid;">{{member_id}}</td> <td style="border: 1px solid;">{{first_name}}</td> <td style="border: 1px solid;">{{last_name}}</td> </tr> {{/result}} </tbody> </table> <div style='margin-top: 10px;' id='pagination'>{{{pagination}}}</div> </script> <div id="test"></div> <script src="https://cdn.jsdelivr.net/npm/handlebars@latest/dist/handlebars.js"></script> <script > loadPagination(0); function loadPagination(pagno){ $.ajax({ url: "http://graphql.local.com/test/loadRecord/"+pagno, type: 'get', dataType: 'json', success: function(response){ var template = $('#handlebars-demo').html(); var templateScript = Handlebars.compile(template); var html = templateScript(response); //console.log(html); // // Insert the HTML code into the page $("#test").html(html); } }); } $(document).on('click','#pagination a',function(e){ e.preventDefault(); var pageno = $(this).attr('data-ci-pagination-page'); //console.log(pageno); loadPagination(pageno); }); </script> </body> </html>
 




Friday 3 April 2020

mysql database upload using command steps

Hello

I have given Simple step for how to upload database using mysql command


Step 1 CMD command : sudo mysql --host hostname --port 3306 -u databaseUsername -p
step 2 pass : of you system then enter  your db pass
step 3 : after login in mysql hit command : use databases;
step 4  : use your database
step 5 : mysql> source /home/jaydip/Downloads/sql.sql ( Path your database )
and then click on entered button

exmaple

Step 1 CMD command : sudo mysql --host localhost --port 3306 -u root -p
step 2 enter your password : test123
step 3 :  use database
step 4 : mysql> source /home/jaydip/Downloads/sql.sql ( Path your database )
and then click on entered button