You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Naming Your Application](#naming-your-application)
10
-
-[Maintenance Mode](#maintenance-mode)
3
+
-[安装](#installation)
4
+
-[配置](#configuration)
5
+
-[基本配置](#basic-configuration)
6
+
-[环境配置](#environment-configuration)
7
+
-[配置缓存](#configuration-caching)
8
+
-[获取配置项](#accessing-configuration-values)
9
+
-[应用程序命名](#naming-your-application)
10
+
-[维护模式](#maintenance-mode)
11
11
12
12
<aname="installation"></a>
13
-
## Installation
13
+
## 安装
14
14
15
-
### Server Requirements
15
+
### 服务器要求
16
16
17
-
The Laravel framework has a few system requirements. Of course, all of these requirements are satisfied by the [Laravel Homestead](/docs/{{version}}/homestead)virtual machine:
@@ -25,64 +25,64 @@ The Laravel framework has a few system requirements. Of course, all of these req
25
25
</div>
26
26
27
27
<aname="install-laravel"></a>
28
-
### Installing Laravel
28
+
### 安装 Laravel
29
29
30
-
Laravel utilizes[Composer](http://getcomposer.org) to manage its dependencies. So, before using Laravel, make sure you have Composer installed on your machine.
Once installed, the simple `laravel new`command will create a fresh Laravel installation in the directory you specify. For instance, `laravel new blog`will create a directory named `blog`containing a fresh Laravel installation with all of Laravel's dependencies already installed. This method of installation is much faster than installing via Composer:
All of the configuration files for the Laravel framework are stored in the `config`directory. Each option is documented, so feel free to look through the files and get familiar with the options available to you.
After installing Laravel, you may need to configure some permissions. Directories within the `storage`and the `bootstrap/cache`directories should be writable by your web server. If you are using the [Homestead](/docs/{{version}}/homestead)virtual machine, these permissions should already be set.
60
+
安装 Laravle 后,你可能需要配置一些权限。目录内的 `storage`和 `bootstrap/cache`目录在你的 Web 服务器中应有写权限。如果你使用 [Homestead](/docs/{{version}}/homestead)虚拟机,那么相关的权限已配置好。
61
61
62
-
#### Application Key
62
+
#### 应用密钥
63
63
64
-
The next thing you should do after installing Laravel is set your application key to a random string. If you installed Laravel via Composer or the Laravel installer, this key has already been set for you by the `key:generate`command. Typically, this string should be 32 characters long. The key can be set in the `.env`environment file. If you have not renamed the `.env.example`file to `.env`, you should do that now. **If the application key is not set, your user sessions and other encrypted data will not be secure!**
Laravel needs almost no other configuration out of the box. You are free to get started developing! However, you may wish to review the `config/app.php`file and its documentation. It contains several options such as `timezone`and`locale` that you may wish to change according to your application.
The framework ships with a `public/.htaccess`file that is used to allow URLs without`index.php`. If you use Apache to serve your Laravel application, be sure to enable the `mod_rewrite`module.
It is often helpful to have different configuration values based on the environment the application is running in. For example, you may wish to use a different cache driver locally than you do on your production server. It's easy using environment based configuration.
To make this a cinch, Laravel utilizes the [DotEnv](https://github.com/vlucas/phpdotenv)PHP library by Vance Lucas. In a fresh Laravel installation, the root directory of your application will contain a `.env.example`file. If you install Laravel via Composer, this file will automatically be renamed to `.env`. Otherwise, you should rename the file manually.
All of the variables listed in this file will be loaded into the `$_ENV` PHP super-global when your application receives a request. You may use the `env`helper to retrieve values from these variables. In fact, if you review the Laravel configuration files, you will notice several of the options already using this helper!
Feel free to modify your environment variables as needed for your own local server, as well as your production environment. However, your `.env`file should not be committed to your application's source control, since each developer / server using your application could require a different environment configuration.
If you are developing with a team, you may wish to continue including a `.env.example`file with your application. By putting place-holder values in the example configuration file, other developers on your team can clearly see which environment variables are needed to run your application.
#### Accessing The Current Application Environment
117
+
#### 获取当前应用环境
118
118
119
-
The current application environment is determined via the `APP_ENV` variable from your `.env`file. You may access this value via the `environment` method on the`App`[facade](/docs/{{version}}/facades):
You may also pass arguments to the `environment`method to check if the environment matches a given value. You may even pass multiple values if necessary:
@@ -130,56 +130,56 @@ You may also pass arguments to the `environment` method to check if the environm
130
130
// The environment is either local OR staging...
131
131
}
132
132
133
-
An application instance may also be accessed via the `app`helper method:
133
+
一个应用实例也可以被通过 `app`辅助函数访问到:
134
134
135
135
$environment = app()->environment();
136
136
137
137
<aname="configuration-caching"></a>
138
-
### Configuration Caching
138
+
### 配置缓存
139
139
140
-
To give your application a speed boost, you should cache all of your configuration files into a single file using the `config:cache` Artisan command. This will combine all of the configuration options for your application into a single file which can be loaded quickly by the framework.
You should typically run the `php artisan config:cache`command as part of your production deployment routine. The command should not be run during local development as configuration options will frequently need to be changed during the course of your application's development.
You may easily access your configuration values using the global `config`helper function. The configuration values may be accessed using "dot" syntax, which includes the name of the file and option you wish to access. A default value may also be specified and will be returned if the configuration option does not exist:
To set configuration values at runtime, pass an array to the `config`helper:
151
+
要在程序运行时设置一个配置项,需传递一个数组到 `config`辅助函数:
152
152
153
153
config(['app.timezone' => 'America/Chicago']);
154
154
155
155
<aname="naming-your-application"></a>
156
-
### Naming Your Application
156
+
### 应用程序命名
157
157
158
-
After installing Laravel, you may wish to "name" your application. By default, the `app`directory is namespaced under `App`, and autoloaded by Composer using the [PSR-4 autoloading standard](http://www.php-fig.org/psr/psr-4/). However, you may change the namespace to match the name of your application, which you can easily do via the `app:name` Artisan command.
For example, if your application is named "Horsefly", you could run the following command from the root of your installation:
160
+
例如,如果你的应用被命名为 "Horsefly",你可以在框架根目录下执行以下命令:
161
161
162
162
php artisan app:name Horsefly
163
163
164
-
Renaming your application is entirely optional, and you are free to keep the `App` namespace if you wish.
164
+
重命名你的应用不是必须的。你完全可以保留默认的命名空间 `App`。
165
165
166
166
<aname="maintenance-mode"></a>
167
-
## Maintenance Mode
167
+
## 维护模式
168
168
169
-
When your application is in maintenance mode, a custom view will be displayed for all requests into your application. This makes it easy to "disable" your application while it is updating or when you are performing maintenance. A maintenance mode check is included in the default middleware stack for your application. If the application is in maintenance mode, an `HttpException`will be thrown with a status code of 503.
While your application is in maintenance mode, no [queued jobs](/docs/{{version}}/queues)will be handled. The jobs will continue to be handled as normal once the application is out of maintenance mode.
185
+
当你的应用处于维护模式,将不会有 [队列 Jobs](/docs/{{version}}/queues)被处理。这些 Jobs 将在应用关闭维护模式后继续正常处理。
0 commit comments