Yii Framework Forum: Full-fledged Yii demo app for learning purpose - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Full-fledged Yii demo app for learning purpose Updated with more features Rate Topic: -----

#1 User is offline   Krish Chandra 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 04-July 12

Posted 04 July 2012 - 07:40 PM

Hi All Yii Aficionados,
I am a freelance software developer (based in India) with more than 15 years of experience in Microsoft technologies. Of late, I have been experimenting with open-source web development stack and the first one I've been looking at is LAMP. After getting hold of PHP, I chanced upon Yii while looking for web development frameworks in PHP. I immediately liked it for its power. I decided to learn Yii and have been spending some time with it. The first thing I do when I pick up a new framework is to develop a sample project that is reasonably complex and will let me use some of the important/necessary features of it. Online book store ( I usually call it Digital Library) is the one I develop to gain confidence. I developed it in Yii and wanted to share with you all. To enable all the newbie Yii devlopers to study and learn and for the experienced ones to contribute to make it the most comprehensive tutorial app, I have made it open source and put it in GitHub: (github dot com slash Krish-Chandra slash DL). Please go through the readme file to find out the features that it offers and also for the scope for enhancement.

Update:
-------
Now, there are 3 versions of the DL app corresponding to the 3 branches:
- Version 1(master branch):
  • Uses PHP script file for authorization data and access control filters for RBAC
  • Allows a book to have only one author and category each.
  • Doesn't support caching
  • Supports database migration

- Version 2('Caching-and-Many-Many-relations' branch):
  • Uses PHP script file for authorization data and access control filters for RBAC
  • Allows a book to have a maximum of 3 authors and categories each
  • Supports caching
  • Supports database migration

- Version 3('Use-Yii-RBAC' branch):
  • Uses the database for RBAC
    • There is an admin component for it

  • Allows a book to have a maximum of 3 authors and categories each
  • Supports caching
  • Allows the books catalog to be searched based on title or author
  • Supports database migration

Regards,
Krish Chandra
krishchan01 at hotmail dot com
2

#2 User is offline   kiran sharma 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 492
  • Joined: 21-May 11
  • Location:India

Posted 05 July 2012 - 12:06 AM

gr8 work,
found you made modules for admin and library.
will check whole afterwards.
Me also thinking for made opensource sample project demo, but haven't get time.
+1 for this.
Thanks,
Kiran Sharma.
0

#3 User is offline   yiqing95 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 592
  • Joined: 27-December 10
  • Location:china

Posted 05 July 2012 - 01:14 AM

address is https://github.com/Krish-Chandra/DL :lol:
0

#4 User is offline   bettor 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 751
  • Joined: 02-February 09

Posted 05 July 2012 - 01:54 AM

Krish,

This is very good idea and will help the community tremendously. I randomly looked through some of the controllers and noticed that occasionally you are printing html in your controllers. What made you choose to display html in the controller rather then using a view?

Thanks for sharing with us.
0

#5 User is offline   raiethan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 76
  • Joined: 10-February 12

Posted 05 July 2012 - 06:46 AM

after i run i got this error ( ! ) Fatal error: Class 'Memcache' not found in C:\xampp\yii\framework\caching\CMemCache.php on line 111
Call Stack
# Time Memory Function Location
1 0.0007 336072 {main}( ) ..\index.php:0
2 0.0253 1885224 CApplication->run( ) ..\index.php:15
3 0.0253 1885224 CWebApplication->processRequest( ) ..\CApplication.php:158
4 0.0253 1885224 CApplication->getUrlManager( ) ..\CWebApplication.php:135
5 0.0254 1885280 CModule->getComponent( ) ..\CApplication.php:501
6 0.0277 2101272 CUrlManager->init( ) ..\CModule.php:372
7 0.0277 2101304 CUrlManager->processRules( ) ..\CUrlManager.php:205
8 0.0278 2101336 CModule->getComponent( ) ..\CUrlManager.php:215
9 0.0299 2246296 CMemCache->init( ) ..\CModule.php:372
10 0.0300 2246608 CMemCache->getMemCache( ) ..\CMemCache.php:88
11 0.0300 2246816 YiiBase::autoload( ) ..\YiiBase.php:0
12 0.0303 2248248 CApplication->handleError( ) ..\CApplication.php:421
13 0.0352 2925792 CErrorHandler->handle( ) ..\CApplication.php:793
14 0.0352 2925824 CErrorHandler->handleError( ) ..\CErrorHandler.php:106
15 0.0354 2938248 CErrorHandler->render( ) ..\CErrorHandler.php:238
16 0.0354 2938280 CWebApplication->runController( ) ..\CErrorHandler.php:280
17 0.0354 2938280 CWebApplication->createController( ) ..\CWebApplication.php:271
18 0.0354 2938344 CApplication->getUrlManager( ) ..\CWebApplication.php:311
19 0.0354 2938400 CModule->getComponent( ) ..\CApplication.php:501
20 0.0355 2940240 CUrlManager->init( ) ..\CModule.php:372
21 0.0355 2940272 CUrlManager->processRules( ) ..\CUrlManager.php:205
22 0.0355 2940304 CModule->getComponent( ) ..\CUrlManager.php:215
23 0.0356 2942232 CMemCache->init( ) ..\CModule.php:372
24 0.0356 2942264 CMemCache->getMemCache( ) ..\CMemCache.php:88
0

