Saturday, May 30, 2015

4. Hello world apps in laravel



In the previous three posts we have installed both composer and laravel, and configured the necessary settings so that we can work with laravel. Now in this tutorial we will create our first laravel application. Obviously it will very simple and tiny, but another step to enter the world of laravel. The application we will create will output some texts only as I have said before. Let's start to work.
 Step 01  Create a new directory inside htdocs
Go to the xampp installation folder, then open the htdocs folder and create a new folder inside it. For example: laraApps.

 Step 02  Change the directory to xampp installation drive
Open the run command prompt and type the drive letter as showed in the image below. For example: if you install xampp in D drive then you have to type d: and need to press the Enter Key.
So, now you are in D drive.

 Step 03  Change the directory to the newly created apps folder
Now we need to change the directory to the folder we have already created inside the htdocs folder. So, we need to type the command cd D:\xampp\htdocs\LaravelApps and also need to press the Enter Key.

 Step 04  Creating new application
Now type the command line laravel new myBlog and hit the Enter Key to create a new application named myBlog. You can try another name as you like.

After pressing the Enter Key, the system will do the listed things below...
1. Will craft the application
2. Will generate optimized class loader
3. Will compile common classes
4. Will set an application key by default
5. Will display the message that application is ready
It will take maximum five minutes to complete all above processes.

 Step 05  Open a browser
Now open a browser and type localhost/LaravelApps, you will get a page of directory. There you will find the newly created application myBlog, you have to click on that.

 Step 06  Get the welcome message
After clicking on the folder myBlog, you will get another folder named public. After clicking on the public folder, the Laravel welcome message will be displayed.

 Step 07  Get the directory
Now go to the directory D:\xampp\htdocs\LaravelApps\myBlog\app\Http\Controllers, there you will get a php file named WelcomeController.php. Open this .php file in an editor like notepad++, netbeans etc and comment out the line number 33. Add another line after that echo "Hello World"; and save the document. Finally reload the page you have opened, you will must get your own defined welcome message Hello World.

So, you have successfully created your first hello word application using laravel.
« Previous Tutorial || Next Tutorial »

Advertisement

Friday, May 29, 2015

3. Configure laravel path globaly

After completing the installation of laravel and composer, you have to change the path following the steps given below. Otherwise laravel won't work.
 Step 01  Get the directory
Find out laravel.bat file from the directory  C:\Users\Uzzwal Dhali\AppData\Roaming\Composer\vendor\bin. If you don't fond the AppData folder then change the settings like this. However, we need the directory, copy that.

 Step 02  Change the path
Now go to Start, right click on Computer / My Computer - a pop-up window will open. Click on Properties, then go to Advanced system settings - again a pop-up window will open, now click on Environmental Variables...

After clicking on Environmental Variables... , another pop-up window will open. Now select the line Path and click on the button Edit...

After clicking on the edit button, a pop-up window will open. Click on the text of the Variable value: and press the buttons Ctrl+A together and paste the path you have copied before in the first step.

 Step 03  Check Laravel if it is working or not
Press Windows Key+R together, the run command box will open. Now type cmd as the run command and press the Enter Key, the command prompt will open.

Now type Laravel and press the Enter Key, you will get something as shown in the image given bellow. It means the Laravel is working in your computer system perfectly.


« Previous Tutorial
Next Tutorial »


Advertisement

Friday, May 22, 2015

2. Installing laravel in windows computer

To work with laravel you must install both php composer and laravel. From the previous post, you have learned to install php composer. Now by this post you will learn to install laravel.
 Step 01  Get the command line
Go to the link http://laravel.com/docs/5.0#install-laravel and copy the command line composer global require "laravel/installer=~1.1"

 Step 02  Open command prompt and install laravel
Press Windows Key+R together to open the run command box. Now type cmd as run command and press the Enter Key. Paste the above command line you have copied and press the Enter Key. Soon the installation will start, but it will take few moments to be installed completely.

After completion you will get messages like the image given below.


« Previous Tutorial
Next Tutorial »


Advertisement

Sunday, May 17, 2015

Bubble sort program in java language


Bubble sorting program using java programming language
The java program given below is a bubble sort program, which is able to sort a collection of integer type numbers provided by the user. After running the program, the user will be asked to provide limit. That means, how many data he/she want to store. The 8th line of the program will display a message saying, "Enter the limit: ".

After providing the limit, it will be stored into an integer type variable limit by the 14th line. But, if we want to get any input then we must have to create Scanner Object as I have done by the 11th line. And we also import the Scanner package as like as the first line. In the 11th line I have created an Scanner Object named input, but you may name it anything as you like. As I have named it input, that's why I have used int limit = input.nextInt(); to store the limit.

