how to fix Deprecation Notice: Composer\Package\Version\VersionParser::parseLinks is deprecated. Use \Composer\Package\Loader\ArrayLoader::parseLinks() instead in phar:///usr/local/bin/composer/src/Composer/Package/Version/VersionParser.php:226

If you are using linux then under your home directory

/root/ or /home/username

mv .composer .composerBackup

run composer and warning should not display again

How to enable mcrypt for developing with Yii2

If you use mcrypt you need to install the following package on linux debian to enable mcrypt.

The easiest way is to install:

apt-get install php5-mcrypt

then restart apache2

service apache2 restart

then your Yii2 framework should not longer be complaining about missing mcrypt package.

If this does not work then sometimes you will need to run the following

php5enmod mcrypt

Yii 2.0 Linux MSSQL setup – could not find driver (Could not connect to a database)

My setup:

Debian

MSSQL Express 2014

Yii 2.0

To get a connection to a database working i had to do the following:

in my /config/db.php

We are using dblib as this works on Linux 

More info here regards the DSN

http://www.yiiframework.com/doc-2.0/guide-db-dao.html (It would be nice if they would let us know that not all drivers works on Linux:)

return [
‘class’ => ‘yii\db\Connection’,
‘dsn’ => ‘dblib:host=xx;dbname=xx’,
‘username’ => ‘xx’,
‘password’ => ‘xx!’,
‘charset’ => ‘utf8’,

then install

apt-get install php5-sybase

service apache2 restart and try again.

I have also installed the following:

apt-get install php5-sqlite

apt-get install php5-odbc

Hope this helps someone!

How to make Yii Application Secure to work only on HTTPS

I am using Yii 2.0, Apache and Debian. This howto take into assumption that you arleady have SSL certificate set up

on your machine.

First we create your apache configuration for your site. Replace xx.xx with your site. In this example I am using domain without www in the front of it.

In your apache conf site configuration add:

In /etc/apache2/site-enabled/mysite.conf

Redirect any traffic from 80 to https

1 <Virtualhost xx.xx.com:80>
2 ServerName xx.xx.com
3 Redirect “/” “https://xx.xx.com&#8221;
4 </Virtualhost>

Create your site https configuration and connect it with SSL certificate
6 <VirtualHost xx.xx.com:443>
7 ServerAdmin xx@xx.com
8 DocumentRoot “/var/www/yourSite/web”
9 ServerName xx.xx.com
10 ServerAlias *.xx.xx.com
11 SSLEngine On
12 SSLCertificateFile /etc/ssl/certs/xx.crt
13 SSLCertificateKeyFile /etc/ssl/private/xx.key
14 </VirtualHost>

restart apache service apache2 restart

In your site directory create .htaccess

touch .htaccess then edit vi .htaccess

then paste the following: (

RewriteEngine On
# prevent httpd from serving dotfiles (.htaccess, .svn, .git, etc.)
RedirectMatch 403 /\..*$
# 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
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

This configuration will allow only https access to your site and all the links will work if you generate them using Url class

<p><a class=”btn btn-lg btn-success” href=”<?php echo Url::to([‘login’]) ?>”>Click here to Login</a></p>

Hope this will work for you the same as it work for me.