473,756 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Large Scale PHP Application Design Questions

I'm about to start working on my first large scale site (in my opinion) that
will hopefully have 1000+ users a day. ok, this isn't on the google/facebook
scale, but it's going to be have more hits than just family and friends.

Either way, I'm planning on this site blowing up once I have enough of a
feature set, so I'm concerned about performance and scalability in the long
run.

I've worked for a software company, but I've never programmed PHP
professionally (looking for an entry level job, wink wink ).

I was wondering if sites like Sitepoint, MySpace, Facebook, etc... actually
use DB abstraction layers and template engines.

I also plan on using the code for this site for my portfolio, so I'd like to
have as much original code as possible, that's why I'm not even considering
using a framework (I've dabbled a bit with CakePHP and ZF), so I won't
bother asking about using them for large scale sites.

I've been doing a lot of research, and it seems to me that using PHP as a
templating engine itself and creating my own DB class using native DB calls
(going to use MySQL until I find it no longer suites my needs) would be the
most efficient approach.

I do plan on separating Data/Business/Presentation logic to make maintenance
easier, so that's the only reason I'm considering using a Template engine to
separate the Business/Presentation layers, and then either PDO, ADOdb or
PEAR::DB for the data layer.

But once again, I've come to the conclusion that using pure PHP to separate
the Business/Presentation layers, while using my own home brewed DB class as
the data layer would be the best way to go regarding
performance/scalability.

Are there professionals out there with experience working on large scale
sites/applications that can lend their two cents?
Oct 17 '08
22 3662
On Oct 22, 10:36 am, "Jesse Burns" <jburns...@jbwe bware.comwrote:
[snip]
>
I've also included my "includes" folder in php's include_path, which was a
great suggestion, thanks. I have one question on that. My "includes" folder
is located outside of my doc_root, but since it's in the include_path in my
php.ini file, can people still access it that don't have root privileges?
You can set an .htaccess file to restrict anyone outside from
accessing files in the folder except localhost (or something to that
affect) so include will work but not user links (I just learned about
that one, have to re-arrange some files...)
I know that I'm not thinking of everything that I'll need in the future, but
I hope that I have enough knowledge at this time to make changes in the
future as painless as possible.
....
I know I haven't touched on a few suggestions posted here, but that's
because I'm still mulling them over and doing my research.
Heres a big tip, now that you have a good beginning of dos and donts,
START WRITING CODE!

Research and theory are nice for a lunch or evening conversation but
practice is where you will actually get your skills polished and
things get done. Some of this stuff may not work for you or you may
discover your own styles. Getting good at programming takes actually
programming a lot.

Also pain happens, regardless of what you know, just think of it as a
challenge, and know you will be getting some real-world hard-knocks
skills tackling those problems.
Once again, I'd like to thank everyone for their feedback. It is much
appreciated.
Sounds like you are off to a good start.
Oct 22 '08 #21
Jerry Stuckle wrote:
>Prefix all your objects with $obj_

I disagree with this part. While it's important to give meaningful
names, I think $customer for a Customer object works well. Then use
something like $customerId for a customer's id (which is probably an
int). I just don't see a good reason to complicate things with $obj_
prefixes (plus it makes documentation that much harder when you have a
lot of objects prefixed that way).
It's a personal thing I suppose. I just like to know when I'm dealing
with an object.
>
>Objects should always have get and set methods for all variables.
IMHO, you should never access variables directly from outside the object.

Agreed - all variables should be private.
>The exception to this is using the __get magic method, which I have
found enormously useful. To give you an example, let's say you have a
customer object and you want to be able to get any property of the
customer eg. $obj_Customer->name and $obj_Customer->balance.

In this I somewhat disagree. I don't like the __get() and __set()
methods at all. It complicates the code.
>You can put a switch/case in the __get method so you can abstract away
anything behind the scenes. So $obj_Customer->name can bring back a
concatenatio n of firstname and lastname, $obj_Customer->balance can
call another object to do more work and return the balance, and so on.

Which is exactly what I'm referring to above. You don't need to use the
__get() method to do this if you have the methods already instantiated.
There's a time and a place for it. I never use __set because I want the
flexibility to be able to validate inputs to methods. In fact, I only
have one class which uses __get, but otherwise it would have countless,
and in my opinion redundant get methods.

The class in question is one which gets customer details. As the
functionality of the application grows, simply adding another case to
the switch statement does the trick.

