PHP code example of infoweb-internet-solutions / yii2-cms

1. Go to this page and download the library: Download infoweb-internet-solutions/yii2-cms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

infoweb-internet-solutions / yii2-cms example snippets


'controllerMap' => [
	'migrate' => [
		'class' => 'fishvision\migrate\controllers\MigrateController',
		'autoDiscover' => true,
		'migrationPaths' => [
			'@vendor'
		],
	],
],  

"    ...
    "fishvision/yii2-migrate": "*",
    "infoweb-internet-solutions/yii2-cms": "*"
]

...
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/infoweb-internet-solutions/yii2-i18n-module"
    },
    {
        "type": "vcs",
        "url": "https://github.com/infoweb-internet-solutions/yii2-ckeditor"
    }
]
...

...
"extra": {
    ...
    "asset-pattern-skip-version": "(-patch)"
}


use \kartik\datecontrol\Module;

return [
	...
    'name' => 'My Application',
    'language' => 'nl',
    'timeZone' => 'Europe/Brussels',
    ...
    'components' => [
        ...
        'cache' => [
            'class' => 'yii\caching\DbCache',
        ],
        'authManager' => [
            'class' => 'yii\rbac\DbManager',
        ],
        // Rewrite url's
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName'  => false,
        ],
        // Formatter
        'formatter' => [
            'dateFormat' => 'php:d-m-Y',
            'decimalSeparator' => ',',
            'thousandSeparator' => ' ',
            'currencyCode' => 'EUR',
        ],
        // Override views
        'view' => [
            'theme' => [
                'pathMap' => [
                    '@dektrium/user/views' => '@infoweb/user/views'
                ],
            ],
        ],
      	'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@infoweb/cms/mail',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => false,
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'host',
                'username' => 'user',
                'password' => 'password',
                'port' => 'port'
            ],
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
                [
                    'class' => 'yii\log\DbTarget',
                    'levels' => ['error'],
                ],
                [
                    'class' => 'yii\log\EmailTarget',
                    'levels' => ['error'],
                    'categories' => ['yii\db\*'],
                    'message' => [
                       'from' => ['[email protected]'],
                       'to' => ['[email protected]'],
                       'subject' => '[MySQL error @ domain.com]',
                    ],
                ],
            ],
        ],
		'i18n' => [
			'class' => Zelenin\yii\modules\I18n\components\I18N::className(),
			'languages' => ['nl']
		],
    ],
    ...
    'modules' => [
        'datecontrol' =>  [
            'class' => 'kartik\datecontrol\Module',

            // format settings for displaying each date attribute (ICU format example)
            'displaySettings' => [
                Module::FORMAT_DATE => 'php:d-m-Y',
                Module::FORMAT_TIME => 'php:H:i',
                Module::FORMAT_DATETIME => 'dd-MM-yyyy HH:mm:ss',
            ],

            // format settings for saving each date attribute (PHP format example)
            'saveSettings' => [
                Module::FORMAT_DATE => 'php:U', // saves as unix timestamp
                Module::FORMAT_TIME => 'php:H:i:s',
                Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s',
            ],

            // set your display timezone
            'displayTimezone' => 'Europe/Brussels',

            // set your timezone for date saved to db
            'saveTimezone' => 'Europe/Brussels',

            // automatically use kartik\widgets for each of the above formats
            'autoWidget' => true,

            // default settings for each widget from kartik\widgets used when autoWidget is true
            'autoWidgetSettings' => [
                Module::FORMAT_DATE => ['pluginOptions' => [
                    'autoclose' => true,
                    'todayHighlight' => true,
                    //'todayBtn' => true
                ]],
                Module::FORMAT_DATETIME => [], // setup if needed
                Module::FORMAT_TIME => [], // setup if needed
            ],
            // Use custom convert action
            'convertAction' => '/cms/parse/convert-date-control'
        ],
		'yii2images' => [
			'class' => 'rico\yii2images\Module',
			'imagesStorePath' => '@uploadsBasePath/img', //path to origin images
			'imagesCachePath' => '@uploadsBasePath/img/cache', //path to resized copies
			'graphicsLibrary' => 'GD', //but really its better to use 'Imagick'
			'placeHolderPath' => '@infoweb/cms/assets/img/transparent-placeholder.png',
		],
    ],
    ...
    'params' => [
        // Font Awesome Icon framework
        'icon-framework' => 'fa',
    ],
];

