helmut2509 Posted September 5, 2018 Share Posted September 5, 2018 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 More sharing options...
Tom. Posted September 5, 2018 Share Posted September 5, 2018 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. 2 Link to comment Share on other sites More sharing options...
helmut2509 Posted September 6, 2018 Author Share Posted September 6, 2018 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 More sharing options...
kongondo Posted September 6, 2018 Share Posted September 6, 2018 (edited) 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 September 6, 2018 by kongondo 2 Link to comment Share on other sites More sharing options...
horst Posted September 6, 2018 Share Posted September 6, 2018 1 hour ago, kongondo said: or if needed even earlier or if even needed more early, but thats not very common, add it into your site/config.php. ? 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now