[font="Arial"]Thought I would post how to create an admin section for your application using the CRUD feature of the yii shell.
Thanks to the yii tutorial http://www.yiiframework.com/doc/guide/quickstart.first-app#implementing-crud-operations and Kevin Korb’s tutorial http://www.kevinkorb.com/post/21, they were a big help…
-
Create the skeleton app using the getting started tutorial on the yii site.
-
modify DB connection settings in /config/main.php to point to your application’s database.
-
Log into SSH and browse to the /skeletonSite/protected/ directory
-
Run the yii shell from this directory but pointing back to the index.php file like: yii shell ../index.php.
-
‘models *’ will create models for each table in your DB.
-
‘crud TableName’ will create the CRUDs for that table. Run that for each table you want a CRUD for.
-
Browse your work by going to /index.php?r=TableName/admin. (defualt login is admin/admin)
For me, the yiic.php script is symbolically linked from /usr/local/lib/php/yii/yii-mcc/framework/yiic.php so I was accessing the yii shell by using: php ~/bin/yiic.php shell ../index.php
Here is my dump:[/font]
[font="Courier New"]ssh devbox.net -l jdoyle
password:
[~/public_html]# cd subscriptions/protected
[~/public_html/subscriptions/protected]# php ~/bin/yiic.php shell ../index.php
Yii Interactive Tool v1.0 (based on Yii v1.0.9)
Please type ‘help’ for help. Type ‘exit’ to quit.
>> model *
The following model classes (tables) match your criteria:
-
Pricing (pricing)
-
Subscriptions (subscriptions)
-
Titles (titles)
Do you want to generate the above classes? [Yes|No] yes
generate Pricing.php
generate Subscriptions.php
generate Titles.php
The following model classes are successfully generated:
Pricing, Subscriptions, Titles
If you have a ‘db’ database connection, you can test these models now with:
$model=Titles::model()->find();
print_r($model);
>> crud Titles
generate TitlesController.php
mkdir .../protected/views/titles
generate create.php
generate update.php
generate list.php
generate show.php
generate admin.php
generate _form.php
Crud ‘titles’ has been successfully created. You may access it via:
http://hostname/path/to/index.php?r=titles
>> crud Subscriptions
generate SubscriptionsController.php
mkdir .../protected/views/subscriptions
generate create.php
generate update.php
generate list.php
generate show.php
generate admin.php
generate _form.php
Crud ‘subscriptions’ has been successfully created. You may access it via:
http://hostname/path/to/index.php?r=subscriptions
>> crud Pricing
generate PricingController.php
mkdir .../protected/views/pricing
generate create.php
generate update.php
generate list.php
generate show.php
generate admin.php
generate _form.php
Crud ‘pricing’ has been successfully created. You may access it via:
http://hostname/path/to/index.php?r=pricing[/font]
[font="Arial"]Hope this helps…[/font]