return [
    ...
	'name' => 'My application',
	...
    'bootstrap' => ['log','cms'],
    ...
    'modules' => [
    	...
        'cms' => [
            'class' => 'infoweb\cms\Module',
        ],
       	'gridview' =>  [
            'class' => '\kartik\grid\Module'
        ],
  	    'media' => [
            'class' => 'infoweb\cms\Module',
        ],
		'email' => [
            'class' => 'infoweb\email\Module'
        ],
		'admin' => [
			'class' => 'mdm\admin\Module',
		],
		'i18n' => [
            'class' => Zelenin\yii\modules\I18n\Module::className(),
        ],
		'settings' => [
            'class' => 'infoweb\settings\Module'
        ],
		'pages' => [
			'class' => 'infoweb\pages\Module',
        ],
		'partials' => [
			'class' => 'infoweb\partials\Module',
		],
		'seo' => [
			'class' => 'infoweb\seo\Module',
		],
		'menu' => [
            'class' => 'infoweb\menu\Module',
        ],
		'alias' => [
			'class' => 'infoweb\alias\Module',
			'reservedUrls' => ['page'] // Url's that are reserved by the application
		],
    ],
    ...
    'components' => [
        ...
        'view' => [
            'theme' => [
                'pathMap' => [
                    '@app/views/layouts' => '@infoweb/cms/views/layouts',
                    '@dektrium/user/views' => '@infoweb/user/views'
                ],
            ],
        ],
		'request' => [
            'class' => 'common\components\Request',
            'web'=> '/backend/web',
            'adminUrl' => '/admin'
        ],
    ],
    ...
];

return [
    ...
    // Moximanager settings
    'moxiemanager'  => [
        'license-key'   => 'your-moxiemanager-key'
    ],
    ...
]

return [
    ...
    // Enabled languages
    'languages' => [
        'nl'    => 'Nederlands',
        'fr'    => 'Français',
        'en'    => 'English',
    ],
    'companyName'   => 'YourCompany'
    ...
];

return [
    ...
    'components' => [
		'user' => [
            'identityClass' => 'infoweb\user\models\frontend\User',
            'enableAutoLogin' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'request'=>[
            'class' => 'common\components\Request',
            'web' => '/frontend/web',
            'csrfParam' => '_frontendCSRF',
        ],
        // Override the urlManager component
        'urlManager' => [
            'class' => 'codemix\localeurls\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '404'               => 'site/error',
                '<alias:[\d\w\-]+>' => 'site/index',
            ],
        ],
        'page' => [
            'class' => 'infoweb\pages\components\Page'
        ]
    ],
	...
];

...
// System aliases
Yii::setAlias('baseUrl', 'http://' . ((isset($_SERVER['HTTP_HOST'])) ? $_SERVER['HTTP_HOST'] : '') . ((YII_ENV_DEV) ? '/directory-in-your-localhost' : '')); <-- Change your path
Yii::setAlias('basePath', dirname(dirname(__DIR__)));
Yii::setAlias('uploadsBaseUrl', Yii::getAlias('@baseUrl') . '/frontend/web/uploads');
Yii::setAlias('uploadsBasePath', Yii::getAlias('@basePath') . '/frontend/web/uploads');
Yii::setAlias('frontendUrl', Yii::getAlias('@baseUrl') . '/frontend/web');
...

'controllerMap' => [
	'migrate' => [
		'class' => 'fishvision\migrate\controllers\MigrateController',
		'autoDiscover' => true,
		'migrationPaths' => [
			'@vendor'
		],
	],
],


namespace common\components;

/**
 * This extension of the Request component can be used to replace parts of the 
 * requested url.
 * 
 * It has to be enabled in the 'components' area of the main configuration files
 * for the front- and backend:
 * 
 * eg: If you want to replace '/frontend/web' from the url's, put this in
 *     frontend/config.main.php in the 'components' section.
 * 
 *      'request'=>[
 *          'class' => 'common\components\Request',
 *          'web'=> '/frontend/web'
 *      ]
 * 
 *
 */
class Request extends \yii\web\Request
{
    public $web;
    public $adminUrl;

    /**
     * Takes the base url from the parent class and replaces the 'web' url that
     * you defined with an empty string:
     * 
     *  eg: the 'web' url is set to 'frontend/web'
     *      www.mydomain.com/frontend/web becomes www.mydomain.com/
     * 
     * @return  string
     */
    public function getBaseUrl()
    {
        return str_replace($this->web, '', parent::getBaseUrl()) . $this->adminUrl;
    }


    /**
     * This function ensures that www.mydomain.com/admin (without trailing slash) will not
     * throw a 404 error
     * 
     * @return  string
     */
    public function resolvePathInfo()
    {
        if ($this->getUrl() === $this->adminUrl) {
            return '';
        } else {
            return parent::resolvePathInfo();
        }
    }
}

'modules' => [
    'user' => [
        'class' => 'dektrium\user\Module',
        'modelMap' => [
            'User' => 'infoweb\user\models\User',
        ],
    ],
],
bash
php composer.phar global ject --prefer-dist --stability=dev yiisoft/yii2-app-advanced advanced

# Yii files
README.md
LICENSE.md