Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Taking the Sting Out of PHP 5 Programming

ScuttleMonkey posted more than 8 years ago | from the agile-web-development dept.

PHP 159

bfioca writes "Where are the all-in-one PHP frameworks that make building well-factored and maintainable applications as easy as building simple sites? O'Reilly ONLamp's recent article Simplify PHP Development with WASP shows how to make a simple database-backed site with WASP in just a few lines of code. Other PHP 5 frameworks such as symfony and PRADO have been getting a lot of recent attention as well."

Sorry! There are no comments related to the filter you selected.

think of the kittens (-1, Offtopic)

Anonymous Coward | more than 8 years ago | (#14534512)

usermilk rules you

biggie smalls nigga fuck all yall

Good post (-1, Troll)

coastin (780654) | more than 8 years ago | (#14534520)

This makes up for the Google post.

Drupal? (3, Informative)

rjung2k (576317) | more than 8 years ago | (#14534522)

I don't claim to be a web architecture guru, but what's wrong with Drupal? [drupal.org] Open source, PHP 5-friendly, and does everything from vanity sites to corporate sites.

Re:Drupal? (3, Interesting)

albalbo (33890) | more than 8 years ago | (#14534550)

I think you have to hack it to get it to work multisite? Also, the URLs are pretty horrible.

That's not to say stuff like PRADO is any good either - I used it for a commercial site, and it's a pain to maintain. It's an ASP-style component system, and doesn't fit the web model - if you want to do 'Ajax', for example, you're screwed.

symfony looks interesting, though, and much more lightweight.

Re:Drupal? (2, Insightful)

rdean400 (322321) | more than 8 years ago | (#14534812)

I looked at the symfony site. Once I got to the HTML templates with embedded PHP, I closed the window. If I want to combine code with HTML, I'll use JSP or ASP - the component model and syntax are cleaner.

Re:Drupal? (3, Informative)

truthsearch (249536) | more than 8 years ago | (#14534894)

No, it takes no hacking to work multisite. I'm running 3 sites on one code base right now. The URLs are very short. There's nothing horrible about them. And if you turn on the right module you can automatically link to /title/page+title. Learn about an app before complaining about it.

Re:Drupal? (4, Informative)

kbahey (102895) | more than 8 years ago | (#14535850)

Disclaimer: I am a Drupal community member and developer.

I think you have to hack it to get it to work multisite?


Nope.

Drupal has multi site out of the box, and has been like that for years. For some 18 months, I ran 4 different domain out of the same code base and the same database even (with database prefixes).

Also, the URLs are pretty horrible.


Drupal boasts "clean URLs" out of the box as well. This means that urls do not have to be www.example.com?q=node/123 but rather www.example.com/node/123 (this requires mod_rewrite).

Moreover, Drupal has out of the box the path module which allows you to alias any page to any URL you like. There is also a contributed module (pathauto) that makes this totally automated.

Check my web site for examples (all URLs are aliased).

Re:Drupal? (0)

Anonymous Coward | more than 8 years ago | (#14534563)

The problem with these off-the-shelf content management systems is that they invariably have security flaws which are exploited.

Although security by obscurity is not the answer it certainly protects you against the 'script kiddies' out there.

As a programmer I always feel uncomfortable using third party systems because at the end of the day if I lose my job because of my own coding errors then fair enough, but if it's because I've used someone else's code in an effort to take short cuts it's a different matter entirely.

Re:Drupal? (2, Interesting)

WebCrapper (667046) | more than 8 years ago | (#14534672)

Couldn't agree more.

In the long run, I would rather write my own CMS than use someone elses. When I first learned PHP, I wrote my own system. Now that I'm older and less stupid, I realize how many security holes where in the application, but in the 3 years I used it, not one hiccup because it wasn't documented anywhere.

I messed around with Mambo (sorta, kinda, like Drupal) and really didn't like it. I hacked it a little to do what I wanted, but found it wasn't for me.

At the same time, I'm a little at a loss. I'm currently writting an OSS application and while I know there will be security flaws, I'm stuck on what I want to do with the data. Do I encrypt everything, have the option of a global storage DB (my DB, not the one people install the application on), etc... Too many choices and they could all, somehow, become a security issue.

Re:Drupal? (2, Informative)

carndearg (696084) | more than 8 years ago | (#14534592)

Drupal is a content management framework, these are application frameworks. In other words Drupal is the application and once you've installed it and whatever modules you need all you have to do is input your content while an application framework requires you to use it to write an application before you can think of content. Drupal is very useful if you want to do what it or one of its modules already does but it is less flexible for custom applications.

Re:Drupal? (1)

metaclous (884409) | more than 8 years ago | (#14536290)

That's ridiculous. Drupal is framework, and its default use is content management. If you want to use it as a custom application, its node system and aspect-oriented hook system make it extremely flexible.

Re:Drupal? (1, Informative)

arivanov (12034) | more than 8 years ago | (#14534596)

Looking at the frequency of attempted exploits for drupal holes on my website there is a lot wrong with it (I do not even have PHP installed). At least from security perspective.

Re:Drupal? (-1, Flamebait)

Anonymous Coward | more than 8 years ago | (#14534631)

Yes. I'm so sick of that goddamn unix crap filling up my IIS6 logfiles.

Attempts != Problem (2, Insightful)

truthsearch (249536) | more than 8 years ago | (#14534918)

So portscans of my Macs prove there are many Mac exploits? Drupal has had just a few very specific security issues, just like any other internet-based app. There are many thousands of drupal-based sites, so evil-doers have written scripts to hunt down and take advantage of those that haven't upgraded. Nothing here uncommon to any other system. My drupal referrer logs fill with thousands to requests for IIS-specific files, yet I've never run a site on Windows.

Re:Drupal? (2, Informative)

kbahey (102895) | more than 8 years ago | (#14535826)

You probably saw scans for the old versions of xmlrpc.

This was a third party library that we incorporated in Drupal a while back to do some remote stuff (e.g. remote blogging, ...etc.)

If you do not use third party client apps to post, you can delete the file xmplrpc.php altogether if you wish.

When it was discovered that it has security flaws, we replaced it completely.

Newer versions are as secure as they can be.

Re:Drupal? (-1, Flamebait)

outsider007 (115534) | more than 8 years ago | (#14536586)

I was wondering where all my hack attempts to xmlrpc were coming from, now I know. Thanks for the info and oh yeah, I won't ever be using your product, noobs.

Re:Drupal? (2, Interesting)

slashdotnickname (882178) | more than 8 years ago | (#14534623)

We actually tested out Drupal for possibly doing a customer's portal site last year. It had a lot of features and was quick to set up, but it was a nightmare to customize it beyond anything simple. I think it's a great product for non-techies to get something up with, but it's too restrictive for any complex business logic needs.

Re:Drupal? (2, Interesting)

truthsearch (249536) | more than 8 years ago | (#14534923)

If you want to do anything beyond things that relate directly to content management then Drupal's not a great option. In theory you could strip out most of the module and use it as an app framework, but you won't get gaining too much over writing your own foundation. Drupal is mostly specific to CMS needs.

Re:Drupal? (1)

tarquin_fim_bim (649994) | more than 8 years ago | (#14534916)

But does it work with PostgreSQL?

Just use Ruby or Python (0, Flamebait)

Anonymous Coward | more than 8 years ago | (#14534545)

The best way to take the *sting* out of PhP is to use Ruby or Python.

Re:Just use Ruby or Python (-1, Offtopic)

DaHat (247651) | more than 8 years ago | (#14534546)

What do you have againt .NET besides being a Microsoft technology and being a TLD?

Re:Just use Ruby or Python (2, Insightful)

onion2k (203094) | more than 8 years ago | (#14534714)

Currently I'd discount Ruby from any sizable web development as it's still very much a minority language and it'd be practically impossible, or outragously expensive, to hire a Ruby developer. If your development team or company vanish (run over by a bus, move to Australia, whatever) you need to be able to get someone else who can come in and maintain the code quickly. That just wouldn't happen for a site written in Ruby. Of course, it'd be fine for any small development like a homepage or a blog .. but PHP would be equally fine for such an unimportant venture despite it's shortcomings. To a lesser extent the same can be said for Python. There's a lot fewer Python developers about than PHP, but there are some.

Caveat: IAAPD (I Am A PHP Developer), so perhaps I'm horribly biased.

Re:Just use Ruby or Python (2, Interesting)

varanid (948040) | more than 8 years ago | (#14534882)

considering the forum in posting, I wouldn't be surprised if I was modded down, buut I signed up on slashdot finally just to make this my first post as a reply

while I agree its a niche language now, it won't be long I imagine till ruby ges more mainstream. The main thing holding ruby back so far has been a lack of books on the subject. hoowever, that is quickly changing and already ruby is more popular than python in japan.

caveat emptor: I've only been dabbeling in ruby for the past week or so

anyway, so far I rather like the language as it somehow manages to emain fairly concise yet readable unlike perl and as a language, I find it alot more powerful than php.

ruby + the rails network shhouldn't be dismissed just yet and php programmers would be wise to at least devote some time to learning ruby. I don't imain, assuming you knoow OOP, anyone would have much of a problem learning ruby, and it scales much better for large apps

note: I myself have used php extensivly in the past but I am now seriously considering going to ruby on rails as my nnew dev environment

Ruby has a steep learning curve (0)

Anonymous Coward | more than 8 years ago | (#14535060)

The thing about Ruby: it's so easy to learn. I'd say you could take some schmoe with experience in functional and OOP languages (Smalltalk, Lisp+Java, any other combination), and train them for Ruby development in two days.

Re:Just use Ruby or Python (0)

Anonymous Coward | more than 8 years ago | (#14535202)

Currently I'd discount Ruby from any sizable web development as it's still very much a minority language and it'd be practically impossible, or outragously expensive, to hire a Ruby developer.

Ah, but Rails people are always saying how it has made them 10 times more productive, so as long as they aren't ten times as expensive you come out ahead.

Re:Just use Ruby or Python (2, Interesting)

danharan (714822) | more than 8 years ago | (#14535450)

There are a lot more Ruby developers than Ruby jobs.

And they tend to be better developers too, those that enjoy hacking and being productive.

Re:Just use Ruby or Python (0, Flamebait)

Anonymous Coward | more than 8 years ago | (#14534732)

LOL... I'll take the "sting" of PHP over the "pounding hangover" of Python or the "intestinal cramps" of Ruby any day.

When I first started with PHP, I was able to make effective use of it very quickly. I enjoyed learning it and "got it" faster than I have ever gotten any other language. When I first looked at Python, I felt old, familiar, throbbing hangovers brought on by Perl returning. When I took a serious look at Ruby (actually Ruby on Rails) I realized that without learning Ruby itself, I'd never really master building a site with Rails. Learning Ruby is, to me, more of a hassle than it is worth. Heck, learning to use C was much easier than learning Ruby, IMNSHO.

Re:Just use Ruby or Python (1)

colinrichardday (768814) | more than 8 years ago | (#14534978)

Interesting, as PHP's syntax is closer to Perl's than Python's is. What about Python reminded you of Perl?

Re:Just use Ruby or Python (1)

hotfireball (948064) | more than 8 years ago | (#14535711)

How long is the largest chunk of code Larry Wall has written in Python? It was 23 lines longer than the largest chunk of code Guido has actually written in Perl. The difference is that Larry's code worked, and Guido's still doesn't...

Re:Just use Ruby or Python (1)

colinrichardday (768814) | more than 8 years ago | (#14536088)

I didn't know that Larry Wall wrote stuff in Python, or that Guido wrote stuff in Perl.

*Please* use Ruby or Python (0)

Anonymous Coward | more than 8 years ago | (#14534981)

LOL... You actually bothered to learn all those horribly inconsistent functions? is_null, isset? strtolower, hex2bin? strip_tags, stripslashes? strpos($haystack, $needle), preg_match($needle, $haystack)? Or are you accepting that looking at the docs every half an hour is normal?

PHP has a lot of shortcomings, and it's a shame that it's been marketed so well that people like you are so used to it that you can't be bothered to learn anything better. Will you still say how good PHP is when you've looked at the docs for the hundredth time, or tried to use Unicode, or use the wrong function? I doubt it.

To anyone else out there: PHP sucks. It has inconsistent function naming, no namespaces, far too many functions, next-to-no unicode support, catering to the lowest common denominator (who aren't expected to know how to escape a string (magic quotes) or use the query string arrays (register_globals (now deprecated, good))). Perl, Python and Ruby have none of these shortcomings. Learn something else - you'll appreciate it.

Re:*Please* use Ruby or Python (1)

baadger (764884) | more than 8 years ago | (#14535240)

LOL... You actually bothered to learn all those horribly inconsistent functions? is_null, isset? strtolower, hex2bin? strip_tags, stripslashes? strpos($haystack, $needle), preg_match($needle, $haystack)? Or are you accepting that looking at the docs every half an hour is normal?


With a manual as clear, conside and accessable as PHP's, who cares? There are hundreds of functions in the 'core', but not all of those in the PHP manual are compiled in on most setup's. Who really learns the libraries and functions of any programming language by heart? Familiar and aware of? Yes. Memorise? No

I know a fair bit of Python and know Perl well. PHP simply cuts Python up when it comes to easy to use documentation regarding web development. Perl is well documented and my current preference for webdev.

Re:*Please* use Ruby or Python (1)

imroy (755) | more than 8 years ago | (#14535351)

With a manual as clear, conside and accessable as PHP's, who cares?

I haven't looked at the PHP docs for a while now, but one Perl programmer made up a table of PHP functions [tnx.nl] that even PHP programmers find useful! That page also has a *lot* of good comparisons to Perl. It's amazing how much baggage PHP has accumulated over the years.

Re:*Please* use Ruby or Python (1)

hotfireball (948064) | more than 8 years ago | (#14535673)

Yeah. Now is good time to throw ~70% of it...

Re:*Please* use Ruby or Python (2, Informative)

Parham (892904) | more than 8 years ago | (#14535650)

This is the one point I have to agree with. PHP has great documentation (with loads of comments). I had to learn Python in school and to this day I still can't browse around the documentation properly without getting frustrated. Python is a great language, it enforces great structure and readability, but the docs for it are incredibly annoying.

Re:*Please* use Ruby or Python (0, Flamebait)

rbanffy (584143) | more than 8 years ago | (#14536155)

To put it shortly, PHP is VB3 for the web.

Re:Just use Ruby or Python (2, Insightful)

CoughDropAddict (40792) | more than 8 years ago | (#14535798)

If your programming immune system immediately rejects any language that is more mindbending than the simple if/while/for/switch/function constructs of C-like languages, you will forever be a pretty naive programmer.

As an example, JavaScript has OO, but no classes! How do you suppose that is? It's prototype-based OO. It's an interesting alternative to class-based OO. Well-rounded programmers can pick up a concept like that rapidly -- they don't just say "this is too much of a hassle."

The basics in Ruby are no harder than C or PHP. Things only get more difficult when you start saying things that simply cannot be said in C or PHP.

KILLER BEES!!! (1)

GET THE FACTS! (850779) | more than 8 years ago | (#14534549)

KILLER BEES!!! [lemonodor.com]

i wanna be somebody (-1, Offtopic)

Anonymous Coward | more than 8 years ago | (#14534570)

be somebody too

Bogus (4, Insightful)

Anonymous Coward | more than 8 years ago | (#14534612)

Give me a break, depending on such things is terribly bad for maintainable code. Exactly the opposite of the billing given above. Will code written with it be compatible with PHP 6? How long after PHP 6's release will such tools be made compatible? If you need tools to simplify php coding, you might as well just forget it.

If you want a quality product, there are no shortcuts. There is no such thing as a free lunch.

A big thumbsdown on this kind of crap. "Sting" to PHP 5 programming? Get real.

Re:Bogus (3, Insightful)

afd8856 (700296) | more than 8 years ago | (#14534702)

You are either ignorant to what a real open source framework would represent (limit code reinvention, benefit from community effort, etc) or are not in the target group of such a framework (maybe you work for a big company that has a large programming team, who knows).
Either way, I can tell you that, from my personal experience, learning and adopting a framework in your work can have a lot of benefits, for me, as a small custom business solutions provider.

Re:Bogus (1)

Nigel182 (948029) | more than 8 years ago | (#14534827)

Yeah, what a horrible idea to establish a framework that can standardize the code in multiple projects and code written by multiple people in the same project. It's better to start from scratch every time so that everyone's code works differently. Then when it comes time to maintain the code, you get to figure out the application's structure for each project and hopefully each person's code who worked on the project!

Re:Bogus (0)

Anonymous Coward | more than 8 years ago | (#14535414)

Too right - I completely agree. There is NO STING in PHP 5 programming. Using a framework solves a non-problem in an obscure way. Tired of rewriting code - simply use PEAR [php.net] .

Languages like Ruby need a framework because:

  1. There are few web-centric functions available
  2. They run as persistent processes (via FastCGI)
  3. There is an obvious need for model-view-controller
If you want MVC in PHP, it's piss easy to write it yourself. In fact everything in PHP is piss easy! Frameworks? No thank you!

Re:Bogus (-1, Troll)

heinousjay (683506) | more than 8 years ago | (#14535915)

You PHP trolls are so cute, with your crappy code full of security holes, barely performant under load even though you run on a blazing fast interpreter. Keep playing with your training wheels, and stay away from us big boys on our Harleys, please.

Re:Bogus (1)

DavidHOzAu (925585) | more than 8 years ago | (#14536482)

You PHP trolls are so cute, with your crappy code full of security holes, barely performant under load even though you run on a blazing fast interpreter.

And I'm sure Chinese is better than English, too. All of us english-speaking people are so limited with only 26 letters to play with.

Oh puhleeze, both are programming languages! , and they can coexist together if you do it right. True hackers don't care what language they program in, they adapt. If the-other-side in the Php-or-Perl issue offends you that much, perhaps you should start thinking in algorithms rather than whatever-language-i-am-coding-in.

Re:Bogus (0)

heinousjay (683506) | more than 8 years ago | (#14536565)

I'm not saying anything about the language, just the code I've seen written. It's the price of being immensely popular - you get a lot of slackers who can't code worth shit.

So basically, I agree with you, and still hold my opinion.

Re:Bogus (0)

Anonymous Coward | more than 8 years ago | (#14535428)

The only point I see in this is the php 6 comment. Given the php history of breaking code between releases, I think he has a valid point. If you write a java based site and then upgrade from 1.4 to 1.5 it will still run. .NET 1.0 code runs on .NET 1.1 as well. Also, open source tends to change apis in general. If you start with a framework today, you may need to either rewrite good portions to remove the framework when your sysadmin wants to go to php6 for security reasons or port your app to the new framework which may require several hours of coding as well. There's maintaining software and then there's rewriting portions when you shouldn't need to. PHP people like to encourge both.

What about PHP using HOOD? (1, Troll)

dotslashdot (694478) | more than 8 years ago | (#14534620)

For the rest of us hip hop inclined programmers, there is PHP using HOOD (Hizous Object Oriented Development) in case you get tired of the WASP crowd.

I don't see the magic words MVC... (4, Insightful)

aphexddb (87610) | more than 8 years ago | (#14534621)

JASPF (Just another silly PHP framework)

If you are looking for quick app development and you aren't joe home user making a website you are going to need something thats based off a model -> view -> controller architecture. Symphony does this, so does the cake [cakephp.org] framework.

I need PHP (1)

Charbax (678404) | more than 8 years ago | (#14534640)

I want to make some original PHP apps on my websites but I still don't know PHP. So it would be great to have some GUI application or something that let's me realize a PHP/MySQL application just out of a database model that I would draw and some specific actions specified. So I am checking these solutions out, and if someone has more solutions for me that would be great.

Re:I need PHP (1)

yddod (778690) | more than 8 years ago | (#14534717)

Who fixes the bugs?

Re:I need PHP (0)

Anonymous Coward | more than 8 years ago | (#14536530)

Who fixes the bugs?

Me.

Re:I need PHP (4, Insightful)

killjoe (766577) | more than 8 years ago | (#14534870)

So let me get this straight. You don't know PHP, you don't want to learn PHP but you want use PHP to build some web apps. Did I get that right?

Seems like a fools errand to me. I predict you will fail miserably and your web site will be hacked within 24 hours of you putting it up.

You really should learn the language that you are trying to build web sites in.

Re:I need PHP (0, Troll)

Charbax (678404) | more than 8 years ago | (#14534932)

I think it should be possible to have a GUI application, that let's the user design a database. Then this GUI let's the user assign some functions between each table of the database. And at last define the .php pages and design them with Wysiwig. Lastly the .php files are uploaded to the server and it should work! That's what I am looking for. But for now I will try cake, prado and symfony and see what I can do with them.

Re:I need PHP (2, Informative)

hazah (807503) | more than 8 years ago | (#14534997)

Look, unless you are able to at least glue these components with SOME code, you aren't going to get anywhere. Just forget about it, because such an elaborate GUI does NOT exist. GUI isn't your solution either, since you don't understand the fundamentals of the problems you are trying to solve. Sorry, but you're either going to have to hit the books, or pay/convince someone else to do this for you.

Re:I need PHP (3, Funny)

Charbax (678404) | more than 8 years ago | (#14535051)

I think I understand the fundamentals, I just don't know PHP.. I can design a database, and I can understand the kind of interaction there needs to be between the tables. Imagine a GUI, first step design a database, with tables and relations. NExt step, you can define some tables as some standard ones, like "username" or "password". Then choose the actions that the PHP pages will do and include, for example the username and password box. And then define on the "logged-in" php page what can happen from which tables. Imagine such GUI that does not create every advanced PHP system, but is advanced enough to design ones own Digg.com kind of system, own search, own custom cms, members area, digital files store and lots of stuff like that. It will generate the php pages and it will be possible to view source and edit them to cutomize them..

Re:I need PHP (2, Informative)

Magic5Ball (188725) | more than 8 years ago | (#14535243)

Macromedia/Adobe Dreamweaver has *limited* support for what you describe (table views [kind of], forms, db updates, page layout, and maybe cookies). You still won't be able to design digg.com with zero understanding of how PHP and web apps work though, regardless of how good the tool is.

Also, your understanding of databases and interfaces needs to be more sophisticated than building a contact manager in MS Access...

Re:I need PHP (1)

Charbax (678404) | more than 8 years ago | (#14535283)

I don't know about contact manager in m$ access. I just surfed around and google tells me about: BigProf AppGini 3.01: "It converts your database structure definition into a powerful PHP application that connects to MySQL database. It creates HTML forms for handling your data and all the PHP scripts behind them." http://www.download.com/AppGini/3000-2210-10070978 .html?part=dl-AppGini&subj=dl&tag=button [download.com] PHPMagic: " Automatic PHP code generator to manage the data of MySQL databases. The very intuitive graphical interface of PHPMagic allows you to create powerful web database applications in a very short time." http://www.websitedatabases.com/download.html [websitedatabases.com] I will see if one of those will let me do a new digg-like application for my website.. Or maybe I might go back and try Dreamweaver again, though I doubt it's able to do the php stuff that I need. Thanks!

Re:I need PHP (1)

hazah (807503) | more than 8 years ago | (#14535449)

I don't think you are listening. What you want is a *dream*. It is not something that has been developed. Believe me I looked. I am developing with the same techs. you describe and I would love a few short cuts. I found them, they are called libraries. You still have to write code. Period. Propel + phphtmllib are very powerful. Many standard pear packages are definately a boost. But the bottom line is that these neat components need glue code.

Re:I need PHP (1)

Charbax (678404) | more than 8 years ago | (#14535495)

Okay thanks, I hope not.. I have looked a bit more and found a couple more applications that generate PHP, hopefully one of them realises my dream: phpCodeGenie: "Just design your database tables and phpCodeGenie can write the php scripts and programs for you." http://www.hotscripts.com/Detailed/20039.html [hotscripts.com] dsQwikSite: http://www.dbqwiksite.com/ [dbqwiksite.com]

Re:I need PHP (1)

Geoffreyerffoeg (729040) | more than 8 years ago | (#14535459)

Why don't you learn PHP?

If you know some programming already (even BASIC will suffice), then you can pick up PHP. If you know C++, even better. If you don't know programming, step away from the PHP and go learn something that won't let people hack your websites (and even if you don't get hacked, will allow your website to keep running in the meanwhile).

If you don't know HTML...uh...make sure you're comfortable with it before starting, because it's almost impossible to make a useful webpage if you can program everything but can't output it.

Save this as a .php file and run it on your server:
<html><body>
<h1>Multiplication table</h1>
<table>
<?php
for ($i=1; $i<=10; $i++) {
  print "<tr>";
  for ($j=1; $j<=10; $j++) {
    print "<td>";
    print $i * $j;
    print "</td>";
  }
  print "</tr>";
}
?>
</table>
</body></html>
There you go, you can see the syntax of PHP now. If you want to use databases, make sure you know SQL first (e.g., "SELECT first_name, last_name FROM customers WHERE age<18"), and then you can use the following commands for MySQL: mysql_connect, mysql_query, mysql_result. For the manual, see php.net. If you're not using MySQL, the commands are similar for other database versions.

Re:I need PHP (1)

niteice (793961) | more than 8 years ago | (#14536017)

You mean something like Microsoft's Visual Web Designer. Unfortunately, that still requires you to know some VB or C# to make stuff happen. Fortunately, you don't need to learn all the ASP controls, as VWD lets you drag controls onto a page and it generates the proper HTML. You only need code to associate actions to the controls, as opposed to also generating the controls like in PHP. Heck, it'll even play nice and make XHTML 1.1. Very handy stuff.

SNOOP development? (0, Troll)

dotslashdot (694478) | more than 8 years ago | (#14534657)

And don't forget SNOOP (SNoop Object Oriented PHP) for the rest of the hip house crowd who doesn't like the Country WASP crowd.

Re:SNOOP development? (0)

Anonymous Coward | more than 8 years ago | (#14534772)

SNOOP? You gotta check out HIZzleOOPfizzle (Highly Integrated Zoned Object Oriented PHP). It's off the teezy. Cheddah!

Sting? (1)

shiznatix (924851) | more than 8 years ago | (#14534767)

Taking shortcuts is just a bad idea. At my company we call shortcuts being 'lazy'. Just do it right without trying to lean on somthing else to help you out. It is just a couple more { and } to make your code work for soon-to-be versions of PHP without this garbage. Also, what is this 'sting'? Find it hard to use some OOP? If that 'stings' you then maybe you should not be coding in PHP. Moral of the story: being lazy will produce bad code that needs to be delt with in later versions of PHP. Save yourself the time now.

Facetious (1, Insightful)

Anonymous Coward | more than 8 years ago | (#14534875)

What company do you work for? If you were writing an enterprise Java application, for example, would you call using Spring or Hibernate "lazy"? Also, what makes you think that this code isn't forward-compatible? It's just a few files of normal PHP code, automatically generated from XML manifests, from what I gather. Finally, what makes you think they even need the code to work in the next iteration of the language interpreter? If they're a contractor that gets paid and bails before anything breaks, then using even the shoddiest frameworks will indeed "Save yourself the time now."

Using a Framework for YOUR applications!? (1)

Archi87 (946032) | more than 8 years ago | (#14534794)

If you simply want a site with some 0815 stuff (like a Guestbook, News, Articles, Photogallerie) use PHP-Nuke [phpnuke.org] and try to create you're own template (or ask a friend to do it for free).

If you want to create anything else (like a corporate site with support system [ticketbased], shop [enduser and reseller], productinfo,... or a browserbased) do it yourself or have a company done it ;-)

And if you really want to stick to a framework - create your own framework :D


Sebastian (using his very own framework AdvFW2 v0.3.9 since 2 years [but it's php4-based because I use it for projects I do for friends for free])

Never ever use PHPNuke (2, Informative)

NoSuchGuy (308510) | more than 8 years ago | (#14535413)

Bad security by default.
Read here. [google.com]

I should think so too. (3, Funny)

afernie (915570) | more than 8 years ago | (#14534796)

Sting has had his finger in entirely too many pies since The Police broke up...

Taking the sting from PHP coding (0)

Anonymous Coward | more than 8 years ago | (#14534848)

Oh that's really easy, anyone with a clue for code can tell you that one. Can you say "Use XML"? I knew you could....

Modern web programmers have moved elsewhere (1, Offtopic)

a55clown (723455) | more than 8 years ago | (#14534880)

I remember a time when PHP was the next latest and greatest thing. Then MySQL tied into it which made it all the more better. Lately, however, a lot of programmers have moved onto Ruby on Rails. It almost seems like magic at the speed at which you can make useful stuff.

Re:Modern web programmers have moved elsewhere (1)

ooh456 (122890) | more than 8 years ago | (#14534951)

I for one am sick of ROR people on this site slamming PHP.

Like I am gonna learn some new language because a bunch of trolls spam post to every PHP article.

Re:Modern web programmers have moved elsewhere (1)

a55clown (723455) | more than 8 years ago | (#14535002)

i'm a php coder, fyi, and haven't had time yet to learn ruby on rails. i'm just putting it out as an alternative to php. i have yet to find a decent framework that can produce useful web objects as fast as ruby on rails.

i'm sure you've seen the video - reminds me of a console version of every single vba demonstration i've ever seen.

Re:Modern web programmers have moved elsewhere (1)

ooh456 (122890) | more than 8 years ago | (#14535185)

Sorry if i've unfairly vented my anger. It's just that every time someone posts a good PHP article I have to wade through a million ROR posts.

Re:Modern web programmers have moved elsewhere (0, Insightful)

Anonymous Coward | more than 8 years ago | (#14535235)

When your app isn't just a simple CRUD tool, your perception of RoR may change. To replicate the functionality of my PHP app, I would end up with almost as much code as I already have. And for that small benefit I would be locking my employer into a still-rare language. Listening to RoR zealots, you'd think that it takes a year to build a web form by hand. Web apps took off because they were simple, people...the only difference now is that we have people screaming that everything needs to be OO and not reusing code wherever possible is blasphemy. First the "real" programmers ignored web apps, then they ridiculed them, and now they're fighting them with rotten frameworks that don't do what we need. Web apps of the simple sort that have made the web what it is have already won; the zealots just haven't realized that yet.

Re:Modern web programmers have moved elsewhere (1, Interesting)

GigsVT (208848) | more than 8 years ago | (#14536456)

Excellent post.

I have read the tutorials for Ruby on Rails and some of the PHP frameworks that rip it off. It seems like a hell of a lot of work just to avoid writing a few lines of code.

We are developing a CRUD-only framework at work, sort of in homage to this current fad, but ours won't be OO, and it won't keep you from having to write code either. It sure as hell won't use XML for anything. We might release it as free software after we see how well it works out.

I don't know why all these framework sites talk about how much fun it is to develop with their framework. What ever happened to being maintainable or scalable or even useful? "Fun" isn't a quality I generally look for in my programming tools.

Re:Modern web programmers have moved elsewhere (1, Troll)

GigsVT (208848) | more than 8 years ago | (#14536362)

Lately, however, a lot of programmers have moved onto Ruby on Rail

No, they haven't [tiobe.com]

You are buying into the hype. Apparently a miniscule but vocal minority of people have even heard of Ruby on Rails. Most of them seem to read this site.

It will not matter Google. (1)

agent (7471) | more than 8 years ago | (#14534886)

They shoot first, and ask questions later.
I will now take this time to help out the Feds for you.

"long dong silver"
"Fox news"
This one is for Laura "Literacy"

By the way, I am not your "customer".

Missing the point! (1, Insightful)

Anonymous Coward | more than 8 years ago | (#14534936)

By demonstrating that it is possible to create and use complicated, "enterprise-class" frameworks effectively in PHP 5, WASP will help more developers make the switch.

Complicated? I didn't realize that complicated frameworks were the pinnacle of modern software development. Here's a newsflash: PHP is popular not because of its rigid structure, nor the availability of misguided "frameworks", but because it allows people to solve problems in a flexible way with little overhead. Yes, a lot of people take it too far in this direction and turn their code into a disaster area, but others manage to build maintainable, useful apps without obsessing over whether or not their program fits into a particular "model". In addition, future maintainers of these apps won't have to read manuals about how to use the framework of the day to make changes. Strict interpretations of pseudo-standards or the use of mind-bending frameworks do not help to develop applications faster, or even better.

I wonder how many "enterprise-class" applications fall flat on their faces because the frameworks on which they are built are not flexible enough to support what their users really need. I know it's happened where I work, and the answer "oh, the framework doesn't support that" led to the success of other projects that came out of nowhere and took hold because they met the demands of users as opposed to the technical demands of project managers. In the real world, a simple PHP app may very well push an "enterprise-class" and "three-tier" monolith out of its way if it does what the users want.

Like Zope? Does anybody use this stuff? (1)

walterbyrd (182728) | more than 8 years ago | (#14535047)

Zope is supposed to be some great product. But, when I do a search for Zope on dice.com, I might get one hit.

I get the feeling these php frameworks might be even more obscure.

Now, compare that to a product like ColdFusion.

I don't use any of those products. But, I've got to wonder.

Re:Like Zope? Does anybody use this stuff? (0)

Anonymous Coward | more than 8 years ago | (#14535556)

What is there to wonder about? Zope programmers are productive and happily employed, thus there are fewer job postings. ColdFusion developers are useless fuckwads who can't hold a job, so companies are always looking for someone to take over their buggy ColdFusion apps.

I also rolled my own farmework and... (1)

AnthongRedbeard (948052) | more than 8 years ago | (#14535166)

I have my own framework I've used for several years now and slowly upgraded. I enjoyed writing it because it forced me to learn the principles of what all the other frameworks were doing. I couldn't understand why people wrote frameworks the way they did until I ran into the same situation. However, I made some significant apps with my framework that companies are using and I found myself writing lots of documentation on them and brushing up the comments... It would have been great if I used published and documented framework just so I wouldn't have to do the tedious stuff for other people to ever maintain it.

a framework is NOT a shortcut (or a CMS!) (4, Insightful)

webwright (910240) | more than 8 years ago | (#14535222)

I tear my eyes out everytime someone calls a framework a "shortcut". Usually they follow it by "There's no substitute for good coders writing good code." The business reality is that most coders are not exceptional, and some are pretty lousy. You can spend all of your budget on human resources finding epic-quality coders (and then scratch some more to come up with their epic-salaries) or you can do what the rest of the world does-- get the best programmers they can find and afford. A framework helps un-exceptional coders write better (and more consistent/maintainable) code. This arguments seems akin to saying "forget word processors! Just get someone who can make Vi or Emacs dance and turn 'em loose." It seems to me that the evolution of software is pretty much the act of layering increasingly-smart frameworks on top of machine language to allow high quality results more accessible to more people.

Stupid article, obfuscated and biased examples. (1, Interesting)

Anonymous Coward | more than 8 years ago | (#14535288)

This article appears to be written for fools. One of the author's examples of WASP's superiority is that this:

<li flexy:foreach="arTasks,key,task">{task[Name]} - <i>{task[Due]}</i></li>

is better than this:

  <?php
        $arTasks = array();
        foreach ($arTasks as $key => $task)
        {
  ?>
                <li><?php echo $task['Name']; ?> - <i><?php echo $task['Due']; ?></i></li>
  <?php
        }
  ?>

Because "Already you can see one of the biggest benefits of working with WASP: no need for embedded PHP code."

Well, it might look that way, because he deliberately coded the PHP version in the messiest way possible. He could have simply done this:

<? foreach ($arTasks as $key=>$task) { echo '<li>' . $task['Name'] . '-<i>' . $task['Due'] . '</i></li>'; } ?>

The WASP sample doesn't look so much better now, does it? Not so much so that it's worth downloading some unknown framework and inheriting someone else's bugs and execution overhead and security holes?

PHP for the enterprise? (-1, Flamebait)

Crazen (615089) | more than 8 years ago | (#14535327)

It's a horrible trend to see scripting languages with loose typing (e.g. a variale can be a string or a number) and poor OO implementations trying to passed off as "Enterprise" class application development platforms. The "P" languages mean crappy maintainability and scalability. Although if you don't have a qualified empowered architect on hand, and outsource most of your development, pass it off to tradesmen instead of engineers or hire a team of fresh students right out of school, I guess this is better than the alternative.

Re:PHP for the enterprise? (0)

Anonymous Coward | more than 8 years ago | (#14535385)

Wow, you know you might be right. Maybe that's why Yahoo switched to PHP a couple years ago. hmmm

actually, the "sting" of php5 is... (2, Insightful)

acroyear (5882) | more than 8 years ago | (#14535355)

the fact that because of all of the php-4 compliant code that it breaks, few ISPs doing web hosting services are in any hurry to upgrade because too many customers simply don't have the time to rewrite their applications to be compliant with php-5, much less take advantage of any or all of the new features.

this is hitting me hard as i'm trying to put together an xml-intensive app and am stuck using home-grown open-source XML parsing and generating packages, mostly unfinished, that won't be finished because they've been superseeded by the php5 libraries that i can't use yet.

Re:actually, the "sting" of php5 is... (1)

GigsVT (208848) | more than 8 years ago | (#14536390)

I'm not sure what sort of compliance you mean.

Our 15,000 line app went from PHP4 to PHP5 with very few changes.

Unless you are relying on very legacy things that have been depricated throughout the PHP4 tree, you should have nearly no problems.

Zend Framework (0)

Anonymous Coward | more than 8 years ago | (#14535386)

There's also the Zend Framework, to be released soon:

http://shiflett.org/archive/171 [shiflett.org]

What About Molins... (1)

bet0x (948063) | more than 8 years ago | (#14535417)

Molins is a framework for PHP5, inspired in Struts, but also it have a lot of features of other sub-projects of Jakarta, like Torque or Commons (FileUpload, etc). Integration with Smarty, and classes for logging, testing, etc. It's 200% object oriented. Come, take a look at http://sourceforge.net/projects/molins/ [sourceforge.net] ;)

What's problem? (1, Flamebait)

hotfireball (948064) | more than 8 years ago | (#14535583)

PHP coders really needs some framework. Because I don't realize how else they can work with the "technology"-like thingy which has bad recursion, lots of not-thread-safe stuff, poor OO, hell slow interpreter, no namespaces, non-standard date format, 4x more built-in functions than Perl (however the functionality of them just same), inconsequent function naming convention and no unicode so far. For those who dislikes Python and likes PHP, I would like to offer one experiment. Please do the simple task: make array of arrays of dict of dict of array of dicts structure (you may feel free to make it slightly other) and then try to change/replace/remove/add and compare each element of any place. Afterall compare perfomance and readability of the code.

Livepipe! (1)

Azound (205506) | more than 8 years ago | (#14535627)

Don't for PHP Livepipe!

It's a PHP5 framework for web developers that was recently released and looks promising.

http://livepipe.net/ [livepipe.net]

php5? i'll bake another cake better... (0)

Anonymous Coward | more than 8 years ago | (#14535737)

http://www.cakephp.org/ [cakephp.org]
check its Object class implementation... for php4

Framework Soup (1)

Tablizer (95088) | more than 8 years ago | (#14535843)

I've found that the best way to build a framework is to figure out the style of the company/organization in question, and then slowly build up a framework that fits over time. And, don't make your code married to the framework, just date it. Leave ways to code around it if it does not fit a particular situation.

For example, here is a simple set of functions to format a typical data entry form with title on the left side and input box/item on the right. If you want to code HTML directly instead of use the helper functions, you can. Thus, you get a shortcut, but not one that is forced on you.

    formHeading("My Sample Form", formName)

    rowStart("Name")
    {input type=text name="myname"} // HTML
    rowEnd()

    rowStart("Date")
    {input type=text name="mydate"} // HTML
    rowEnd("format mm/dd/yyyy")

    rowStart("Category")
    {select name="mycat"} // HTML ....

    formFooter(...)

(Curly braces used instead of angle braces (HTML)here to avoid slashdot edit conflicts.)

Re:Framework Soup (1)

Jerf (17166) | more than 8 years ago | (#14536030)

I think you're right. I've been around the loop a few times now, and I've examined any number of frameworks. I've used a few, but more often, I've rolled my own.

The big advantage of frameworks is they make the things the designer wanted to make easy, easy. The problem with frameworks is they make things the designer never thought of or never wanted either harder than it would be to do it directly, harder than it should be, or, in the worst cases, flat out impossible.

I've found that for larger projects, the disadvantages frequently outweigh the advantages.

I'll still use components here or there, but anything claiming to be an all-in-one approach is genarally more trouble than it's worth for anything over a couple of man-years*. Web frameworks are damned easy to build, as you can witness by the proliferation of them.

If I was knocking up a personal website, I might use a framework of some kind. But for anything serious, they're just so often a source of more trouble than gain after the first six months.

One of the reasons this work is that your local, custom framework can be "instantiated lazily"; you only add things as you need them. Framework purveyors have to work very hard to cover a lot of cases, you just need to cover the ones you use. With decent unit testing (don't leave home without it!), you can end up with a radically simpler system that works for you, rather than you working for it.

(*: Yes, yes, "mythical man years". The phrase can still have meaning.)

Taking the sting out? (1)

Tony Shepps (333) | more than 8 years ago | (#14535893)

I know PHP has matured as a technology when people feel it's painful to use.

I realize that programming languages are supposed to be painful, but for me, PHP 3 made programming fun again. As a sysadmin sort it was remarkable to be coding and enjoying it. This seemed to be true no matter whether it was a 10-line hack to get something done on a website, or a top-down structured project.

And you know when then turnaround happened? When PHP stopped being fun? I have an opinion. I think it coincided with the discovery that global variables were found to be harmful. Suddenly this thing which had so much instinctive power, required the use a system array with a specific syntax.

Simple example (1)

sabit666 (457634) | more than 8 years ago | (#14536068)

Why do they always have to go with `simple' example?? Why not go into some depth and show a moderately big project with some complex feature implementation?
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?