Thursday, December 29, 2016

Creating a sample laravel 5.2 Project with PHPUnit

Creating a sample laravel 5.2 Project with PHPUnit

Laravel Installation

First we need to install the laravel. 

Commonly laravel is installing using Composer. So if you are not installed the composer first we need to install it in your system.

We can install the composer from the url :

After installing the composer take the Terminal and go to the directory where you need to create the project.

Now from the terminal run the following command  and it will create the laravel project in the 'Student' directory.

composer create-project laravel/laravel Student

Wait for some time and it will install the laravel for you.

Now the installation is finished and take the url http://localhost:8080/ 

It will show the 'Student' directory there and take it and then take 'Public' folder. Now you can see the 'Laravel 5' welcome screen on the browser.

Now we are going to create a database for storing the students info.

Take the phpmyadmin (Hopefully it is in and create a database named Students.

Now we need to fill the database details in the .env file


Now we need to create a migration for creating the table in the database.

For it run the following command from the terminal from the students directory:

php artisan make:migration create_students_table

This will create a migration file in the database/migrations folder.

Open it and update the up() function with the following content.

Schema::create('students', function(Blueprint $table)

Fill the down() function with the following content


Then from the terminal run the command : 

php artisan migrate

This will create the students table in the Students database. Please check it.

Monday, December 26, 2016

Solution for not affecting the changes in .env file in laravel

Laravel : After make changes to env file it is better to run the following command to affect the new changes in your application.

If you change the .env file content and it is not affecting then run the following command from the command prompt

php artisan config:cache

It will show the following result :

Configuration cache cleared!
Configuration cached successfully!