Installing and creating users in Laravel 5.6
First steps:
- Install MySQL
- Install PHP
- Windows
- Linux (Ubuntu)
- Install Composer
- Windows
- Linux (Ubuntu)
- Open a new terminal or command prompt and follow the following commands
- cd D:/sites
- composer global require "laravel/installer"
- composer create-project --prefer-dist laravel/laravel ProjectName
- cd ProjectName
- Windows
- copy .env.example .env
- Linux
- cp .env.example .env
- Now go to the new file you created and edit it. you will find a section that looks like this
- DB_CONNECTION=mysql
- DB_HOST=127.0.0.1
- DB_PORT=3306
- DB_DATABASE=homestead
- DB_USERNAME=homestead
- DB_PASSWORD=secret
- change these according to the database you have already created
- See Step 1
- In your terminal/command prompt run the following
- php artisan make:auth
- php artisan migrate
- php artisan serve --port 80
- Open your web browser and go to http://localhost
- you will now see the laravel boiler plate.
- you can click login or register and create users that easy
- What if you want to create your own users your own way (easy)
- Go back to your terminal / command prompt and run these commands
- ctrl + c -- to exit the serving command
- php artisan make:controller UserController --resource
- Now go to your project folder and navigate to app/http/controllers
- in this folder you will find your new PHP class / controller UserController
- navigate to the create method
- type the following code
return view ('users.create');
- Now go to your root directory and go to resources/views
- create a folder called users
- in the users folder create a file create.blade.php
- In the create.blade.php file create your html form method of post action of /users
- your form should include the following fields
- name
- password
- go back to your UserController file
- go to the store method
- type the following code in the store method
$user = new \App\User(); $request->password = bcrypt($request->get('password')); $user->fill($request->all()); $user->save(); return view ('users.create');
- go back to the terminal / command prompt -- command time
- php artisan serve --port 808
- go to http://localhost/users/create
- fill your form and submit (should bring you back to your create form)
- go back to http://localhost
- log out (upper right)0
- login as your new user.
CONGRADUFUCKINGLATIONS
you just created your new user and users in laravel - the dirty way lol
Dedicated to
@Wotta
@Tom Ellis
@Mojtabaa