public function __get($var)
{
switch($var)
{
case 'foo':
// do stuff to get foo
break;

case 'bar':
// do stuff to get bar
break;

default:
throw new Exception("Cann ot get $var");
break;
}
}

So there's no confusion or ambiguity, and a lot of flexibility without
loss of clarity.
>Then $foo['sdf'] becomes $foo->sdf. Much nicer to use. You can also
create new data objects on the fly using new stdClass.

I don't like this, personally, but won't argue that much with it.
I agree, it's just a matter of taste. I prefer fewer brackets and quotes.
Oct 23 '08 #22
Jesse Burns wrote:
I've also heard (and believe) that the likelihood of throwing away the first
draft and having to start again as you learn what works and what doesn't
work in large projects like this, is a big likelihood. And that's fine with
me as long as I'm learning in the process.
It's funny you should say that - I'm in the process of rewriting an
enormous system which has been successful, will end up looking exactly
the same as the old one and will do the same thing.

It had become unmanageable. I was using an a fairly monolithic system
which worked up to a point, but for the project to go forward it needed
ground up rewriting.

My advice is come up with a simple framework into which you can drop new
pages at will. What has worked for me is to have an index.php which uses
the 'section' variable of the URL to both load up an include file at the
top of the script (for the business logic) and another include file for
the presentation logic (html).

The advantages of OO are enormous. Classes and objects don't just offer
encapsulation, they offer flexibility. You can pass objects to one
another as method arguments, act upon them.

Just don't fall into the trap of writing "God" classes which are
infinitely flexible and general, just because you can. I actually have a
ObjectVerb naming convention for all my classes - CreateFoo, DeleteFoo,
UpdateFoo, often as children from abstract class Foo which might be too
much for some but works for a simpleton like me.
Oct 23 '08 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2279
by: Constandinos Mavromoustakis | last post by:
CFP: CLADE 2004-Challenges of Large Applications in Distributed Environments ------------------------------------------------- PhD student - Dept.Informatics at Aristotle University of Thessaloniki URL-> http://agent.csd.auth.gr/~cmavrom -------------------------------------------------- -------------------------CLADE 2004--------------------------- Challenges of Large Applications in Distributed Environments June 7th, 2004, Honolulu,...
9
2423
by: limor | last post by:
Hi, I am considering using Python in a new testing tool application we intend to build for out product. I must get references before starting develope in this language , since although lots of good things are said about this language , I still have my doubts how can it compete with languages like C++ and Java. I have found te sytax and some features if the language not as problematic in maintenance prospective (although I keep reading...
36
6396
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but something I'll need in this case is some experience-based set of rules about how to use python in this context. For example... is defining readonly attributes in classes worth the hassle ? Does duck-typing scale well in complex
2
3576
by: Kymert persson | last post by:
Hi. I was wondering if there are any more C++ books along the lines of "Large scale C++ software design" by Lakos, J. I.e. concerning larger design issues in close relation to C++. I have made a fairly thorough literature search, but i haven't found anything fitting this criteria. In general there seems to be a huge amount concerning the C++ language as such and more "narrow" design issues, e.g. along the lines of Meyers Effective-
26
2235
by: yoda | last post by:
Hi guys, My situation is as follows: 1)I've developed a service that generates content for a mobile service. 2)The content is sent through an SMS gateway (currently we only send text messages). 3)I've got a million users (and climbing). 4)The users need to get the data a minimum of 5 seconds after it's generated. (not considering any bottlenecks external to my code). 5)Generating the content takes 1 second.
9
1636
by: Da~One | last post by:
This message has been posted to 2 groups, one to the VB.NET group, and the other to C#. I am trying to decide which language to commit to for a large scale project. I am looking for the input of people who have gone through this process before. I am currently leaning towards C# solely because I envision VB.NET slowing down exponentially as projects are added with the constant background compilation.
1
5764
by: Maria DiGiano | last post by:
I am using Access to organize data from a survey which uses a Likert scale to measure response- the scale is 3 points- "I agree", "I don't know" and "I disagree". The numerical value of each response (1, 2 or 3) varies- such that for some questions "I agree" is = to 3 points, and other times "I agree" is = to 1. I created an "answer key" table, such that each record is a question, and for the fields of "I agree", "I disagree" and "I...
1
9857
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9722
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7259
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.