Skip to content

Instantly share code, notes, and snippets.

@JQL
Last active February 25, 2019 21:43

Revisions

  1. JQL revised this gist Feb 25, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions config.md
    Original file line number Diff line number Diff line change
    @@ -61,6 +61,7 @@ to $config = [
    add: ` 'name' => 'yii2Stuff', `

    to $config = [ 'components' => [

    uncomment:
    ```
    'urlManager' => [
  2. JQL created this gist Feb 25, 2019.
    147 changes: 147 additions & 0 deletions config.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,147 @@
    # 1. Virtual Host

    C:\xampp\apache\conf\extra\httpd-vhosts.conf
    ```
    <VirtualHost *:80>
    ##ServerAdmin webmaster@tutorial
    DocumentRoot c:/xampp/htdocs/tutorial
    ServerName tutorial
    ServerAlias tutorial.local
    </VirtualHost>
    ```
    C:\Windows\System32\drivers\etc\hosts
    ```
    127.0.0.1 tutorial
    127.0.0.1 tutorial.local
    ```
    # 2. PHPMyAdmin
    either:
    ```
    CREATE DATABASE IF NOT EXISTS `tutorial` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
    ```
    or
    Manually

    # 3. NetBeans

    ## a) Properties

    Project URL: ` http://tutorial/ `

    ## b) config
    ### db.php
    ```
    <?php
    return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=tutorial',
    'username' => 'root', // or your Username
    'password' => '', // enter your password if you have used one
    'charset' => 'utf8',
    // Schema cache options (for production environment)
    //'enableSchemaCache' => true,
    //'schemaCacheDuration' => 60,
    //'schemaCache' => 'cache',
    ];
    ```
    ### params.php
    ```
    <?php
    return [
    'adminEmail' => '[email protected]', // Your EMAIL address
    'supportEmail' => '[email protected]', // Your EMAIL address
    'user.passwordResetTokenExpire' => 3600,
    'company' => 'jlavelle.uk', // Your Company name or your name
    ];
    ```
    ### web.php
    to $config = [
    add: ` 'name' => 'yii2Stuff', `

    to $config = [ 'components' => [
    uncomment:
    ```
    'urlManager' => [
    'enablePrettyUrl' => true,
    'showScriptName' => false,
    'rules' => [
    ],
    ],
    ```
    ## c) .htaccess
    Required if you've configured PrettyUrls
    ```
    # Use UTF-8 encoding for anything served as `text/html` or `text/plain`.
    AddDefaultCharset utf-8
    Options +FollowSymLinks
    IndexIgnore */*
    RewriteEngine on
    # Force UTF-8 for certain file formats.
    <IfModule mod_mime.c>
    AddCharset utf-8 .atom .css .js .json .rss .vtt .webapp .xml
    </IfModule>
    # Block access to directories without a default document.
    # Usually you should leave this uncommented because you shouldn't allow anyone
    # to surf through every directory on your server (which may includes rather
    # private places like the CMS's directories).
    <IfModule mod_autoindex.c>
    Options -Indexes
    </IfModule>
    # prevent httpd from serving dotfiles (.htaccess, .svn, .git, etc.)
    RedirectMatch 403 /\..*$
    # Block access to hidden files and directories.
    # This includes directories used by version control systems such as Git and SVN.
    <IfModule mod_rewrite.c>
    RewriteCond %{SCRIPT_FILENAME} -d [OR]
    RewriteCond %{SCRIPT_FILENAME} -f
    RewriteRule "(^|/)\." - [F]
    </IfModule>
    # Used to create the "pretty URLs"
    <IfModule mod_rewrite.c>
    # if a directory or a file exists, use it directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # otherwise forward it to index.php
    # RewriteRule . index.php
    # RewriteRule ^(.*)\?*$ index.php/$1 [QSA] # for Pretty URLs plus Query Strings
    RewriteRule ^(.*)\?*$ index.php/$1
    </IfModule>
    # Block access to backup and source files.
    # These files may be left by some text editors and can pose a great security
    # danger when anyone has access to them.
    <FilesMatch "(^#.*#|\.(bak|config|dist|fla|inc|ini|jql|log|psd|sh|sql|sw[op])|~)$">
    Order allow,deny
    Deny from all
    Satisfy All
    </FilesMatch>
    # ------------------------------------------------------------------------------
    # | Content transformations |
    # ------------------------------------------------------------------------------
    # Prevent some of the mobile network providers from modifying the content of
    # your site: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.5.
    <IfModule mod_headers.c>
    Header set Cache-Control "no-transform"
    </IfModule>
    ```

    ## d) views/layout/main.php
    NavBar
    ```
    'brandLabel' => Yii::$app->name,
    ```
    Footer
    ```
    <p class="pull-left">&copy;<?= date('Y') . ' ' . Yii::$app->params['company'] ?></p>
    ```