A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
|How to use PHP for large projects?||#1|
The question has been asked: No PHP for large projects? Why not? It's a recurring theme and PHP developers--with some cause--are forced to defend PHP.
All of these questions are valid and there have been some responses but this got me thinking. Based on the principle that you can write good code in any language and bad code in any language, I thought it worth asking a positive rather than negative question. Rather than why you can't, I wanted to ask how you can use PHP for large projects.
So, how do you write a large, complex, scalable, secure and robust PHP application?
EDIT: While I appreciate that the organizational aspects are important, they apply to any large project. What I'm primarily aiming for here is technical guidance and how to deal with common issues of scalability. Using an opcode cache like APC is an obvious starter. Cluster-aware sessions would be another. That's the sort of thing I'm getting at.
posted date: 2008-12-21 17:37:00
|Re: How to use PHP for large projects?||#3|
You do as you would in any other language or any other enviornment.There are a couple of simple steps in project development:Organization; You need to organize everything, having documentation, uml diagrams and other pre-work done, before you start programming.Structure; Before you start coding and also aftter starting, you need to have a focus on structure, meaning that you always need to do it correctly and not do any spagetthi solutions. Keep code simple and well commented.These two points, are simple and apply in all development areas, despite the language. Keep it simple and well documented and you will find that developing a large scale web app in PHP is as easy as it would be in ASP.NET, Ruby or whatever.However when we come to the development stage, you need to get a nice IDE, use a good database, use a repo., get an MVC / Template system, this runs in the "Structure"-part though.Just as a side point, splitting the application into different layers: DLF ( Data, Logic, Front ). Use at least these three layers and you will find that the development will go easy.
posted date: 2008-12-21 17:43:00
|Re: How to use PHP for large projects?||#4|
For the most part, the problems with php are not so much with the language. The problems come from the coupling of a low barrier of entry and the lack of any infrastructure to avoid common programming problems or security problems. Its a language that, by itself, is pretty quick-and-dirty. Nevertheless, it still has many advantages for large-scale web apps. You'll just need to know how to add in some level of infrastructure to avoid a lot of the common web programming blunders. See - What should a developer know before building a public web site for help with this.You need to learn about the reasons php can make your web app to be insecure or problematic and learn to mitigate those problems. You should learn about how to use php to securely access your database. You should learn about avoiding SQL injection. You should learn about evil things like register_globals and why you should never ever use them. In short, you should do your homework about your tool before just diving in for a real-world, large-scale, web app.Once you are educated, it comes down to you'll probably want to build a framework or use a preexisting framework that will mitigate these problems. Popular frameworks include PEAR and Zend.Also, useful questions that might help:What should every php programmer know?What should a developer know before building a public web site
posted date: 2008-12-21 17:45:00
|Re: How to use PHP for large projects?||#5|
Using PHP for large projects isn't different than with any other language. You need experience and knowledge in writing maintainable and extendable source code. You need to be aware of security pitfalls and performance concerns. You need to have researched your problem domain and be well familiar with it.In the end, same as any other language - what you need are high-quality and well-motivated developers.
posted date: 2008-12-21 17:51:00
|Re: How to use PHP for large projects?||#6|
posted date: 2008-12-22 14:52:00
|Re: How to use PHP for large projects?||#7|
i know, this is a little out of date, but still, i'll tempt an answer ...use haXe/PHP ... i could delve into details ... but if you look at the language, its features, and the nice way the PHP API is encapsulated into something rather consistent, you will soon see, what PHPs problems are ... and also, you have all the benefits of haXe in the end ...edit: this was a serious answer ... haXe/PHP automatically solves a lot of problems mentioned in the post flagged as answer ... register_globals is turned off ... you get your parameters through the php.Webusing the SPOD-layer (same API for php) for the database automatically takes care of escaping (and will automatically provide your model (and templo is quite a good template engine, so that should help for your views))having a typed language, you are more likely to write better code ... plus language features as generics and enums are very powerful ... and there is a lot of compile time magic in haXe that is also of interest ... a more powerful language is always good to adress complex problems ...if you want to use other PHP frameworks, you only need to write the external classes and everything will work as expected ...i think haXe is a very good answer to "large", "complex", "secure" and "robust" ... scalability does not come from haXe itself of course ... but still, if you check out haxelib, then you find many things, that would help for scalability ... such as memcached (you will have to change neko.net.Socket to php.net.Socket in memcached.Connection) ...if you really want to use the PHP language, and not just the platform, haXe won't help you of course ...
posted date: 2009-07-03 06:03:00
|Re: How to use PHP for large projects?||#8|
i suppose the downvote came from you ... i admit, my answer was a little short ... i made an effort to update it ... hopefully it is of some help now ...
posted date: 2009-07-03 07:08:00
|Re: How to use PHP for large projects?||#9|
Downvote wasn't from me since you asked.
posted date: 2009-07-03 07:17:00
|Re: How to use PHP for large projects?||#10|
It gives me creeps when somebody (still) mentions register_globals. Most of the new guys donno about them. Heaven's sake keep it that way.
posted date: 2010-03-25 12:13:00
|Re: How to use PHP for large projects?||#11|
I've had good experiences using CodeIgniter. I think it's just light weight enough so you can get down and dirty but also adds a nice MVC abstraction layer. Consider using Doctrine ORM with it. Example: http://pampersmybabyregistry.com
posted date: 2010-07-17 16:08:00
|select page: « 1 »|