Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
systems:yii2:setup_and_configuration [2018/04/19 06:41] smayr [Yii 2 Setup and Configuration] |
systems:yii2:setup_and_configuration [2020/05/20 16:22] (current) ajdavis [Upgrade Yii] |
||
---|---|---|---|
Line 121: | Line 121: | ||
</ | </ | ||
- | Rename '' | + | Yii2 expects Bower and NPM packages to be installed to vendor/bower and vendor/npm folders respectively. So, to use asset-packagist it's necessary to add aliases in web.php: |
<code php> | <code php> | ||
- | //... | + | $config = [ |
- | public function setVendorPath($path) | + | |
- | { | + | 'aliases' |
- | | + | ' |
- | Yii:: | + | ' |
- | | + | ], |
- | | + | ... |
- | } | + | ]; |
</ | </ | ||
== Initial Configuration == | == Initial Configuration == | ||
Line 144: | Line 145: | ||
* '' | * '' | ||
* '' | * '' | ||
+ | |||
+ | The local versions would be empty, but you can add parameters to override the respective settings: | ||
+ | <code php> | ||
+ | <?php | ||
+ | return [ | ||
+ | ]; | ||
+ | </ | ||
For basic app only: Edit the following to support local copies. | For basic app only: Edit the following to support local copies. | ||
Line 190: | Line 198: | ||
</ | </ | ||
+ | ==== Database Config ==== | ||
Edit the following configuration files. | Edit the following configuration files. | ||
Line 204: | Line 213: | ||
</ | </ | ||
+ | ==== Params Config ==== | ||
''/ | ''/ | ||
<code php> | <code php> | ||
return [ | return [ | ||
+ | ' | ||
' | ' | ||
' | ' | ||
Line 225: | Line 236: | ||
' | ' | ||
' | ' | ||
- | ' | + | ' |
+ | //' | ||
+ | ' | ||
' | ' | ||
' | ' | ||
Line 231: | Line 244: | ||
' | ' | ||
' | ' | ||
+ | | ||
+ | // | ||
+ | // Site Message of the Day (MOTD) | ||
+ | // | ||
+ | // --- Hurricane mesg --- | ||
+ | //' | ||
+ | // < | ||
+ | // the office will be closed | ||
+ | // <div class=" | ||
+ | // < | ||
+ | // Nuestras disculpas por este inconveniente.</ | ||
+ | // --- Phone Line Down message --- | ||
+ | //' | ||
+ | // to a nationwide phone provider outage. | ||
+ | // --- Memorial Day message --- | ||
+ | //' | ||
+ | // closed in observance of the Memorial Day holiday. We will resume normal hours on Monday. ', | ||
+ | // --- US Independence/ | ||
+ | //' | ||
+ | // will be closed July 4, in observance of the US Independence Day holiday. | ||
+ | // We will resume normal hours on July 5. ', | ||
+ | // --- Labor Day message --- | ||
+ | //' | ||
+ | // | ||
+ | // --- Thanksgiving message --- | ||
+ | //' | ||
+ | // Thanksgiving Day holiday, the office will be closed. | ||
+ | // Debido a la celebración del Día de Acción de Gracias, la oficina estará cerrada. | ||
+ | // Nuestras disculpas por cualquier molestia.', | ||
+ | // --- Xmas/ | ||
+ | //' | ||
+ | // Our offices will be closed December 25, and January 1, in observance of the Christmas | ||
+ | // and New Year holidays. We will resume normal hours the next day. Happy Holidays!', | ||
+ | // --- NewYear message --- | ||
+ | //' | ||
+ | // closed January 1, in observance of the New Year holidays. We will resume normal hours | ||
+ | // the next day. Happy Holidays!', | ||
+ | | ||
+ | // Test Site | ||
+ | //' | ||
+ | | ||
+ | // --- MOTD Date Range (comment lines to display permanently) --- | ||
+ | //' | ||
+ | //' | ||
]; | ]; | ||
</ | </ | ||
+ | ==== Main/Web Config ==== | ||
''/ | ''/ | ||
<code php> | <code php> | ||
Line 247: | Line 305: | ||
// Preferably, add to local config: | // Preferably, add to local config: | ||
// $config[' | // $config[' | ||
- | ' | + | ' |
| | ||
// Use a custom name per app for csrf cookie to avoid clashes with other Yii apps | // Use a custom name per app for csrf cookie to avoid clashes with other Yii apps | ||
- | ' | + | ' |
' | ' | ||
' | ' | ||
Line 276: | Line 334: | ||
' | ' | ||
' | ' | ||
- | ' | + | ' |
//' | //' | ||
], | ], | ||
], | ], | ||
' | ' | ||
- | ' | + | ' |
' | ' | ||
], | ], | ||
Line 315: | Line 373: | ||
</ | </ | ||
+ | ==== htaccess File ==== | ||
<WRAP round tip> | <WRAP round tip> | ||
For '' | For '' | ||
Line 325: | Line 384: | ||
# use mod_rewrite for pretty URL support | # use mod_rewrite for pretty URL support | ||
RewriteEngine on | RewriteEngine on | ||
+ | |||
+ | # HTTPS redirect for pages users input sensitive data (eg. password) | ||
+ | # NOTE: Disable these in localhost or other server without HTTPS. | ||
+ | # | ||
+ | # | ||
+ | # | ||
# If a directory or a file exists, use the request directly | # If a directory or a file exists, use the request directly | ||
Line 334: | Line 399: | ||
</ | </ | ||
+ | ==== System Variables ==== | ||
Setup application name in '' | Setup application name in '' | ||
<code php> | <code php> | ||
Line 342: | Line 408: | ||
</ | </ | ||
+ | ==== Debugging ==== | ||
Yii2-debug module needs permission to trace and log in case application is installed on a server other than '' | Yii2-debug module needs permission to trace and log in case application is installed on a server other than '' | ||
<code php> | <code php> | ||
Line 378: | Line 445: | ||
Main template: Edit ''/ | Main template: Edit ''/ | ||
<code php> | <code php> | ||
+ | < | ||
+ | ... | ||
+ | <link rel=" | ||
+ | </ | ||
... | ... | ||
<?php | <?php | ||
Line 548: | Line 619: | ||
' | ' | ||
// Use a custom name per app for csrf cookie to avoid clashes with other Yii apps | // Use a custom name per app for csrf cookie to avoid clashes with other Yii apps | ||
- | ' | + | ' |
' | ' | ||
' | ' | ||
Line 643: | Line 714: | ||
* Backend: http:// | * Backend: http:// | ||
- | == Rewrite Base URL / | + | == Rewrite Base URL (/basic/web or / |
References: | References: | ||
- | * [[http:// | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
Line 651: | Line 721: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// | ||
* [[http:// | * [[http:// | ||
* [[https:// | * [[https:// | ||
* [[http:// | * [[http:// | ||
+ | |||
=== Basic App === | === Basic App === | ||
Create '' | Create '' | ||
Line 673: | Line 745: | ||
RewriteCond %{REQUEST_FILENAME} !-f | RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | RewriteCond %{REQUEST_FILENAME} !-d | ||
- | RewriteRule . / | + | |
+ | RewriteRule . index.php | ||
</ | </ | ||
Line 684: | Line 757: | ||
# Deny accessing dot files | # Deny accessing dot files | ||
RewriteRule (^\.|/\.) - [F] | RewriteRule (^\.|/\.) - [F] | ||
- | |||
</ | </ | ||
Line 698: | Line 770: | ||
</ | </ | ||
- | Edit '' | + | Hide the '' |
<code php> | <code php> | ||
<?php | <?php | ||
Line 705: | Line 777: | ||
use \yii\web\Request; | use \yii\web\Request; | ||
- | // Use current location | + | // Set current location |
- | // The Rewrite | + | // Mod_Rewrite |
$baseUrl = str_replace('/ | $baseUrl = str_replace('/ | ||
return [ | return [ | ||
- | | + | |
- | | + | |
' | ' | ||
- | // Define request. Must have a baseUrl specified | ||
' | ' | ||
- | ' | + | |
+ | // Required if wanting to hide ' | ||
+ | | ||
+ | |||
+ | //... | ||
], | ], | ||
- | // Define | + | // Activate |
' | ' | ||
' | ' | ||
Line 726: | Line 800: | ||
], | ], | ||
- | ... | + | |
], | ], | ||
' | ' | ||
Line 867: | Line 941: | ||
' | ' | ||
' | ' | ||
- | ' | + | ' |
//' | //' | ||
] | ] | ||
], | ], | ||
' | ' | ||
- | ' | + | ' |
' | ' | ||
], | ], | ||
Line 889: | Line 963: | ||
' | ' | ||
' | ' | ||
- | ' | + | ' |
//' | //' | ||
] | ] | ||
], | ], | ||
' | ' | ||
- | ' | + | ' |
' | ' | ||
], | ], |