Simple steps for installtion of laravel for biggeners

1. Goto server directory(www for wamp,htdocs for xampp,etc)
2. Run "git clone git@github.com:laravel/laravel.git" (git shows an internal or external error for windows users),do below
->goto this url in browser "https://github.com/laravel/laravel"
->click "clone or download"
->then click download zip
->extract that zip into server directory to a folder (in my case "rest" is the project name)
3. Now move to the project directory(rest) using "cd rest"
4. Now, run "composer install" (make sure you have installed composer in your pc,if u don't have first instll composer)
5. Rename .env.example file to .env use this command "rename .env.example .env"
6. Now, php artisan key:generate
7. open http://localhost/{project name}/public in my case(http://localhost/rest/public/)
that's it basic installation of laravel completed.

Now we will discuss about using database:

it is better to use migration for creating tables in laravel,this will autometically generate some dependencys
Creating tables using migration
1. update your local database details in .env file before u proceed to below steps
in your.env file update below fileds

[code language="php"]
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_mysql_server_user_name
DB_PASSWORD=your_mysql_server_password

[/code]
1. After changing .env file run following command
"php artisan migrate" , this will create two tables in your database,here by default users,password_resets tables migrations are added by default by laravel

While running this command you may got this type exceptions
"[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (S
QL: alter table `users` add unique `users_email_unique`(`email`))"
If you got any exception like this means,you are using an old mysql server or maria db,
for this you need to add this line

[code language="php"]
use Illuminate\Support\Facades\Schema;

public function boot()
{
Schema::defaultStringLength(191);
}

[/code]
in AppServiceProvider.php located inside "project_folder/app/Providers"

2. If you want to create a new table simple run "php artisan make:migration create_table_name"
3. This will create a file with name xxxxx_xxx_xxx_xxx_create_table_name.php file,you can add fields what you need in up method there

Comments

Popular posts from this blog

Simple Mail Sending Contact Form using PHP and Jquery

Codeigniter with Admin LTE

onclick anchor tag open url in bootstrap model