Jump to content

Custom classes


helmut2509
 Share

Recommended Posts

Hello,

I am just going to write a class to process data in my pw app.

My question: where should I store the class files?

should I use a separate directory?

Or should I integrate the class in a module? 

there are certainly different approaches and I am not sure which one to use...

thanx for your help.

Link to comment
Share on other sites

I create a 'ready.php' in the '/site' folder. This is where you can put your class and you can access it anywhere. If you need to re-use it or plan on releasing it, or just want to keep your code tidy. I would use a module. 

  • Like 2
Link to comment
Share on other sites

21 hours ago, Tom. said:

I create a 'ready.php' in the '/site' folder. This is where you can put your class and you can access it anywhere. If you need to re-use it or plan on releasing it, or just want to keep your code tidy. I would use a module. 

thanx for the tip. I will try this.

Link to comment
Share on other sites

Alternatively, depending on what your class does and when you need it to be called as well as the 'template approach' you're using, you could put the whole class in /site/templates/_func.php (_func.php) or in a custom file, e.g. /site/templates/_my_class_file.php. Then, in _init.php include the file (/site/templates/_init.php). Or, if you need it earlier (after current page has been determined but before it is rendered), include it in /site/ready.php or if needed even earlier (e.g to attach hooks), in /site/init.php. Follow the links for more info (to site-default). Using this approach, your ready.php and init.php remain a bit cleaner ?.

Edited by kongondo
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...