By the 17th line, the user will be asked to store the data into the array. As I need to store data into an array, that's why I have declared an integer type array by the 20th line. In 23rd line there is a for-loop to store data into the array.
java program,bubble sorting program
import java.util.Scanner;
public class bubbleSort{
 public static void main(String args[]){
  //Declaring variables
  int i, j, temp;

  //Displaying message
  System.out.print("Enter the limit: ");

  //Creating scanner object
  Scanner input = new Scanner(System.in);
  
  //Storing the limit into variable
  int limit = input.nextInt();
  
  //Displaying message
  System.out.print("Enter the numbers: ");

  //Declaring integer type array
  int num[] = new int[limit];
  
  //for-loop for storing data into the array
  for(i=0; i<limit; i++){
   num[i] = input.nextInt();
  }
  
  //Displaying message
  System.out.print("The unsorted data into the array: ");

  //for-loop for displaying the unsorted data
  for(i=0; i<limit; i++){
   System.out.print(num[i]+", ");
  }
  
  //for-loop to sort the entered data
  for(i=0; i<limit; i++){
   for(j=0; j<limit-1; j++){
    if(num[j] > num[j+1]){
     //Data Swapping
     temp = num[j];
     num[j] = num[j+1];
     num[j+1] = temp;
    }
   }
  }
  
  //Displaying message
  System.out.print ("\nThe sorted data into the array: ");

  //for-loop for displaying the sorted data
  for(i=0; i<limit; i++){
   System.out.print(num[i]+", ");
  }
 }
}

Advertisement

Saturday, May 16, 2015

Binary search program in java


Operations of the java program given below
The java program given below is a binary search program. When you will run the program, then you will be asked to provide the limit. The 5th line is to show the message.

In the 8th line a scanner object input has been created, otherwise we couldn't input anything using keyboard. And most importantly we have to import the packages as like as the first line.

By the 11th line an integer type data will be stored into a variable limit. We have to use limit to define how many data we will store into the array.

Using the 14th line we will again display a message to provide the items/data. 

import java.util.*;
public class bsa{
 public static void main(String args[]){
  //Message to input the limit
  System.out.print("Enter the limit: ");

  //Creating scanner object
  Scanner input = new Scanner(System.in);

  //Getting input into the variable limit
  int limit = input.nextInt();

  //Message to provide the items
  System.out.print("Enter the items: ");

  //Declaring int type array
  int data[] = new int[limit];

  //Storing data into an array
  for(int i=0; i<limit; i++){
   data[i] = input.nextInt();
  }

  //Message to provide the expected item
  System.out.print("Enter an item to search: ");

  //Storing expected item into variable
  int searchItem = input.nextInt();

  //Initializing beginning and end
  int beg = 1, end = limit;

  //Defining the mid
  int mid = (beg + end)/2;

  //While loop to find out the data
  while(beg <= end && data[mid] != searchItem){
   if(searchItem < data[mid]){
    end = mid - 1;
   } else {
    beg = mid + 1;
   }

   mid = (beg + end)/2;
  }

  //Increasing the array position by 1
  int arrayPos = mid + 1;

  //If statement to display message if data found or not
  if(data[mid] == searchItem){
   System.out.println("Data found at position: "+arrayPos);
  } else {
   System.out.println("Data not found!!!");
  }
 }
}

Advertisement

Thursday, May 14, 2015

Linear search program in java for character type data


The java program given below is capable to perform linear search for characters. When you will run the program then you will be asked to provide the limit, that means how many characters do you want to provide. After providing the limit, you will be asked to provide the characters one by one.

And then you will be asked to provide a single character that you want to search. After providing the second for-loop of the program will check if there is the expected character. If found then a message will be displayed saying, "The character found at position: n" and if not found, then another message will be displayed saying, "The character  x has not found!!!"

import java.util.*;
public class charSearch{
 public static void main(String args[]){
  //DECLARING AN INTEGER TYPE VARIABLE
  int flag=0;

  //CREATING SCANNER OBJECT
  Scanner input = new Scanner(System.in);

  //MESSAGE TO INPUT THE LIMIT
  System.out.print("Enter the limit: ");

  //GETTING INPUT
  int limit = input.nextInt();

  //DECLARING AN STRING TYPE ARRAY
  char chars[] = new char[limit];

  //MESSAGE TO INPUT CHARACTERS
  System.out.print("Input the characters now: ");

  //STORING THE CHARACTERS INTO AN ARRAY
  for(int i=0; i<limit; i++){
   chars[i] = input.next().charAt(0);
  }

  //MESSAGE TO INPUT A CHARACTER TO SEARCH
  System.out.print("Enter the character you want to search: ");

  //STORING THE CHARACTER INTO VARIABLE
  char searchChar = input.next().charAt(0);

  //CHECKING THE EXPECTING CHARACTER INTO THE ARRAY
  for(int j=0; j<limit; j++){
   if(chars[j]==searchChar){
    //SETTING THE POSITION FOR THE CHARACTER
    int k = j+1;
    //DISPLAYING MESSAGE IF THE EXPECTED CHARACTER FOUND
    System.out.println("The character found at position: "+k);
    //SETTING FLAG=1 IF THE CHARACTER FOUND
    flag = 1;
   }
  }

  //DISPLAYING MESSAGE IF THE EXPECTED CHARACTER DOESN'T EXIST
  if(flag==0){
   System.out.println("The character "+searchChar+" has not found!!!");
  }
 }
}

