Environment Configuration
-----------------------------------------------
Database - Laravel Migration:
Laravel Migration is they are king of table generators, column generators. Basically what we do is we defind the table insight or application side Laravel. we define the table and we define the columns in how we wanted the columns and then we run a PHP artisan command and then we create a table where ever that table software is. if we are using MYSQL in that this example you're going to able to see that table in phpmyadmin or another program you use to see your tables. If we are using SQLite a file base Database then you're able to go and see that information in these files.
Why is t so important to do migrations???
Because imagines that you have to share your project. Now you don't have to go to phpmyadmin or export your Database. you don't have to do that. or you have to do is just give the project to somebody else. and what we do is they just run PHP artisan command and that have their tables created for them automatically in their site.
-------------------------------------------------
Configuration files and environment variable or file:
.env, .evn.example - environment files :
when you use a composer you are going the composer is going to create these files (.env, .env.example) automatically. you never want to push this project to production with your personal information. remember this very sensitive data. we got an API key here, we got a Database connection driver information, we got mail information, we got a REDIS information. there is a lot of things here that are personal right to your application. So what does is you put all the necessary information in the .env file that .env.example file. Everything that makes application work and everything else you just leave it as default. Now when the developer gets it over there So that you ship your application and you tell the team to listen. I'm done with it. Now's your chance to keep developing. you're going to send it with .env.example. they're going to rename it to .evn make it work.
if you see .env or .env.example file constant or keys and values or whatever the thing. these are actually called environment variables. This file is environment files. you never want to send it to Github. Laravel project also .gitignore file has been added to the .env file.
So,
.evn.example file - you never put sensitive information here.
.evn file - you put sensitive information right here.
-----------------------------------------------
how to you use it ??
1. go to config->database.php :
this file returning an array. that array has a lot of keys and values. But not only keys and values when using helper functions there to define the path ( database_path()), we use in their environment functions here (even('DB_HOST', 'localhost')) to set the key and the value. ('DB_HOST' - key, 'localhost' - value).
this file basically if you see this is called connection drivers. we have SQLite(it is a file-based database), MYSQL, pgsql, sqlsry ..etc.
SQLite:
SQLite is a file-based database meaning that we don't have to use some type of special program or anything like that. these are information data saved in files. So if we have a small application we don't wanna deal with MYSQL well we could deal with SQLite and every information every data that we have is going to be saved in files. So we're going to have a database that is SQLite file with all of the information about everything that we need for users or for polls or for categories of information is going to be saved in files. So that's why I like really is. this is for very small applications.
MYSQL:
MYSQL is using for bigger applications.
No comments:
Post a Comment