laravel中数据库配置_Laravel中的配置

laravel中数据库配置

I hope, after reading the project structure of Laravel project, you will understand the concept of why we use the Laravel framework, it's installation and It's important directories. It's pre-defined directories made easy everything creating a project to database work.

我希望,在阅读了Laravel项目项目结构之后,您将了解为什么我们使用Laravel框架的概念,它的安装以及它的重要目录。 它的预定义目录使创建数据库项目的所有工作变得容易。

For further process, we need to configure our project to customize it. This configuration allows you to set values.

为了进行进一步的处理,我们需要配置项目以对其进行自定义。 此配置允许您设置值。

In the config directories, we will see a bunch of various PHP files here labeled each for a section of the application. Each of these files is loaded by laravel when your application processes a request means we can add new files if we need it.

在config目录中,我们将看到一堆各种PHP文件,其中每个文件都标记了应用程序的一部分。 当您的应用程序处理请求时,laravel会加载每个文件,这意味着我们可以根据需要添加新文件。

config/app.php: 'env' function with two-parameter where 'env' function gets the value from shell environment in which our application runs.

配置/ app.php:“ENV”有两个参数,其中“ENV”函数从shell环境,使我们的应用程序运行时的价值功能。

    env(APP_NAME,'LARAVEL');

  • First parameter, APP_NAME which is used for the environmental variable to local.

    第一个参数APP_NAME用于将环境变量设置为local。

  • Second parameter, LARAVEL which is the default value to use if none is set.

    第二个参数LARAVEL是未设置的默认值。

timezone: This value is set as a static value if we want to change this value, we could. It means we may have a different timezone for our different environments.

时区:如果我们要更改此值,则可以将其设置为静态值。 这意味着我们针对不同的环境可能会有不同的时区。

Laravel uses an 'env' package for these environments get set or for timezone used regardless of where our application is running.

无论我们的应用程序在哪里运行,Laravel都会为这些环境设置或使用的时区使用“ env”包。

vendor: ' .env ' file (enviornment file) : [app_name='laravel']

供应商: '.env'文件(环境文件):[app_name ='laravel']

  • [app_env = homestead]: changes and see the changes on the browser on the main laravel page.

    [app_env = homestead] :更改并在laravel主页上的浏览器上查看更改。

  • If you remove this 'app_env' and save then you will see the production page on the main page on the browser.

    如果删除此“ app_env”并保存,则将在浏览器的主页上看到生产页面。

After installation, we have to do something for starting our new project or for Laravel Configuration.

安装后,我们必须做一些事情来启动我们的新项目或进行Laravel配置。

1) Create a new project

1)创建一个新项目

Check my previous article, Installation in Laravel, if you don't know how to create a new project in laravel.

如果您不知道如何在laravel中创建新项目,请查看我之前的文章Laravel中的安装

2) Database configuration on PHPMyAdmin using xampp server named "blog" (DB name). It means you have to create a database on PHPMyAdmin named "blog".

2)使用名为“ blog”(数据库名称)的xampp服务器在PHPMyAdmin上进行数据库配置。 这意味着您必须在PHPMyAdmin上创建一个名为“ blog”的数据库。

Note: you can also use your own database name.

注意:您也可以使用自己的数据库名称。

3) After this, you have to make changes in .env file which is known as environment file in Laravel.

3)之后,您必须在.env文件中进行更改,该文件在Laravel中称为环境文件。

    DB_DATABASE -> 'blog', 
    DB_USERNAME -> 'root', 
    DB_PASSWORD -> 'null'

Configuration in Laravel | step 1

4) Now, Open the project run command on Command prompt to start the laravel server for using its pre-defined functionality.

4)现在,在命令提示符下打开项目运行命令,以启动laravel服务器以使用其预定义功能。

On CMD --> $ php artisan serve

在CMD上-> $ php artisan服务

Configuration in Laravel | step 2

5) Now, RUN on browser -> localhost:8000

5)现在,在浏览器上运行-> localhost:8000

Configuration in Laravel | step 3

Conclusion:

结论:

In this article, we are learned about the configuration of Laravel first project. I hope you will understand the concept. we will know more about it in the upcoming article. Have a nice day! Happy Learning!

在本文中,我们了解了Laravel first项目的配置 。 希望您能理解这个概念。 我们将在下一篇文章中进一步了解它。 祝你今天愉快! 学习愉快!

翻译自: https://www.includehelp.com/laravel/configuration-in-laravel.aspx

laravel中数据库配置

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值