Whole site in class
Moderator: General Moderators
-
shivam0101
- Forum Contributor
- Posts: 197
- Joined: Sat Jun 09, 2007 12:09 am
Whole site in class
Hello,
How to build whole website in class files? What structure I should follow? I am using php with mysql
Thanks
How to build whole website in class files? What structure I should follow? I am using php with mysql
Thanks
A whole web site should not be in class files. You will need regular .php files, template files (if you're doing templating), css files, etc.
Classes should be used for performing a specific task, or a group of similarly related tasks. Even if you want to go completely object oriented, using a framework, or design pattern, all of your files will not be in classes.
Classes should be used for performing a specific task, or a group of similarly related tasks. Even if you want to go completely object oriented, using a framework, or design pattern, all of your files will not be in classes.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
Re: Whole site in class
You would only want to do this if you want to have one of the slowest web sites around that can't support very many simultaneous accesses without overloading the CPU.shivam0101 wrote:Hello,
How to build whole website in class files? What structure I should follow? I am using php with mysql
Thanks
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Whole site in class
I think the poster means using OO to build the site, not all in one class.shivam0101 wrote:How to build whole website in class files? What structure I should follow? I am using php with mysql
I would recommend look at some PHP frameworks like the Zend Framework, Cake, Symfony, Code Igniter, etc. There are many excellent frameworks available. One of them will probably be in the style you prefer. You can use one of them or model your own code on their code.
And your site will perform fine despite what Panama Jack always says. There are thousands of sites around based on PHP OO frameworks.
(#10850)
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
-
shivam0101
- Forum Contributor
- Posts: 197
- Joined: Sat Jun 09, 2007 12:09 am
Thanks for replying.
This is how i made, since i this is the first time i am making class to make a site, i am very confused and i am changing the structure many times.
This is the present structure i am following.
Each class in seperate files.
1. A class for sql statements
2. A class for client
3. A class for admin
4. A class for general - methods which are general to both client and admin
5. A class to link all this.- I will be calling this class object to access the methods of other classes.
But after going through, viewtopic.php?t=72041&highlight= i think i made a mistake. Since the site is allmost over. I can only alter a small portion and it may take more time to redo. Can any one please suggest a better way of altering.
Thanks.
This is how i made, since i this is the first time i am making class to make a site, i am very confused and i am changing the structure many times.
This is the present structure i am following.
Each class in seperate files.
1. A class for sql statements
2. A class for client
3. A class for admin
4. A class for general - methods which are general to both client and admin
5. A class to link all this.- I will be calling this class object to access the methods of other classes.
But after going through, viewtopic.php?t=72041&highlight= i think i made a mistake. Since the site is allmost over. I can only alter a small portion and it may take more time to redo. Can any one please suggest a better way of altering.
Thanks.
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
Actually it can be if you take the time. One of the best cases it to use the Zend Framework, class nightmare from hell to create a site and then do the same thing using mainly procedural coding with just a couple of classes for database and templating. Then use a web site stress testing package to test the number of simultaneous connection each design can handle. You will find the design using the Zend Framework is horribly slow and can't even come close to the number of page accesses per second of the virtually non-class version. I know I have tested stuff like this to make sure.ole wrote:You can't substantiate that in any way.You would only want to do this if you want to have one of the slowest web sites around that can't support very many simultaneous accesses without overloading the CPU.
It's a inherent problem with PHP in creating objects from classes. The classes themselves are just as fast as procedural code after they have been created. It's the creation part that is dog slow in all versions of PHP. If you decide to take the time and actually test this yourself you will see I am right.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Your classes are not quite right, but you are headed in the right direction. Your next site will be a little better. Look at the frameworks I listed. They will give you ideas.shivam0101 wrote:But after going through, viewtopic.php?t=72041&highlight= i think i made a mistake. Since the site is allmost over. I can only alter a small portion and it may take more time to redo. Can any one please suggest a better way of altering.
(#10850)
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
George Schlossnagle, and he's not the first, mentions in his presentation that object overhead make up only a tiny fraction for the performance of the application when compared with the database (page 8 ). This is of course a typical case, things things vary depending on what you are writing and how you have written them.
Did you use a profiler? There were probably specific things about ZF that made it slow, for instance the ZF front controller always starts a session. On some systems this can potentially be quite an expensive operation considering a garbage clean-ups are performed at that time.One of the best cases it to use the Zend Framework, class nightmare from hell to create a site and then do the same thing using mainly procedural coding with just a couple of classes for database and templating. Then use a web site stress testing package to test the number of simultaneous connection each design can handle. You will find the design using the Zend Framework is horribly slow and can't even come close to the number of page accesses per second of the virtually non-class version. I know I have tested stuff like this to make sure.
This is the first time I've ever heard this.It's a inherent problem with PHP in creating objects from classes.