Brijesh Chaturvedi, Author at Codeexecute

Installing laravel on ubuntu step by step

Follow the following steps exactly to installing laravel on ubuntu operating system

Basic Need :

  1. apache server installed
  2. php 5.8 and above
  3. internet connection
  4. Root permission for terminal

// notice: in these steps i had use “brijesh” an an example for project name you can user your own porject name by replacing it with yours.

Step1: First install composer

user this link if needed more information // refference: https://getcomposer.org/download/

        use these command for installing composer

sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php composer-setup.php
sudo mv composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

// to un install composer
php -r "unlink('composer-setup.php');"

Step 2: Change root directory path (if your server folder is “html” then goto html folder

cd /var/www/html

Step 3: Install Laraven with your project name ex.: brijesh

composer<em> create-project laravel/laravel your-project-name</em>

ex.: composer create-project laravel/laravel brijesh

step 4: Give permission to brijesh , App, Storage , Piublic

sudo chmod -R 755 /var/www/html/brijesh
sudo chmod -R 777 /var/www/html/brijesh/app
sudo chmod -R 777 /var/www/html/brijesh/storage
sudo chmod -R 777 /var/www/html/brijesh/public

Step 5: create virtual host

// copy and past default host file by below comand to your { PROJECT NAME }<em></em>
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/brijesh.conf

// edit your .conf file
sudo vim /etc/apache2/sites-available/brijesh.conf

// Add this code  { replace brijesh with your project name } save and exit

 
<VirtualHost *:>
 
 ServerAdmin admin@brijesh
 ServerName brijesh.com
 ServerAlias www.brijesh.com
 DocumentRoot /var/www/html/brijesh/public/index.php

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

 <Directory /var/www/html/brijesh>
 AllowOverride All
 </Directory>

</VirtualHost>

// then press Esc and then write :wq and enter button end

Step 6: enable your vitural host

 
sudo a2ensite brijesh.conf
sudo service apache2 restart
 // OPTIONAL STEP
 Step 7: change host url
 </pre>
// open host
sudo vim /etc/hosts

// there look like
 127.0.0.1 localhost 
 // add your host name like
127.0.0.1 brijesh.com www.brijesh.com
 //save, exit and restart apache
sudo service apache2 restart

 

Type in url “www.brijesh.com” or “localhost/brijesh/public/index.php” 

if below screen appears brijesh.com
karavel

yo yo laravel starts woooo……….

notice : replace brijesh with you project name.

 

while installing laravel on ubuntu operating system if there is any problem please comment we will reply as soon as possible thanks.

 

WordPress Content Functions

These are the pre-define function defined in wordpress we just need to use 
it directly where we wanted.
the most common functions we normally use is get title , get site url etc.
So basically  these are for beginners  and you become expert while regular using this.
there are comment with every function to explain its functionality. 


// title of the post


<?php the_title(); ?>


// web site url 


<?php echo site_url(); ?>


// web site name 


<?php echo get_bloginfo(); ?>

// post body 

<?php 
if ( have_posts() ) : the_post();
the_content();
endif;
?> 


// get custom value of the post


<?php 
$cusomVal = get_post_custom_values('name_of_custom_value', $post->ID);
echo $cusomVal[0] ;
?>


// get post thumbnail 

<?php the_post_thumbnail(); ?>


// get thumbnail url

<?php  
$post_thumbnail_id = get_post_thumbnail_id($post->ID);
$post_thumbnail_url = wp_get_attachment_url( $post_thumbnail_id );
?> 


// post per page attributes (give the required number of post on the page)
<?php
  $args = array( 'posts_per_page' => 5, 'offset'=> 0 );
  $myposts = get_posts( $args );
?>

// limited post text on the page (put this on the place the_content())and add ellipse in the end


<?php the_excerpt(); ?>


// get published date 
<?php echo get_the_date(); ?>

</pre>
<pre>
 

Download table from mysql in .xls without Popup in Php

For download table from myslq into .xls form without asking have two basic steps:

  1. create connection to the database
  2. create index file to get the data from database, execute code and get desired output ( .xls file )

1.  connection to Database in connection.php

<?php $server="localhost"; 
$dbusername="root"; $dbPassword=""; 
$dbname="Database Name"; 
$connection_error= "your database is not connected";
 if(!mysql_connect($server,$dbusername,$dbPassword) || !mysql_select_db($dbname)) { die($connection_error); }
 ?>

 

2. Then in index.php add this code

<?php // connection connection file to index.php 
include ("connection.php");

 $setCounter = 0; $setData=""; 
$setExcelName = "download_excal_file";

// sql query which brings your table data
 $setSql = "SELECT * FROM `tablename` WHERE 1";

 // executing select query
 $setRec = mysql_query($setSql);

 // counting number of rows in the result of select query 
$setCounter = mysql_num_fields($setRec); $setMainHeader="";

 // creating header for .xls file

 for ($i = 0; $i &lt; $setCounter; $i++)
 {
 $setMainHeader .= mysql_field_name($setRec, $i)."\t"; 
}
 $setMainHeader.="\n"; 
while($rec = mysql_fetch_row($setRec))
 { $rowLine = ''; 

foreach($rec as $value)
 {
 if(!isset($value) || $value == "")
 { 
$value = "\t"; 
}
else {
 //It escape all the special charactor, quotes from the data. 
$value = strip_tags(str_replace('"', '""', $value));

$value = '"' . $value . '"' . "\t";
}
 $rowLine .= $value;
}
$setData .= trim($rowLine)."\n";
}

 $setData = str_replace("\r", "", $setData);

 if ($setData == "") 
{ 
$setData = "\nno matching records found\n";
 }

 $setCounter = mysql_num_fields($setRec);

 $myfile = fopen($setExcelName."_Reoprt.xls", "w") or die("Unable to open file!");

 $txt = $setMainHeader. $setData;

 fwrite($myfile, $txt);
 ?>

after adding this code in index file just load the file to the browser and check the root folder of your code you will get a xls file created with file name ending with “_Report.xls”

NOTE: You can give selected fields name if you want to get only some selected column instead of all the fields of table.

 
 

Full screen div at any screen and resolution

Add this in your javascript file and call this file after jquery file

function fullsize() 
{
	var new_height = window.innerHeight; // get new height of window
	var fullsize = new_height; 
	fullsize = parseInt(fullsize) + 'px'; // concatenate string get output in px format  
	jQuery("div").css('height',fullsize); // changing height of div
}
jQuery(document).ready(function()
{
	fullsize();
	jQuery(window).bind('resize', fullsize); // event is call at screen change ( resolution changes )
});

Note: you can replace ‘jQuery’ with ‘$’ if there is any issue due to ‘jQuery’ Keyword.