X

Installation of Yii 2 Advanced Project Template on Xampp Windows 10 - Complete Guide

/

Requirements

The minimum requirement by this project template is that your Web server supports PHP 5.4.0.

Step 1: Installing using Composer

composer global require "fxp/composer-asset-plugin:~1.1.1"composer create-project --prefer-dist yiisoft/yii2-app-advanced first-project


Step 2: The Above 2 Commands will download Yii2 in the Folder "first-project" and will show the following in Putty CLI.

Creating a "yiisoft/yii2-app-advanced" project at "./first-project"Installing yiisoft/yii2-app-advanced (2.0.38)- Installing yiisoft/yii2-app-advanced (2.0.38): Downloading (100%)Created project in F:first-projectLoading composer repositories with package informationUpdating dependencies (including require-dev)Package operations: 85 installs, 0 updates, 0 removals- Installing yiisoft/yii2-composer (2.0.10): Loading from cache- Installing sebastian/diff (3.0.2): Loading from cache- Installing sebastian/recursion-context (3.0.0): Loading from cache- Installing sebastian/exporter (3.1.2): Loading from cache- Installing sebastian/comparator (3.0.2): Loading from cache- Installing theseer/tokenizer (1.2.0): Loading from cache- Installing sebastian/version (2.0.1): Loading from cache- Installing sebastian/environment (4.2.3): Loading from cache- Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache- Installing phpunit/php-text-template (1.2.1): Loading from cache- Installing phpunit/php-token-stream (3.1.1): Loading from cache- Installing phpunit/php-file-iterator (2.0.2): Loading from cache- Installing phpunit/php-code-coverage (7.0.10): Loading from cache- Installing sebastian/type (1.1.3): Loading from cache- Installing sebastian/resource-operations (2.0.1): Loading from cache- Installing sebastian/object-reflector (1.1.1): Loading from cache- Installing sebastian/object-enumerator (3.0.3): Loading from cache- Installing sebastian/global-state (3.0.0): Loading from cache- Installing phpunit/php-timer (2.1.2): Loading from cache- Installing doctrine/instantiator (1.3.1): Loading from cache- Installing phpdocumentor/reflection-common (2.2.0): Loading from cache- Installing symfony/polyfill-ctype (v1.18.1): Loading from cache- Installing webmozart/assert (1.9.1): Loading from cache- Installing phpdocumentor/type-resolver (1.4.0): Loading from cache- Installing phpdocumentor/reflection-docblock (5.2.2): Loading from cache- Installing phpspec/prophecy (1.11.1): Loading from cache- Installing phar-io/version (2.0.1): Loading from cache- Installing phar-io/manifest (1.0.3): Loading from cache- Installing myclabs/deep-copy (1.10.1): Loading from cache- Installing phpunit/phpunit (8.5.8): Loading from cache- Installing codeception/phpunit-wrapper (8.1.2): Loading from cache- Installing codeception/verify (1.1.0): Loading from cache- Installing bower-asset/jquery (3.5.1): Loading from cache- Installing bower-asset/bootstrap (v3.4.1): Loading from cache- Installing bower-asset/yii2-pjax (2.0.7.1): Loading from cache- Installing bower-asset/punycode (v1.3.2): Loading from cache- Installing bower-asset/inputmask (3.3.11): Loading from cache- Installing cebe/markdown (1.2.1): Loading from cache- Installing ezyang/htmlpurifier (v4.13.0): Loading from cache- Installing yiisoft/yii2 (2.0.38): Loading from cache- Installing yiisoft/yii2-bootstrap (2.0.10): Loading from cache- Installing symfony/polyfill-php72 (v1.18.1): Loading from cache- Installing paragonie/random_compat (v9.99.99): Loading from cache- Installing symfony/polyfill-php70 (v1.18.1): Loading from cache- Installing symfony/polyfill-intl-normalizer (v1.18.1): Loading from cache- Installing symfony/polyfill-intl-idn (v1.18.1): Loading from cache- Installing symfony/polyfill-mbstring (v1.18.1): Loading from cache- Installing symfony/polyfill-iconv (v1.18.1): Loading from cache- Installing doctrine/lexer (1.2.1): Loading from cache- Installing egulias/email-validator (2.1.21): Downloading (100%)- Installing swiftmailer/swiftmailer (v6.2.3): Loading from cache- Installing yiisoft/yii2-swiftmailer (2.1.2): Loading from cache- Installing opis/closure (3.5.7): Loading from cache- Installing yiisoft/yii2-debug (2.1.13): Loading from cache- Installing phpspec/php-diff (v1.1.3): Loading from cache- Installing yiisoft/yii2-gii (2.1.4): Loading from cache- Installing fzaninotto/faker (v1.9.1): Loading from cache- Installing yiisoft/yii2-faker (2.0.4): Loading from cache- Installing codeception/stub (3.7.0): Loading from cache- Installing behat/gherkin (v4.6.2): Loading from cache- Installing symfony/css-selector (v5.1.5): Loading from cache- Installing symfony/deprecation-contracts (v2.2.0): Loading from cache- Installing symfony/yaml (v5.1.5): Loading from cache- Installing symfony/polyfill-php80 (v1.18.1): Loading from cache- Installing psr/event-dispatcher (1.0.0): Loading from cache- Installing symfony/event-dispatcher-contracts (v2.2.0): Loading from cache- Installing symfony/event-dispatcher (v5.1.5): Loading from cache- Installing psr/container (1.0.0): Loading from cache- Installing symfony/polyfill-intl-grapheme (v1.18.1): Loading from cache- Installing symfony/string (v5.1.5): Loading from cache- Installing symfony/service-contracts (v2.2.0): Loading from cache- Installing symfony/polyfill-php73 (v1.18.1): Loading from cache- Installing symfony/console (v5.1.5): Loading from cache- Installing symfony/finder (v5.1.5): Loading from cache- Installing ralouphie/getallheaders (3.0.3): Loading from cache- Installing psr/http-message (1.0.1): Loading from cache- Installing guzzlehttp/psr7 (1.6.1): Loading from cache- Installing codeception/lib-asserts (1.13.1): Loading from cache- Installing codeception/codeception (4.1.7): Loading from cache- Installing codeception/module-asserts (1.3.0): Loading from cache- Installing symfony/dom-crawler (v4.4.13): Loading from cache- Installing symfony/browser-kit (v4.2.4): Loading from cache- Installing codeception/lib-innerbrowser (1.3.2): Loading from cache- Installing codeception/module-yii2 (1.1.1): Loading from cache- Installing codeception/module-filesystem (1.0.2): Loading from cachesebastian/environment suggests installing ext-posix (*)phpunit/php-code-coverage suggests installing ext-xdebug (^2.7.2)sebastian/global-state suggests installing ext-uopz (*)phpunit/phpunit suggests installing phpunit/php-invoker (^2.0.0)phpunit/phpunit suggests installing ext-soap (*)phpunit/phpunit suggests installing ext-xdebug (*)paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)symfony/polyfill-intl-normalizer suggests installing ext-intl (For best performance)symfony/polyfill-intl-idn suggests installing ext-intl (For best performance)egulias/email-validator suggests installing ext-intl (PHP Internationalization Libraries are required to use the SpoofChecking validation)swiftmailer/swiftmailer suggests installing ext-intl (Needed to support internationalized email addresses)swiftmailer/swiftmailer suggests installing true/punycode (Needed to support internationalized email addresses, if ext-intl is not installed)symfony/event-dispatcher suggests installing symfony/dependency-injectionsymfony/event-dispatcher suggests installing symfony/http-kernelsymfony/polyfill-intl-grapheme suggests installing ext-intl (For best performance)symfony/service-contracts suggests installing symfony/service-implementationsymfony/console suggests installing symfony/locksymfony/console suggests installing symfony/processsymfony/console suggests installing psr/log (For using the console logger)guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)codeception/codeception suggests installing hoa/console (For interactive console functionality)codeception/codeception suggests installing codeception/specify (BDD-style code blocks)codeception/codeception suggests installing symfony/phpunit-bridge (For phpunit-bridge support)codeception/codeception suggests installing stecman/symfony-console-completion (For BASH autocompletion)symfony/browser-kit suggests installing symfony/processPackage phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.Writing lock fileGenerating autoload files28 packages you are using are looking for funding.Use the `composer fund` command to find out more!