#6 User is offline   Krish Chandra 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 04-July 12

Posted 05 July 2012 - 08:31 AM

View Postbettor, on 05 July 2012 - 01:54 AM, said:

Krish,

This is very good idea and will help the community tremendously. I randomly looked through some of the controllers and noticed that occasionally you are printing html in your controllers. What made you choose to display html in the controller rather then using a view?

Thanks for sharing with us.


Hi bettor,
Thanks!
I echo HTML from the controllers whenever the action is AJAXified.

Regards,
Krish Chandra
0

#7 User is offline   Krish Chandra 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 04-July 12

Posted 05 July 2012 - 06:27 PM

View Postdhenet5254, on 05 July 2012 - 06:46 AM, said:

after i run i got this error ( ! ) Fatal error: Class 'Memcache' not found in C:\xampp\yii\framework\caching\CMemCache.php on line 111
Call Stack
# Time Memory Function Location
1 0.0007 336072 {main}( ) ..\index.php:0
2 0.0253 1885224 CApplication->run( ) ..\index.php:15
3 0.0253 1885224 CWebApplication->processRequest( ) ..\CApplication.php:158
4 0.0253 1885224 CApplication->getUrlManager( ) ..\CWebApplication.php:135
5 0.0254 1885280 CModule->getComponent( ) ..\CApplication.php:501
6 0.0277 2101272 CUrlManager->init( ) ..\CModule.php:372
7 0.0277 2101304 CUrlManager->processRules( ) ..\CUrlManager.php:205
8 0.0278 2101336 CModule->getComponent( ) ..\CUrlManager.php:215
9 0.0299 2246296 CMemCache->init( ) ..\CModule.php:372
10 0.0300 2246608 CMemCache->getMemCache( ) ..\CMemCache.php:88
11 0.0300 2246816 YiiBase::autoload( ) ..\YiiBase.php:0
12 0.0303 2248248 CApplication->handleError( ) ..\CApplication.php:421
13 0.0352 2925792 CErrorHandler->handle( ) ..\CApplication.php:793
14 0.0352 2925824 CErrorHandler->handleError( ) ..\CErrorHandler.php:106
15 0.0354 2938248 CErrorHandler->render( ) ..\CErrorHandler.php:238
16 0.0354 2938280 CWebApplication->runController( ) ..\CErrorHandler.php:280
17 0.0354 2938280 CWebApplication->createController( ) ..\CWebApplication.php:271
18 0.0354 2938344 CApplication->getUrlManager( ) ..\CWebApplication.php:311
19 0.0354 2938400 CModule->getComponent( ) ..\CApplication.php:501
20 0.0355 2940240 CUrlManager->init( ) ..\CModule.php:372
21 0.0355 2940272 CUrlManager->processRules( ) ..\CUrlManager.php:205
22 0.0355 2940304 CModule->getComponent( ) ..\CUrlManager.php:215
23 0.0356 2942232 CMemCache->init( ) ..\CModule.php:372
24 0.0356 2942264 CMemCache->getMemCache( ) ..\CMemCache.php:88



Hi,
Open the main.php config file in the protected\config folder, locate the following line, comment it out and try:
'cache'=>array('class'=>'system.caching.CMemCache', 'servers'=>array(array('host'=>'127.0.0.1', 'port'=>11211, 'weight'=>60))),
0

#8 User is offline   razorfish 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 04-July 12

Posted 14 July 2012 - 06:08 AM

hey Krish , nice app
I am going to take a deep look at your app since I am a new Yii developer.
But wich is the username and posword for admin area?
0

#9 User is offline   Krish Chandra 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 04-July 12

Posted 14 July 2012 - 10:29 AM

View Postrazorfish, on 14 July 2012 - 06:08 AM, said:

hey Krish , nice app
I am going to take a deep look at your app since I am a new Yii developer.
But wich is the username and posword for admin area?


Hi razorfish,
Thanks!
username: administrator
password: admin
0

#10 User is offline   ErwinDeClerck 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 15-July 12

