Skip to content
1 change: 1 addition & 0 deletions cookbook/en/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ This book conforms to the [Terms of Yii Documentation](https://www.yiiframework.
- [Preface](preface.md)
- [Structuring code by use-case with vertical slices](organizing-code/structuring-by-use-case-with-vertical-slices.md)
- [Sentry integration](sentry-integration.md)
- [Configuring webservers](configuring-webservers/general.md)
46 changes: 46 additions & 0 deletions cookbook/en/configuring-webservers/apache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Configuring web servers: Apache

Use the following configuration in Apache's `httpd.conf` file or within a virtual host configuration. Note that you
should replace `path/to/app/public` with the actual path for `app/public`.

```apacheconfig
# Set document root to be "app/public"
DocumentRoot "path/to/app/public"

<Directory "path/to/app/public">
# use mod_rewrite for pretty URL support
RewriteEngine on

# if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^index.php/ - [L,R=404]

# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Otherwise forward the request to index.php
RewriteRule . index.php

# ...other settings...
</Directory>
```

In case you have `AllowOverride All` you can add `.htaccess` file with the following configuration instead of
using `httpd.conf`:

```apacheconfig
# use mod_rewrite for pretty URL support
RewriteEngine on

# if $showScriptName is false in UrlManager, do not allow accessing URLs with script name
RewriteRule ^index.php/ - [L,R=404]

# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Otherwise forward the request to index.php
RewriteRule . index.php

# ...other settings...
```
15 changes: 15 additions & 0 deletions cookbook/en/configuring-webservers/general.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Configuring web servers: General

On a production server, if you don't use Docker, configure your web server to serve only the application's public files.
Point the document root of your web server to the `app/public` folder.

> Info: If you're running your Yii application behind a reverse proxy, you might need to configure
> [Trusted proxies and headers](../../../guide/en/security/trusted-request.md).

## Specific server configurations

- [Nginx](nginx.md)
- [Apache](apache.md)
- [Lighttpd](lighttpd.md)
- [Nginx Unit](nginx-unit.md)
- [IIS](iis.md)

Check notice on line 15 in cookbook/en/configuring-webservers/general.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/general.md#L15

[Microsoft.Acronyms] 'IIS' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'IIS' has no definition.", "location": {"path": "cookbook/en/configuring-webservers/general.md", "range": {"start": {"line": 15, "column": 4}}}, "severity": "INFO"}
34 changes: 34 additions & 0 deletions cookbook/en/configuring-webservers/iis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Configuring web servers: IIS

Check warning on line 1 in cookbook/en/configuring-webservers/iis.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/iis.md#L1

[Microsoft.HeadingAcronyms] Avoid using acronyms in a title or heading.
Raw output
{"message": "[Microsoft.HeadingAcronyms] Avoid using acronyms in a title or heading.", "location": {"path": "cookbook/en/configuring-webservers/iis.md", "range": {"start": {"line": 1, "column": 28}}}, "severity": "WARNING"}

Check notice on line 1 in cookbook/en/configuring-webservers/iis.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/iis.md#L1

[Microsoft.Acronyms] 'IIS' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'IIS' has no definition.", "location": {"path": "cookbook/en/configuring-webservers/iis.md", "range": {"start": {"line": 1, "column": 28}}}, "severity": "INFO"}

When you use [IIS](https://www.iis.net/), host the application in a virtual host (Website) where the document

Check notice on line 3 in cookbook/en/configuring-webservers/iis.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/iis.md#L3

[Microsoft.Acronyms] 'IIS' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'IIS' has no definition.", "location": {"path": "cookbook/en/configuring-webservers/iis.md", "range": {"start": {"line": 3, "column": 15}}}, "severity": "INFO"}
root points to the `path/to/app/public` folder and configure the website to run PHP.
In that `public` folder, place a file named `web.config` at `path/to/app/public/web.config`.
Use the following content:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<rewrite>
<rules>
<rule name="Hide Yii Index" stopProcessing="true">
<match url="." ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile"
ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory"
ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
```

Also, the following list of Microsoft's official resources could be useful to configure PHP on IIS:

Check notice on line 31 in cookbook/en/configuring-webservers/iis.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/iis.md#L31

[Microsoft.Acronyms] 'IIS' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'IIS' has no definition.", "location": {"path": "cookbook/en/configuring-webservers/iis.md", "range": {"start": {"line": 31, "column": 96}}}, "severity": "INFO"}

1. [How to set up your first IIS website](https://support.microsoft.com/en-us/help/323972/how-to-set-up-your-first-iis-web-site)

Check notice on line 33 in cookbook/en/configuring-webservers/iis.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/iis.md#L33

[Microsoft.Acronyms] 'IIS' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'IIS' has no definition.", "location": {"path": "cookbook/en/configuring-webservers/iis.md", "range": {"start": {"line": 33, "column": 30}}}, "severity": "INFO"}
2. [Configure a PHP Website on IIS](https://docs.microsoft.com/en-us/iis/application-frameworks/scenario-build-a-php-website-on-iis/configure-a-php-website-on-iis)

Check notice on line 34 in cookbook/en/configuring-webservers/iis.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/iis.md#L34

[Microsoft.Acronyms] 'IIS' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'IIS' has no definition.", "location": {"path": "cookbook/en/configuring-webservers/iis.md", "range": {"start": {"line": 34, "column": 32}}}, "severity": "INFO"}
7 changes: 7 additions & 0 deletions cookbook/en/configuring-webservers/lighttpd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Configuring web servers: lighttpd

Check notice on line 1 in cookbook/en/configuring-webservers/lighttpd.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/lighttpd.md#L1

[Microsoft.Headings] 'Configuring web servers: lighttpd' should use sentence-style capitalization.
Raw output
{"message": "[Microsoft.Headings] 'Configuring web servers: lighttpd' should use sentence-style capitalization.", "location": {"path": "cookbook/en/configuring-webservers/lighttpd.md", "range": {"start": {"line": 1, "column": 3}}}, "severity": "INFO"}

Check failure on line 1 in cookbook/en/configuring-webservers/lighttpd.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/lighttpd.md#L1

[Microsoft.HeadingColons] Capitalize ': l'.
Raw output
{"message": "[Microsoft.HeadingColons] Capitalize ': l'.", "location": {"path": "cookbook/en/configuring-webservers/lighttpd.md", "range": {"start": {"line": 1, "column": 26}}}, "severity": "ERROR"}

To use [lighttpd](https://www.lighttpd.net/) >= 1.4.24, put `index.php` in the web root and add the following to the configuration:

```
url.rewrite-if-not-file = ("(.*)" => "/index.php/$0")
```
60 changes: 60 additions & 0 deletions cookbook/en/configuring-webservers/nginx-unit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Configuring web servers: NGINX Unit

Check notice on line 1 in cookbook/en/configuring-webservers/nginx-unit.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/nginx-unit.md#L1

[Microsoft.Acronyms] 'NGINX' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'NGINX' has no definition.", "location": {"path": "cookbook/en/configuring-webservers/nginx-unit.md", "range": {"start": {"line": 1, "column": 28}}}, "severity": "INFO"}

Run Yii-based apps using [NGINX Unit](https://unit.nginx.org/) with a PHP language module.

Check notice on line 3 in cookbook/en/configuring-webservers/nginx-unit.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/nginx-unit.md#L3

[Microsoft.Acronyms] 'NGINX' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'NGINX' has no definition.", "location": {"path": "cookbook/en/configuring-webservers/nginx-unit.md", "range": {"start": {"line": 3, "column": 27}}}, "severity": "INFO"}
Here is a sample configuration.

Check notice on line 4 in cookbook/en/configuring-webservers/nginx-unit.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/nginx-unit.md#L4

[Microsoft.Vocab] Verify your use of 'sample' with the A-Z word list.
Raw output
{"message": "[Microsoft.Vocab] Verify your use of 'sample' with the A-Z word list.", "location": {"path": "cookbook/en/configuring-webservers/nginx-unit.md", "range": {"start": {"line": 4, "column": 11}}}, "severity": "INFO"}

```json
{
"listeners": {
"*:80": {
"pass": "routes/yii"
}
},

"routes": {
"yii": [
{
"match": {
"uri": [
"!/assets/*",
"*.php",
"*.php/*"
]
},

"action": {
"pass": "applications/yii/direct"
}
},
{
"action": {
"share": "/path/to/app/public/",
"fallback": {
"pass": "applications/yii/index"
}
}
}
]
},

"applications": {
"yii": {
"type": "php",
"user": "www-data",
"targets": {
"direct": {
"root": "/path/to/app/public/"
},

"index": {
"root": "/path/to/app/public/",
"script": "index.php"
}
}
}
}
}
```

You can also [set up](https://unit.nginx.org/configuration/#php) your PHP environment or supply a custom `php.ini`
in the same configuration.
56 changes: 56 additions & 0 deletions cookbook/en/configuring-webservers/nginx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Configuring web servers: Nginx

To use [Nginx](https://wiki.nginx.org/), install PHP as an [FPM SAPI](https://secure.php.net/install.fpm).

Check notice on line 3 in cookbook/en/configuring-webservers/nginx.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/nginx.md#L3

[Microsoft.Acronyms] 'FPM' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'FPM' has no definition.", "location": {"path": "cookbook/en/configuring-webservers/nginx.md", "range": {"start": {"line": 3, "column": 61}}}, "severity": "INFO"}

Check notice on line 3 in cookbook/en/configuring-webservers/nginx.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/configuring-webservers/nginx.md#L3

[Microsoft.Acronyms] 'SAPI' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'SAPI' has no definition.", "location": {"path": "cookbook/en/configuring-webservers/nginx.md", "range": {"start": {"line": 3, "column": 65}}}, "severity": "INFO"}
Use the following Nginx configuration, replacing `path/to/app/public` with the actual path for
`app/public` and `mysite.test` with the actual hostname to serve.

```nginx
server {
charset utf-8;
client_max_body_size 128M;

listen 80; ## listen for ipv4
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6

server_name mysite.test;
root /path/to/app/public;
index index.php;

access_log /path/to/basic/log/access.log;
error_log /path/to/basic/log/error.log;

location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php$is_args$args;
}

# uncomment to avoid processing of calls to non-existing static files by Yii
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
# try_files $uri =404;
#}
#error_page 404 /404.html;

# deny accessing php files for the /assets directory
location ~ ^/assets/.*\.php$ {
deny all;
}

location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php8-fpm.sock;
try_files $uri =404;
}

location ~* /\. {
deny all;
}
}
```

When you use this configuration, also set `cgi.fix_pathinfo=0` in the `php.ini` file
to avoid many unnecessary system `stat()` calls.

Also, note that when running an HTTPS server, you need to add `fastcgi_param HTTPS on;` so that Yii
can detect if a connection is secure.
3 changes: 1 addition & 2 deletions cookbook/en/preface.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@

Yii is a high-performance, package-based PHP framework for developing modern applications.
The name Yii (pronounced `Yee` or `[ji:]`) means "simple and evolutionary" in Chinese.
You can also think about it as an acronym for **Yes It Is**!

Check failure on line 5 in cookbook/en/preface.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/preface.md#L5

[Microsoft.Contractions] Use 'it's' instead of 'It Is'.
Raw output
{"message": "[Microsoft.Contractions] Use 'it's' instead of 'It Is'.", "location": {"path": "cookbook/en/preface.md", "range": {"start": {"line": 5, "column": 53}}}, "severity": "ERROR"}

Yii is a generic Web programming framework.
You can use it for developing all kinds of Web applications using PHP.
Because of its architecture and sophisticated caching support,
it's especially suitable for developing large-scale applications such as portals, content management systems,
e-commerce, REST APIs, etc.

Check notice on line 11 in cookbook/en/preface.md

View workflow job for this annotation

GitHub Actions / vale

[vale] cookbook/en/preface.md#L11

[Microsoft.Acronyms] 'REST' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'REST' has no definition.", "location": {"path": "cookbook/en/preface.md", "range": {"start": {"line": 11, "column": 13}}}, "severity": "INFO"}

Together with a comprehensive set of documentation and an enthusiastic user community, Yii can reduce your development
time in a long run significantly.
With comprehensive documentation and an enthusiastic user community, Yii can significantly reduce your development time in the long run.

## What's the book about

Expand Down
2 changes: 1 addition & 1 deletion guide/en/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The definitive guide to Yii 3.0

This guide is released under the [Terms of Yii Documentation](https://www.yiiframework.com/license#docs).
We release this guide under the [Terms of Yii Documentation](https://www.yiiframework.com/license#docs).

Check warning on line 3 in guide/en/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] guide/en/README.md#L3

[Microsoft.We] Try to avoid using first-person plural like 'We'.
Raw output
{"message": "[Microsoft.We] Try to avoid using first-person plural like 'We'.", "location": {"path": "guide/en/README.md", "range": {"start": {"line": 3, "column": 1}}}, "severity": "WARNING"}

Introduction +
------------
Expand Down Expand Up @@ -46,7 +46,7 @@
Handling requests +
-----------------

* [Routing and URL generation](runtime/routing.md) +

Check warning on line 49 in guide/en/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] guide/en/README.md#L49

[Microsoft.GeneralURL] For a general audience, use 'address' rather than 'URL'.
Raw output
{"message": "[Microsoft.GeneralURL] For a general audience, use 'address' rather than 'URL'.", "location": {"path": "guide/en/README.md", "range": {"start": {"line": 49, "column": 16}}}, "severity": "WARNING"}
* [Request](runtime/request.md) +
* [Response](runtime/response.md) +
* [Sessions](runtime/sessions.md) +
Expand All @@ -71,7 +71,7 @@

* [Database access objects](db-dao.md): Connecting to a database, basic queries, transactions, and schema manipulation
* [Query builder](db-query-builder.md): Querying the database using a simple abstraction layer
* [Active record](db-active-record.md): The Active Record ORM, retrieving and manipulating records, and defining relations

Check notice on line 74 in guide/en/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] guide/en/README.md#L74

[Microsoft.Acronyms] 'ORM' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'ORM' has no definition.", "location": {"path": "guide/en/README.md", "range": {"start": {"line": 74, "column": 59}}}, "severity": "INFO"}
* [Migrations](databases/db-migrations.md): +

Getting data from users -
Expand Down Expand Up @@ -113,7 +113,7 @@
* [HTTP caching](caching/http.md) -


REST APIs -

Check warning on line 116 in guide/en/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] guide/en/README.md#L116

[Microsoft.HeadingAcronyms] Avoid using acronyms in a title or heading.
Raw output
{"message": "[Microsoft.HeadingAcronyms] Avoid using acronyms in a title or heading.", "location": {"path": "guide/en/README.md", "range": {"start": {"line": 116, "column": 1}}}, "severity": "WARNING"}

Check notice on line 116 in guide/en/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] guide/en/README.md#L116

[Microsoft.Acronyms] 'REST' has no definition.
Raw output
{"message": "[Microsoft.Acronyms] 'REST' has no definition.", "location": {"path": "guide/en/README.md", "range": {"start": {"line": 116, "column": 1}}}, "severity": "INFO"}

Check notice on line 116 in guide/en/README.md

View workflow job for this annotation

GitHub Actions / vale

[vale] guide/en/README.md#L116

[Microsoft.Headings] 'REST APIs -' should use sentence-style capitalization.
Raw output
{"message": "[Microsoft.Headings] 'REST APIs -' should use sentence-style capitalization.", "location": {"path": "guide/en/README.md", "range": {"start": {"line": 116, "column": 1}}}, "severity": "INFO"}
-----------

* [Quick start](rest/quick-start.md)
Expand Down
Loading
Loading