Step 3: Please add the following code in c:xampapacheconfextrahttpd.vhosts.conf - Assuming that first-project is the project. Don't forget to restart Apache after add this code.

ServerName first-project.netDocumentRoot "C:/xampp/htdocs/first-project/frontend/web/"<Directory "C:/xampp/htdocs/first-project/frontend/web/"># use mod_rewrite for pretty URL supportRewriteEngine on# If a directory or a file exists, use the request directlyRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d# Otherwise forward the request to index.phpRewriteRule . index.php# use index.php as index fileDirectoryIndex index.php# ...other settings...

ServerName manage.first-project.net DocumentRoot "C:/xampp/htdocs/first-project/backend/web/" <Directory "C:/xampp/htdocs/first-project/backend/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 # use index.php as index file DirectoryIndex index.php # ...other settings...

Step 4: Please add 2 lines in C:WindowsSystem32driversetchosts file and save as Administrator.

127.0.0.1 first-project.net127.0.0.1 manage.first-project.net

 

Step 5: In the browser please type http://first-project.net and you can see project files.

Step 6: Then to make the project environment to Development environment please access project directory in CLI.

c:xampphtdocsfirst-projectphp init

Yii Application Initialization Tool v1.0 Which environment do you want the application to be initialized in? [0] Development [1] Production Your choice [0-1, or "q" to quit] type 0 Initialize the application under 'Development' environment? [yes|no] type yes Start initialization ... overwrite backend/config/main-local.php unchanged backend/config/params-local.php unchanged backend/config/test-local.php unchanged backend/web/index-test.php unchanged backend/web/index.php unchanged backend/web/robots.txt overwrite common/config/codeception-local.php unchanged common/config/main-local.php unchanged common/config/params-local.php unchanged common/config/test-local.php unchanged console/config/main-local.php unchanged console/config/params-local.php unchanged console/config/test-local.php unchanged frontend/config/codeception-local.php overwrite frontend/config/main-local.php unchanged frontend/config/params-local.php unchanged frontend/config/test-local.php unchanged frontend/web/index-test.php unchanged frontend/web/index.php unchanged frontend/web/robots.txt unchanged yii unchanged yii_test unchanged yii_test.bat generate cookie validation key in backend/config/main-local.php generate cookie validation key in common/config/codeception-local.php generate cookie validation key in frontend/config/main-local.php chmod 0777 backend/runtime chmod 0777 backend/web/assets chmod 0777 console/runtime chmod 0777 frontend/runtime chmod 0777 frontend/web/assets chmod 0755 yii chmod 0755 yii_test ... initialization completed.

Step 7: Now access the project in the browser and you can see the magic. Yii2 is installed and running successfully.

Enjoy ;)