Posted 15 July 2012 - 02:28 PM

Seems like there is a case-problem with the files:
protected/modules/admin/adminmodule.php
and
protected/modules/admin/librarymodule.php
on some systems. (eg. Linux)
They should be:
protected/modules/admin/AdminModule.php
protected/modules/admin/LibraryModule.php

The proposed paths in index.php are Windows paths also...
Works better with forward slashes on Linux :-)

And a last thing: the name of the database is also capitalized.
Spelling of database and 'connectionString' => 'mysql:host=localhost;dbname=digital_library', in main.php should be spelled same way.

As a newbie it took me a few hours to find out. Thought I should share it.

Erwin
0

#11 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 15 July 2012 - 02:51 PM

IMO, those changes needs to be applied to the repository, so you'd better fork it and issue a pull request. :)
"Less noise - more signal"
0

#12 User is offline   Suralc 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 10-January 12
  • Location:Germany

Posted 15 July 2012 - 04:03 PM

Even if I didn't noticed the backslashes, as I'm using Windows, the issue should be solved in this branch:

https://github.com/s...ii-as-submodule

Pullrequest is already open.

I did not touch the case issues inside the app.
0

#13 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 15 July 2012 - 04:05 PM

IMO, if it doesn't break anything on Windows, fix it in the main branch.

Makes sense since 98% of all servers are running on some kind of *nix and thus are case-sensitive.
"Less noise - more signal"
0

#14 User is offline   Suralc 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 10-January 12
  • Location:Germany

Posted 15 July 2012 - 04:13 PM

Well I'm not the owner, I just forked the project and opend a pullrequest to include yii as a submodule. I didn't noticed the case-sensitivity issue. I just changed the backslashes to forward slashes as I updated the path.
0

#15 User is offline   ErwinDeClerck 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 15-July 12

Posted 15 July 2012 - 06:37 PM

And I found a few other case-sensitivities...
in modules/admin/views/author/index.php 17: 'zii.widgets.Grid.CGridView',
should become a lower case: zii.widgets.grid.CGridView',

same for
modules/admin/views/book/index.php
modules/admin/views/category/index.php
modules/admin/views/issue/index.php
modules/admin/views/member/index.php
modules/admin/views/publisher/index.php
modules/admin/views/request/index.php
modules/admin/views/role/index.php
modules/admin/views/user/index.php

and

modules/library/views/default/index.php
modules/library/views/default/viewcart.php

Erwin
0

#16 User is offline   Krish Chandra 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 04-July 12

Posted 17 July 2012 - 12:56 AM

View PostSuralc, on 15 July 2012 - 04:03 PM, said:

Even if I didn't noticed the backslashes, as I'm using Windows, the issue should be solved in this branch:

https://github.com/s...ii-as-submodule

Pullrequest is already open.

I did not touch the case issues inside the app.


I notice that you've added 'RewriteBase /' in .htaccess. Why did you add this line? With it, a url, like http://localhost:8080/DL/admin, will not work.

What is the issue with backslashes? Since I develop on Windows, I am unable to anticipate the issues on other OSes.
0

#17 User is offline   Suralc 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 10-January 12
  • Location:Germany

Posted 19 July 2012 - 11:52 AM

View PostKrish Chandra, on 17 July 2012 - 12:56 AM, said:

I notice that you've added 'RewriteBase /' in .htaccess. Why did you add this line? With it, a url, like http://localhost:8080/DL/admin, will not work.

What is the issue with backslashes? Since I develop on Windows, I am unable to anticipate the issues on other OSes.



I obv. failed with this, I just changed that on my local system and forgot to remove it from the commit. Would be nice if anyone could revert this, as I'm currently(including the next two weeks) unable to get access to a pc with a working version of git.
0

#18 User is offline   razorfish 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 04-July 12

Posted 22 July 2012 - 10:09 AM

Well I'm trying this apps and it seems cool for a beginer like me.

When I delete an Author that has some Books, those books are deleted too.
How is this possible since actionDelete on Author model doesn't have any piece of code related with the deletion of his books?
0

#19 User is offline   raiethan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 76
  • Joined: 10-February 12

Posted 22 July 2012 - 09:42 PM

Sir why is that i try to install on my local host and created a sample author, publisher, and categories and when i try to add a book, My ISBN always invalid..
0

#20 User is offline   Krish Chandra 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 04-July 12

Posted 22 July 2012 - 11:45 PM

View PostSuralc, on 19 July 2012 - 11:52 AM, said:

I obv. failed with this, I just changed that on my local system and forgot to remove it from the commit. Would be nice if anyone could revert this, as I'm currently(including the next two weeks) unable to get access to a pc with a working version of git.


Taken care of it!
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users