- Installation ¶
- Installing using Composer ¶
- Install from an Archive File ¶
- Preparing application ¶
- Installing using Vagrant ¶
- Manual for Linux/Unix users ¶
- Manual for Windows users ¶
- Installing using Docker ¶
- Download
- Yii 2.0
- Install via Composer (recommended)
- Install from an Archive File
- Upgrade from Older Versions
- Offline Documentation
- Yii 1.1
- Documentation
- Archive
Installation ¶
The minimum requirement by this project template is that your Web server supports PHP 5.6.0.
Installing using Composer ¶
If you do not have Composer, follow the instructions in the Installing Yii section of the definitive guide to install it.
With Composer installed, you can then install the application using the following commands:
composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application
The command installs the advanced application in a directory named yii-application . You can choose a different directory name if you want.
It uses asset-packagist for managing bower and npm package dependencies through Composer. Also you can use asset-plugin, as in earlier versions, but it works slowly.
Install from an Archive File ¶
Extract the archive file downloaded from yiiframework.com to a directory named advanced that is directly under the Web root.
Then follow the instructions given in the next subsection.
Preparing application ¶
After you install the application, you have to conduct the following steps to initialize the installed application. You only need to do these once for all.
- Open a console terminal, execute the init command and select dev as environment.
/path/to/php-bin/php /path/to/yii-application/init
/path/to/php-bin/php /path/to/yii-application/init --env=Development --overwrite=All --delete=All
- for frontend /path/to/yii-application/frontend/web/ and using the URL http://frontend.test/
- for backend /path/to/yii-application/backend/web/ and using the URL http://backend.test/
For Apache it could be the following:
ServerName frontend.test DocumentRoot "/path/to/yii-application/frontend/web/" # use mod_rewrite for pretty URL support RewriteEngine on # If a directory or a file exists, use the request directly RewriteCond % !-f RewriteCond % !-d # Otherwise forward the request to index.php RewriteRule . index.php # use index.php as index file DirectoryIndex index.php # . other settings. # Apache 2.4 Require all granted ## Apache 2.2 # Order allow,deny # Allow from all ServerName backend.test DocumentRoot "/path/to/yii-application/backend/web/" # use mod_rewrite for pretty URL support RewriteEngine on # If a directory or a file exists, use the request directly RewriteCond % !-f RewriteCond % !-d # Otherwise forward the request to index.php RewriteRule . index.php # use index.php as index file DirectoryIndex index.php # . other settings. # Apache 2.4 Require all granted ## Apache 2.2 # Order allow,deny # Allow from all
server < charset utf-8; client_max_body_size 128M; listen 80; ## listen for ipv4 #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 server_name frontend.test; root /path/to/yii-application/frontend/web/; index index.php; access_log /path/to/yii-application/log/frontend-access.log; error_log /path/to/yii-application/log/frontend-error.log; location / < # Redirect everything that isn't a real file to index.php try_files $uri $uri/ /index.php$is_args$args; > # uncomment to avoid processing of calls to non-existing static files by Yii #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ # try_files $uri =404; #> #error_page 404 /404.html; # deny accessing php files for the /assets directory location ~ ^/assets/.*\.php$ < deny all; > 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; > > server < charset utf-8; client_max_body_size 128M; listen 80; ## listen for ipv4 #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 server_name backend.test; root /path/to/yii-application/backend/web/; index index.php; access_log /path/to/yii-application/log/backend-access.log; error_log /path/to/yii-application/log/backend-error.log; location / < # Redirect everything that isn't a real file to index.php try_files $uri $uri/ /index.php$is_args$args; > # uncomment to avoid processing of calls to non-existing static files by Yii #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ # try_files $uri =404; #> #error_page 404 /404.html; # deny accessing php files for the /assets directory location ~ ^/assets/.*\.php$ < deny all; > 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; > >
127.0.0.1 frontend.test 127.0.0.1 backend.test
Thank you for registration. Please check your inbox for verification email.
- delete soft line breaks ‘=’ and newlines to create a single line with the line below
- change ‘=3D’ to ‘=’
- On Mac / Linux, convert \r\n to \n — MIME CRLF line breaks are «real» and should be preserved.
Paste this URL into a browser tab to complete the User creation. You will be presented with the message: Your email has been confirmed!
Note: if you want to run advanced template on a single domain so / is frontend and /admin is backend, refer to Using advanced project template at shared hosting.
Installing using Vagrant ¶
This way is the easiest but long (~20 min).
This installation way doesn’t require pre-installed software (such as web-server, PHP, MySQL etc.) — just do next steps!
Manual for Linux/Unix users ¶
git clone https://github.com/yiisoft/yii2-app-advanced.git cd yii2-app-advanced/vagrant/config cp vagrant-local.example.yml vagrant-local.yml
That’s all. You just need to wait for completion! After that you can access project locally by URLs:
Manual for Windows users ¶
- Install VirtualBox
- Install Vagrant
- Reboot
- Create GitHub personal API token
- Prepare project:
- download repo yii2-app-advanced
- unzip it
- go into directory yii2-app-advanced-master/vagrant/config
- copy vagrant-local.example.yml to vagrant-local.yml
- Place your GitHub personal API token to vagrant-local.yml
- Open terminal ( cmd.exe ), change directory to project root and run command:
That’s all. You just need to wait for completion! After that you can access project locally by URLs:
Installing using Docker ¶
Install the application dependencies
docker-compose run --rm backend composer install
Initialize the application by running the init command within a container
docker-compose run --rm backend php /app/init
Adjust the components[‘db’] configuration in common/config/main-local.php accordingly.
'dsn' => 'mysql:host=mysql;dbname=yii2advanced', 'username' => 'yii2advanced', 'password' => 'secret',
Docker networking creates a DNS entry for the host mysql available from your backend and frontend containers.
If you want to use another database, such a Postgres, uncomment the corresponding section in docker-compose.yml and update your database connection.
'dsn' => 'pgsql:host=pgsql;dbname=yii2advanced',
For more information about Docker setup please visit the guide.
docker-compose run --rm backend yii migrate
Access it in your browser by opening
Download
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.48 (May 22, 2023)
- Changes in this and older versions
- Upgrade instructions
- List of all Yii 2.x releases
Install via Composer (recommended)
The installation instructions described here are a short summary, you may want to check the Definitive Guide for more detailed instructions.
Choose one of the application templates to start installing Yii 2.0. An application template is a package that contains a skeleton Web application written in Yii which you can start building your application from. If you just start with Yii, we recommend the installation of the basic template.
To install the basic application template, run the following command:
php composer.phar create-project yiisoft/yii2-app-basic basic
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.
Install from an Archive File
Download one of the following archive files, and then extract it to Web-accessible folder:
Afterwards you may want to follow the introduction in the definitive guide to get started, or check out the documentation of the advanced application template to learn how to use it.
Upgrade from Older Versions
If you are upgrading from Yii 2.0.x with Composer, simply run the following commands in your project’s root directory:
php composer.phar update yiisoft/yii2 yiisoft/yii2-composer bower-asset/jquery.inputmask
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.
Offline Documentation
The Definitive Guide to Yii 2.0 and the API Documentation are available for offline browsing. Below you will find the download packages including the HTML files of Guide and API Documentation as well as links to the PDF versions of the Guide in different languages.
العربية .tar.gz — .tar.bz2
English PDF — .tar.gz — .tar.bz2
Español PDF — .tar.gz — .tar.bz2
Français PDF — .tar.gz — .tar.bz2
Bahasa Indonesia PDF — .tar.gz — .tar.bz2
日本語 PDF — .tar.gz — .tar.bz2
Polski PDF — .tar.gz — .tar.bz2
Português brasileiro PDF — .tar.gz — .tar.bz2
Русский PDF — .tar.gz — .tar.bz2
Українська .tar.gz — .tar.bz2
Oʻzbekcha .tar.gz — .tar.bz2
简体中文 PDF — .tar.gz — .tar.bz2
Tiếng Việt .tar.gz — .tar.bz2
Yii 1.1
Continued support and bug fixes for this version have been provided until December 31, 2016 .
Security fixes and compatibility for PHP 7 and PHP 8 until December 31, 2026 .
- Latest release is 1.1.28 (February 28, 2023)
- Source Code (.zip)
- Changes in this and older versions
- Upgrade instructions
- Offline Documentation (.zip)
- List of all Yii 1.x releases
You may obtain the latest development version of the Yii 1.1 code from the Github repository using git:
git clone git@github.com:yiisoft/yii.git yii
svn checkout https://github.com/yiisoft/yii/trunk/ yii
The yiisoft/yii composer package is available as well.
Documentation
Archive
If you are looking for Yii 1.0 and other really old resources, you may find them at the museum.