- Comments: 0
- 04 February 2014 21:30
- in Web Programming
- by admin
- Visits: 2306
- Last Modified: -/-
Recently there’s a buzzing word in php community about laravel framework. I heard a lot about it and thought let’s give it a try. You know what I’ve tried zend framework, cake php, symfony, codeigniter and others framework too. Honestly saying that laravel is the best (my opinion) and I liked it very much. Few days earlier I saw a article on sitepoint saying that the laravel is the best PHP framework in 2014. Surely it is getting too much attention for the php developers. Let’s have a look at the chart from sitepoint below.
This is the reason I’m writing this post to share my experience about laravel with you. So in this post I will show you how you can get started with laravel.
As laravel framework utilizes Composer for installation and dependency management. If you haven’t already, start by installing Composer. Follow the instruction from the mentioned link to install composer but if you are a *nix user like me run below command in the terminal to install composer.
$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer
This will install composer in your machine globally. To verify run
composer in terminal this will show you bunch of composer command if everything went well.
Now we will create a laravel project using composer command.
composer create-project laravel/laravel laravel-tutorial --prefer-dist copy & paste this command in terminal. This will download laravel and will create project named
There’s another way of creating laravel project but let’s not do this. If you are curious enough you can also try it. Go ahead and download the laravel repo from github and unzip it. Cd into the unzipped directory and run
composer install. This command will download and install the framework’s dependencies.
Next you may need to change the directory permission to grant the web server write permissions to the
We have installed laravel let’s try it now. If you are using php 5.4 you can run laravel easily by running
php artisan serve command from terminal. This will run laravel at http://localhost:8000. Browse the url via web browser and you will see below output.
Congratulations you have installed and running laravel framework in your machine but that’s not the end of this tutorial. We need to know a little bit more how you can continue from here. Let’s have a look at the directory structure first.
- App – The app directory contains folders such as
models. Most of your application’s code will reside somewhere in this directory.
- Public – In this directory we will store our css, img and other supporting files for view.
- App/Config – Application configuration files such as database, auth, application config etc.
- App/Controller – Our controller files goes here.
- App/Model – Our business logic goes here.
- App/View – Application view files are stored here.
Last but not the least have a look at the </code>route.php</code> file. Our routes through the application are defined here. As you can see
By default laravel is defined our route for the first view. You will find the view file in
That’s it. In future tutorial I will continue to laravel route, controller templating, migration, seed, authentication and basic CRUD.