PHP development framework laravel installation and configuration tutorial

Source: Internet
Author: User
Tags php web development
Laravel is a simple and elegant PHP Web development framework. This article describes how to configure Laravel.

Laravel is a simple and elegant PHP Web development framework. This article describes how to configure Laravel.

Laravel is a simple and elegant PHP Web development framework. This article describes how to configure Laravel.

Configuration instructions

The framework has been downloaded, but we still need to know something to use. This is the configuration. Project-related configuration is in the app/config folder, but there are some other configurations that may be needed here. As a basic tutorial, I will not introduce it one by one. I just want to explain it in some scenarios where you have many configurations.

Configuration instructions in app/config

In the app/config folder, two files are often configured: app. php and database. php. One of them is the configuration item miscellaneous, and the other is the configuration database. Below I will explain the common configurations below:

First, the app. php file

// App/config/app. php file return array (/* | release | Laravel debug module | enabled | enable when set to 'true' (the following settings are default and enabled) | 'false' is disabled. When the program is enabled, an error message will be displayed when an error occurs. | when the program is closed, the page will jump to the error page (usually 404 pages) */'debug' => true,/* | used | application address | used | this address is used only when the Artisan command is used and must be set as the application root directory. | Yes. If you still don't know what I'm talking about, set it to null like below. */'Url' => '',/* | runtime | time zone of the application | runtime | this is the time zone operation. If you have not set PHP, the time zone is the United States time zone, | that is, 'utc'. Do you want to write a website targeting China's tianchao website? Set it to 'Asia/Shanghai. */'Timezone '=> 'Asia/Shanghai',/* | ---------------------------------------------------------------- | application localization | generally, you can set multiple language settings, the default value is 'en'. If you do not have your own language pack, you should leave this value alone. | You can see the Language Pack in the app/lang folder. If you don't have any multilingual idea, you don't need to worry about it. */'Locale' => 'en',/* | secret | application key | secret | this is the key used when Laravel's built-in encryption function is applied, to ensure encryption security. | If your file is not a random 32-bit string, you can use 'php artisan key: generate' | the command generates a 32-bit random string, remember to do this before you write a webpage. | Once you change this string, the contents encrypted with the previous string cannot be found !! */'Key' => '',);

In fact, there is still some content behind app. php, But it basically does not need to be modified. (This is only required when a third-party package is added. We will talk about it later)

Next we will introduce the database. php file

// App/config/database. php file return array (/* | bytes | PDO type | bytes | by default, Laravel databases are operated by PDO, which greatly improves database compatibility. | By default, the returned type is an object, that is, the following default settings. | If you want to return an array, you can set it to 'pdo: FETCH_ASSOC '*/'fetch' => PDO: FETCH_CLASS, /* | connections | default database connection name | -------------------------------------------------------------------------- | the name here corresponds to the name in the following 'connections, instead of the database you are using | for your better understanding, I changed a name here */'default' => 'meinv ', /* | database connection name | ------------------------------------------------------------------------------ | the configuration of various databases is set here, the 'driver 'in each array indicates the type of the database you want to use | you can set multiple configurations for the same database type, just name them separately, like the following 'mysql' and 'meinv' | others, I don't think I need to explain them. It is literal. I believe your English skills (in fact, my English is poor) */'connections' => array ('sqlite '=> array ('driver' => 'sqlite ', 'database' => _ DIR __. '/.. /database/production. sqlite ', 'prefix' => '',), 'mysql' => array ('driver' => 'mysql', 'host' => 'localhost ', 'database' => 'database', 'username' => 'root', 'Password' => '', 'charset' => 'utf8 ', 'colation' => 'utf8 _ unicode_ci ', 'prefix' => '',), 'meinv' => array (// here is the default Connection database name in the above example. It is actually the mysql database 'driver '=> 'mysql ', 'host' => 'localhost', 'database' => 'database', 'username' => 'root', 'Password' => '', 'charset' => 'utf8', 'colation' => 'utf8 _ unicode_ci ', 'prefix' => '',), 'pgsql' => array ('driver '=> 'pgsql', 'host' => 'localhost', 'database' => 'database ', 'username' => 'root', 'Password' => '', 'charset' => 'utf8', 'prefix' => '', 'scheme' => 'public',), 'sqlsrv' => array ('driver '=> 'sqlsrv', 'host' => 'localhost ', 'database' => 'database', 'username' => 'root', 'Password' => '', 'prefix' => '',),),);

Amount ~, You know, I certainly won't even finish it all. for you at the beginning, it is enough to know about database settings.

Configure the development environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.