0
votes

I have a complete database hosted and I want to integrate it into my laravel new project. All I know is how to change the env file and I did so. There is a couple of questions though:

  • Does using online database with laravel need creating classes?

  • What should I add to the env file? This from my env file:

    DB_CONNECTION=MySQL
    DB_HOST=(my server IP)
    DB_PORT=3306
    DB_DATABASE=name
    DB_USERNAME=done
    DB_PASSWORD=done

What else should I add and where?

1

1 Answers

0
votes

If you are using Laravel with Database you have to specify which database you want to connect (Live/Local). You can configure your database credentials in .env and database.php inside config folder.

Most preferred way is by using .env from the root directory/folder. Doing this it will be easier for deploying in multiple instances like UAT, PROD, etc.

Comming back to your questions:

  • Does using online database with laravel need creating classes? I assume you refer to models.

The answer is Yes and No.

NO: If you want to use Laravel Query Builder.

YES: If you want to use Elloquent ORM.

I personally prefer using Elloquent ORM instead of writing lots of dirty join query and beyond. Once you get the hang of it, you will never step away from Elloquent ORM. It take a bit of time to learn but worth the time you will invest.

  • What should I add to the env file? This from my env file:

I think you are good with your current .env

Good luck and happy learning.