The Yii2 preview was recently released and is available on github. I want to take it for a test drive, but the "documentation" so far gets outdated almost instantly since it is still under heavy development. I have tried to follow this guide on creating a simple CRUD app with Yii2, but it fails at the step:
php yiic.php app/create /var/www/yii2
With the error:
Could not open input file: yiic.php
Indicating that there is no file called yiic.php
. The only folder within the framework folder is yii (framework/yii
), and within that folder there is no file yiic.php
, only Yii.php
which when called in the command line gives the command list:
The following commands are available:
- asset
- cache
- help
- message
- migrate
Anyone managed to successfully setup a Yii2 app? Care to share how you got it done?
Installing from an Archive File Download the archive file from yiiframework.com. Unpack the downloaded file to a Web-accessible folder. Modify the config/web. php file by entering a secret key for the cookieValidationKey configuration item (this is done automatically if you are installing Yii using Composer):
Advertisements. A widget is a reusable client-side code, which contains HTML, CSS, and JS. This code includes minimal logic and is wrapped in a yii\base\Widget object. We can easily insert and apply this object in any view.
Seems like yiic has been removed for now, there are alternatives though, so read on.
It's all in the early stages, so the following method could break in the coming days/weeks/months. Therefore use with caution.
There are 2 ways to do this now:
Use composer. (I recommend this option.)
Directly copy the contents of yii2/apps/ directory to your apps directory, depending on the type of app you want to try.
There are currently 2 options for type of app - advanced, and basic. Both are in their respective directories within the yii2/apps/ directory, i.e yii2/apps/advanced and yii2/apps/basic.
For basic go through the basic readme.md, and for advanced go through the advanced readme.md.
The directions for using composer are given in the respective readme.md files. Including them here for completeness:
php path/to/composer.phar create-project --stability=dev yiisoft/yii2-app-basic my_yii2_trial
http://localhost/my_yii2_trial/www
php path/to/composer.phar create-project --stability=dev yiisoft/yii2-app-advanced my_yii2_trial
./install
. Selected development environment (by entering choice 0
in the instructions that show up when running install
command). init
, composer doesn't fail anymore, with fix from Qiang (check the issue 439 for more details).http://localhost/my_yii2_trial/frontend/www
or http://localhost/my_yii2_trial/backstage/www
Here's how to copy the directory and get it working:
Basic app:
http://localhost/my_yii2_trial/www
Advanced app:
http://localhost/my_yii2_trial/frontend/www
or http://localhost/my_yii2_trial/backstage/www
Some important links to read more about this: issue 77, issue 108, issue 131, and wiki comment.
I am not sure how composer's autoloader is being used, so can't comment on that. Also in future versions, backstage might be renamed to backend.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With