Yii Framework Forum: Where is the best place to store my own classes - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Where is the best place to store my own classes Rate Topic: -----

#1 User is offline   Daniel Zhu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 18-December 09

Posted 18 December 2009 - 10:53 AM

same as title.

thanks.
0

#2 User is offline   manilodisan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 80
  • Joined: 17-September 09
  • Location:Bucharest

Posted 18 December 2009 - 11:04 AM

I would say...components/
Or components/lib/ - lib/ is not part of Yii but it's how I like to call it.
0

#3 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,695
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 18 December 2009 - 11:14 AM

I think, /components is better for classes that extends CComponent.
I prefer to use my own folder called 'vendors' (CakePHP legacy :))
God is real unless declared as integer
0

#4 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 18 December 2009 - 11:16 AM

I use /components for app-components, /components/controllers for special parent controllers, /components/classes for classes and so on.
0

#5 User is offline   jayrulez 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 348
  • Joined: 29-July 09

Posted 18 December 2009 - 11:28 AM

All classes that are used by my application are stored under protected/components/$classgroup$

eg:

protected
protected/components
protected/components/auth
protected/components/controllers
protected/components/mailer
protected/components/widgets
etc...

if the class is not a part of a group then i place it under

protected/components
php:
foreach(array('cat', 'dog', 'cow') as $animal) echo $animal."\n";

python:
[(animal, print(animal)) for animal in ['cat', 'dog', 'cow']]

ruby:
['cat', 'dog', 'cow'].each {|animal| puts animal}


You say Tomato, I say Tomato.
0

#6 User is offline   Daniel Zhu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 18-December 09

Posted 18 December 2009 - 02:49 PM

Can anyone give me an example how to call methods I put in components folder.

I like to have something like:

class.myclass.addit(x,y)


Is this possible. thanks.
0

#7 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 18 December 2009 - 02:53 PM

You can simply do MyClass::myFunction()
0

Share this topic:


Page 1 of 1
  • 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