Yii Boilerplate Installation Guides:
1. Download YiiBoilerplate from https://github.com/clevertech/YiiBoilerplate2. Map admin.domainname.com (or similar) to backend > www
Map domainname.com (or similar) to frontend > www (if required)
3. Create database for app
Create database for test with suffix _test (if required)
4. Add db details to common > config > params-local.php
5. Remove comments from db connections in console > config > main.php
Remove comments from db connections and gii in backend > config > main.php
Remove comments from db connections in frontend > config > main.php (if required)
6. Run the following command
./runpostdeploy local non-migrate
./yiic migrate
Yii Boilerplate Get Start:
** Please chmod 777 for the following file and folder- yiic and runpostdeploy
- backend/views
- backend/controllers
- backend/models
1. Run the following command to create table in mysql
./yiic migrate create create_tablename
2. Goto folder console/migration/ and find the file to add in table stucture
3. Run the following command after edit migration file
./yiic migrate
4. Goto backend/config/main.php to uncomment Gii section and save the file
5. You can browse Gii with the following path and start work with your MVC
http://xxx.dev/backend/www/gii/default/index
To Enable Gii
1. Goto backend/config/main.php2. uncomment Gii
3. Add the following code in Gii section, else you will get error 403
'ipFilters' => array('127.0.0.1', $_SERVER['REMOTE_ADDR']),
To Browse Gii
1. Goto http://yourdomain.com/backend/www/gii/model/
********************* HAPPY CODING!! ******************
ok found the file mlXXXXXX_XXXXXX_create_tablename.php
ReplyDeleteand? how it would be edited? that info unfortunely is not in the yiiboilerplate documentation.
Hi Nestor, its depend on what sql queries you want to write. The following is the sample of creating table, hope it is helping:
ReplyDeleteclass mlXXXXXX_XXXXXX_create_tablename extends CDbMigration {
public function up() {
// Create sample table
$create_fields = array(
'id' => 'INT NOT NULL AUTO_INCREMENT',
'text' => 'TEXT NOT NULL',
'sequence' => 'INT NULL',
'status' => 'TINYINT NULL',
'create_date' => 'INT UNSIGNED NULL',
'user_id' => 'INT UNSIGNED NULL',
'PRIMARY KEY (id)'
);
$this->createTable('sample', $create_fields);
}
public function down() {
//drop question_table
$this->dropTable('sample');
}
}
The concept to create table with migration command in regular yii framework are the same. The only difference is the folder location, it located in protected/migrations .
ReplyDeleteI like the tutorial, was a big help. You're cute btw ;)
ReplyDeleteHi Jamarcus, Thanks for the support. ^^
DeleteReally great tutorial, straight steps to follow and project is ready to deploy.
ReplyDeleteMany thanks.
Thanks, hope it helping. :)
DeleteHello,
ReplyDeleteI have created two virtual host in my ubuntu 12.10 os. i.e
backend.local for yii backend and
frontend.local for yii frontend
I have added path for them in my vhost like:
ServerName backend.local
DocumentRoot /var/www/yiibootstrap/backend/www
and
ServerName frontend.local
DocumentRoot /var/www/yiibootstrap/frontend/www
But when I am trying open
http://backend.local/gii
its showing me following error:
Not Found
The requested URL /gii was not found on this server.
Please help to solve this. I am very new in yii framework.
Thanks
Please check if you had enable gii module from backend\config\main.php
DeleteYes gii module is enabled here. I have removed comments these lines:
Delete'modules' => array(
'gii' => array(
'class' => 'system.gii.GiiModule',
'password' => 'clevertech',
'generatorPaths' => array(
'bootstrap.gii',
//'ipFilters' => array('127.0.0.1', $_SERVER['REMOTE_ADDR']),
),
)
),
This comment has been removed by the author.
DeletePlease try with this:
Delete'modules' => array(
'gii' => array(
'class' => 'system.gii.GiiModule',
'password' => 'clevertech',
'ipFilters' => array('127.0.0.1', $_SERVER['REMOTE_ADDR']),
'generatorPaths' => array(
'bootstrap.gii'
)
)
),
Thanks for reply..but its still not working
DeleteHow about http://backend.local? Any error?
DeleteHi,
DeleteI solved that error :) It was the issue of read-write module in my ubuntu os. by the way Thanks for help. Can I ask you little more help about YiiBoilerPlate ? Do you have some tutorials on it?
that's great to hear that and have fun with boilerplate! (^-^)
DeleteHi Lee, Thanks a lot for the tutorial. This helped me a lot. Have you tried running unit test. test.php is in frontend config and do we create test in frontend or in tests folder?
ReplyDelete1./When run (runpostdeploy local non-migrate), I get bug:
ReplyDeleteRunning command:
php 'C:\wamp\www\yiiboilerplate\common\lib/../../yiic' migrate --interactive=0 'php' is not recognized as an internal or external command, operable program or batch file.
2./When run (yiic migrate), I get bug:
PHP Error[2]: PDO::_construc<>: php_network_getaddresses: getaddrinfo fail: No such host is know
in file c:\.......\common\lib\CDbConnection.php at line 422
==> Please help me setup detail!
It could be your db setting error, or try to restart mysql service.
DeleteCan you vnc remote and config for me, please? Thank you very much :). My yahoo, skype: quangckt
DeleteSory about my bad english!
How can use gii to create/update models in the Common directory?
ReplyDeleteHi Jan, you can try to create from Backend then move the file to Common Directory
DeleteJust change the Model Path
Deletefrom application.models
to common.models
Thank you! :)
ReplyDeleteHi Jan,there is no such file named params-local.php in the newest YiiBoiler.Do I need to create one?
ReplyDeleteYou are right. I am too looking into this setup but could not find this file. I guess the structure mentioned in this article has changed in the last few months base don the commits I see on git.
DeleteHi lee, I can't configure my yii boilerplate application. can you give me some details about your each step??
ReplyDelete1. Map admin.domainname.com (or similar) to backend > www
Map domainname.com (or similar) to frontend > www (if required)
mean what??
2. Run the following command
./runpostdeploy local non-migrate
./yiic migrate
how to run these commands??
If you are using LAMP environment, you should go to /etc/httpd/vhosts.d to setup the mapping. Then cd /var/www/hosts/ and redirect to your project folder.
DeleteTo run migration command, you have to go to your project folder from command prompt.
This comment has been removed by the author.
ReplyDeleteI run these commands but i get the error that '.' is not recognized as an internal or external command.
ReplyDeleteAnd i am working on WAMP environment.
ReplyDeleteGreat work, I would mention a addition of a line indicating that after unpacking the archive a dependency installation should be done with composer.
ReplyDeleteBut I still have some questions.
1. Using Gii I create models, but when using crud the controllers are created descended from CController, is it right to be changed to BackendController (for backend for example)?
2. Even changed to "extend BackendController" in a created controller i get a wrong view in browser? Is there any specific things for creating mvc with crud?
Great,
ReplyDeleteand how do I post production.
I have FTP access to public_html.
How can it be configured on production server if everything is uploaded in public_html. So i am getting issue if i am pointing public_html/frontend/www its always redirecting to index.php means its always redirect to default controller it does not process the request of other controller.
ReplyDeletePlease guide on this.