Beruflich Dokumente
Kultur Dokumente
You can install Yii in two ways, using the Composer package manager or by downloading an archive
file. The former is the preferred way, as it allows you to install new extensions or update Yii by simply
running a single command.
Standard installations of Yii result in both the framework and a project template being downloaded
and installed. A project template is a working Yii project implementing some basic features, such as
login, contact form, etc. Its code is organized in a recommended way. Therefore, it can serve as a
good starting point for your projects.
In this and the next few sections, we will describe how to install Yii with the so-called Basic Project
Template and how to implement new features on top of this template. Yii also provides another
template called the Advanced Project Templatewhich is better used in a team development
environment to develop applications with multiple tiers.
Info: The Basic Project Template is suitable for developing 90 percent of Web applications. It differs
from the Advanced Project Template mainly in how their code is organized. If you are new to Yii, we
strongly recommend you stick to the Basic Project Template for its simplicity yet sufficient
functionalities.
Installing Assets
Yii relies on Bower and/or NPM packages for the asset (CSS and JavaScript) libraries installation. It
uses Composer to obtain these libraries, allowing PHP and CSS/JavaScript package versions to
resolve at the same time. This can be achieved either by usage of asset-packagist.org or composer
asset plugin. Please refer to Assets documentation for more details.
You may want to either manage your assets via native Bower/NPM client, use CDN or avoid assets
installation entirely. In order to prevent assets installation via Composer, add the following lines to
your 'composer.json':
"replace": {
"bower-asset/jquery": ">=1.11.0",
"bower-asset/inputmask": ">=3.2.0",
"bower-asset/punycode": ">=1.3.0",
"bower-asset/yii2-pjax": ">=2.0.0"
},
Note: in case of bypassing asset installation via Composer, you are responsible for the assets
installation and resolving version collisions. Be prepared for possible inconsistencies among asset
files from different extensions.
<Directory "path/to/basic/web">
# use mod_rewrite for pretty URL support
RewriteEngine on
# 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>
server_name mysite.test;
root /path/to/basic/web;
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;
}
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/php5-fpm.sock;
try_files $uri =404;
}
location ~* /\. {
deny all;
}
}
When using this configuration, you should also set cgi.fix_pathinfo=0 in the php.ini file in order
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 properly detect if a connection is secure.
Download
Yii Framework & Offline Documentation
Yii is an open source project released under the terms of the BSD License. This means that you can
use Yii for free to develop either open-source or proprietary Web applications.
There are two ways to install Yii: by using Composer or by downloading an application template. We
highly recommend you to use Composer.
If you do not have Composer installed yet, you may install it following the instructions on
the Composer website.
Yii 2.0
Latest release is 2.0.15 (March 20, 2018)
Changes in this and older versions
Upgrade instructions
List of all Yii 2.x releases
The best way to get started with the basic application template is to follow the introduction in the
definitive guide.
To install the advanced application template, run the following command:
php composer.phar create-project yiisoft/yii2-app-advanced advanced
When you have installed the advanced application template, you should check out
its documentation to learn how to use it.
When upgrading Yii there might be changes that require adjustment in you application code, so you
should always check the UPGRADE notes. These also contain more detailed instructions on how to
upgrade Yii with composer.
If you installed Yii using an archive file, you can either follow the progress described above using
Composer, or download a new release file and replace the contents of the vendor/ directory in your
application with the files from the new archive file.
Upgrading from Yii 1.1 is not trivial and requires rewriting a great part of your application code. Please
refer to the guide about upgrading from Yii 1.1 for more details.