Laravel 5.2 How to authenticate with a real mysql database - laravel

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?

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.

I think you might need to read again Laravel documentations.
Try the following.
Make sure you have a database create in your MySql.
Check again your .env for: database_host, database_name, database_user, database_password - make sure you have the right
Try bellow code on your route.php
Route::get('/', function () {
if(DB::connection()->getDatabaseName())
{
echo "Yes! successfully connected to the DB: " . DB::connection()->getDatabaseName();
}
});
If above is successful your migration should work.

Related

Laravel Homestead-authentication not working

I've setup Homestead and the site is up and running. It connects to my database and migrates tables.
The problem is that when I create a new project with authentication using this command : laravel new blog --auth, when I go to the register page and want to register a user I get this error:Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] (SQL: select count() as aggregate from users where email = vlad#yahoo.com)*. The user is not inserted into the database and cannot go further.
Found out this post: stackoverflow.com/a/41247114/11003430 and I've changed 127.0.0.1 to localhost and now it works. Don't know why though

Laravel - Moved project now can't login

I have an existing Laravel 5.6 project, I have moved it over to a new Bitnami WAMP installation.
I have migrated the database and seeded it so it contains my user account, but whenever I attempt to log in I get the following error..
these credentials do not match our records
I have confirmed the password is correct and that it can access the database, is there anything else I should be checking?
I am leaning towards it being a configuration issue with the Bitnami install but am slightly lost on where to be checking.
Change .env file, DB name, DB user name And DB Password
composer update
php artisan key:generate

Issues when trying to migrate

I am having a problem when trying to make migrate.
MY DATABASE DOES NOT RECEIVE NEW MIGRATION, NO NEW FILES NO UPDATES
From my project;
I do:
php artisan migrate
But nothing shows in my database, I already verify my database and my file .env
Both are correct.
I know you said you verified it, but please check again that the correct database information is entered in your .env file. It should be something like the following for a dev environment:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
You need to edit that data if you haven't and make sure it's correct. You also need to make sure that your database actually exists.
Also make sure you're actually entering the correct command. The general way you should making migrations is:
php artisan make:migration create_example_table --create=example
After that, run
php artisan migrate
Lastly, are you getting any errors in the console? If so, you need to edit your post and post them here.
firts thanks for answering
I had already checked .env file and I replaced database name from my sql (I use phpadmin), and also I changed username and password as I entered on sql server, but there is no migration
I had created a new table using artisan command (besides I have a users table that comes when downloading laravel project). After creating this new table I expected to upload this new one to my database located in sql server, but nothing happen
it shows your users yable already exists, mentions my users tables and not my new table that i just created. It is weird bcz it does not EVEN upload any changes made in default table users.....always answer your table users already exits

how to use external database table in codeigniter active records

I am facing below problem. Have to fetch a row from database which is not default db. i am querying like ->from("database_name.table_name"), but its been converted as ->from("``database_name``.``table_name``") as gives error. How to correct this please. Thank You!
Connect to second database in databse file. Load second database like this.
$DB2=$this->load->database($config, TRUE);
//then execute the query.
Also follow this link.
Codeigniter - multiple database connections
Hope this will help you.

Laravel4 Session handling issue?

I want to use Laravel Database Session. I have changed
'driver' => 'database',
in session.php.
When I try to access application i.e during landing page or before login
I am getting this error
null value in column "data" violates not-null constraint DETAIL
But if this error comes after login, then it is fine. Because that is when session is created. I did not understand why it is coming during application load.
Please let me know what is the issue or Please let me know the tutorial link for session handling in Laravel4
Thanks all
The "data" value you reference doesn't exist in the implementation of the Laravel session handler. The fields are id, payload and last_activity.
If you're trying to use Laravel's session handler via database, you're going to need to run the Laravel migrations.
Go to your command line and run artisan. php artisan session:table will automatically create the Laravel session migrations.
Then run composer dump-autoload or composer.phar dump-autoload (depending on your implementation).
Next, php artisan migrate and your Laravel session table will be created! You'll now be able to use laravel's built-in session handler.
Documentation here: http://laravel.com/docs/session#database-sessions

Resources