0

I'm new with laravel, I read the documentation of laravel, but I don't know how I make an authentication with a real mysql database. I mean, I see that there is a php migration command, but it makes a table in php and not in my database right ? Actually, I have a mysql database with a user table with login and password. I'm lost with this framework, because I never used a php framework.

Thanks !!

Edit : Excuse me, I misspoke and my problem has evolved, how did you to authenticate with a user table already exists in the database by using the Authentication service?

1
  • You need to configure your db connection in .env file. Then Laravel 5.2 can create auth for you php artisan make:auth Commented Jun 10, 2016 at 10:50

2 Answers 2

3

in .env or config>database.php you can set your database and related database connections configurations after that create migrations and run them it will create database tables in your database as per your .env or config>database.php database configurations.

Sign up to request clarification or add additional context in comments.

19 Comments

Don't use database.php. Use .env instead
thank you for your reply, I set my database but If I already have a table user in my database, is the migration command will delete my table ?
Doesn't deserve a downvote, you can use config/database.php or .env
@haakym sure, but if u will share 1 connection accross all team, its not cool.
drop your table and run your migrations. @KhoyaDev
|
1

I think you might need to read again Laravel documentations.

Try the following.

  1. Make sure you have a database create in your MySql.
  2. Check again your .env for: database_host, database_name, database_user, database_password - make sure you have the right
  3. Try bellow code on your route.php

    Route::get('/', function () { if(DB::connection()->getDatabaseName()) { echo "Yes! successfully connected to the DB: " . DB::connection()->getDatabaseName(); } });

  4. If above is successful your migration should work.

1 Comment

Thank you, this is well explained !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.