Monday, May 11, 2015

Linear search program in java for float type data

The java program given below is able to search a float type number from an array. When you will run the program, then first of all you will be asked to provide a number that will be stored into a float type variable itemNumber.

After providing the number/limit, another message will be displayed asking the numbers you want to store. And the numbers will be stored one by one into a float type array numbers[].

Then another message will appear asking what do you want to search. After providing a float type number, it will be compared with each number stored into the array. If match, a message will be displayed saying "Item has found at position: 2", otherwise a message will be displayed saying "Item has not found".

Most importantly, if the item found in three location then the message "Item has found... " will be displayed three times.

import java.util.*;
public class floatSearch{
 public static void main(String args[]){
  //DECLARING VARIABLES
  int j, flag=0;

  //CREATING SCANNER OBJECT
  Scanner input = new Scanner(System.in);

  //ASKING TO PROVIDE THE NUMBER OF ITEM
  System.out.print("Enter the number of Item: ");

  //GETTING INPUT FROM KEYWORD
  int itemNumber = input.nextInt();

  //ASKING TO PROVIDE THE ITEMS
  System.out.print("Enter the items one by one: ");

  //DECLARING AN ARRAY
  float numbers[] = new float[itemNumber];

  //STORING THE ITEMS INTO AN ARRAY
  for(int i=0; i<itemNumber; i++){
   numbers[i] = input.nextFloat();
  }

  //ASKING TO PROVIDE THE DESIRED ITEM
  System.out.print("Enter the item you want to search: ");

  //STORING THE ITEM INTO VARIABLE
  float item = input.nextFloat();

  //SEARCHING AN ITEM
  for(j=0; j<itemNumber; j++){
   if(numbers[j] == item){
    int k=j+1;
    System.out.println("The item has found at position: "+k);
    flag = 1;
   }
  }

  if(flag == 0){
   System.out.println("Item has not found!!! :(");
  }
 }
}

Sunday, May 10, 2015

Linear search program in java for integer type data


The java program given below is able to search an integer type number from an array. When you will run the program, then first of all you will be asked to provide a number that will be stored into an integer type variable itemNumber. This number will be considered as number of elements that you want to store into an array.

After providing the number/limit, another message will be displayed asking the numbers/elements you want to store. And the numbers will be stored one by one into an integer type array numbers[].

Then another message will appear asking what do you want to search. After providing an integer type number, it will be compared with each number stored into the array. If match, a message will be displayed saying "Item has found at position: 2", otherwise a message will be displayed saying "Item has not found".

Most importantly, if the item found in three location then the message "Item has found... " will be displayed three times.

import java.util.*;
public class linearSearch{
 public static void main(String args[]){
  //DECLARING VARIABLES
  int j, flag=0;
  
  //CREATING SCANNER OBJECT
  Scanner input = new Scanner(System.in);

  //ASKING TO PROVIDE THE NUMBER OF ITEM
  System.out.print("Enter the number of Item: ");

  //GETTING INPUT FROM KEYWORD
  int itemNumber = input.nextInt();

  //ASKING TO PROVIDE THE ITEMS
  System.out.print("Enter the items one by one: ");

  //DECLARING AN ARRAY
  int numbers[] = new int[itemNumber];

  //STORING THE ITEMS INTO AN ARRAY
  for(int i=0; i<itemNumber; i++){
   numbers[i] = input.nextInt();
  }

  //ASKING TO PROVIDE THE DESIRED ITEM
  System.out.print("Enter the item you want to search: ");

  //STORING THE ITEM INTO VARIABLE
  int item = input.nextInt();

  //SEARCHING AN ITEM
  for(j=0; j<itemNumber; j++){
   if(numbers[j] == item){
    int k=j+1;
    System.out.println("The item has found at position: "+k);
    flag=1;
   }
  }

  if(flag == 0){
   System.out.println("Item has not found!!! :(");
  }
 }
}

Advertisement