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

No comments:

Post a Comment