This tutorial is part I of a three-part series (part II | part III) that takes you from the most basic PHP script to working with databases and streaming from the file system by documenting the building of a document workflow system.
This tutorial is part I of a three-part series (part II | part III) that takes you from the most basic PHP script to working with databases and streaming from the file system by documenting the building of a document workflow system.
How does this relate to OSnews? I would expect to see this on devshed or something.
Whatever you do don’t learn PHP. It’s now worth it, LIVE! No but seriously, don’t do it. There are mutch beter solutions to web programming then PHP. What’s so bad? Well for starters read this:
http://spyced.blogspot.com/2005/06/why-php-sucks.html
You can fined lots of other rants if you want to. I would recomend Ruby on Rails, not only can you avoid doing any back end PHP, you can also avoid doing any frontend JavaScript!
I agree with this as Ruby on Rails is a framework and PHP is not(be aware that I’m generalizing a little). I would like to see the future as RoR+JS+Postgres(note: I barely use RoR but my limited experience was positive enough that I’d really like to ditch PHP and based on what I’ve heard from other people it’s a good way to go).
Just that you don’t think there isn’t any information on Ruby on Rails, I give you:
http://www.onlamp.com/lpt/a/5546
http://www.onlamp.com/lpt/a/5641
No but seriously, don’t do it. There are mutch beter solutions to web programming then PHP.
Why don’t you provide some examples instead of linking to someone else’s rant site?
(my guess is because you’re unoriginal and simply get YOUR opinion from someone else’s)
The author of said article says things like:
$a = array(array(‘foo’ => ‘bar’));
foreach ($a as $item) {
$item[‘new key’] = ‘new value’;
}
print_r($a);
This, of course, changes $a not at all, because the assignment to $item is a deep copy. (It’s also slow as hell if the items you’re deep-copying are substantial.) The workarounds for this are truly ugly.
This changes completely in PHP5, which is a good thing, unless you’re trying to upgrade an existing body of code. That’s not a small “unless;” if you weren’t using PHP4, there’s really no excuse to start out in PHP5 instead of Spyce or CherryPy or Rails.
This would leave you to believe that in PHP5, when you do a foreach it behaves differently and is backwards incompatible with PHP4. This is most definitely not the case.
Also the author seems to throw around data structures like he knows something, and he may well, but he doesn’t know ANYTHING about PHP internals. He hasn’t researched them, he’s just guessing. When he talks about “deep copies” in foreach loops, he’s 100% wrong.
PHP uses “copy-on-write” with references so when you loop through a large array of data it is in fact looping over THAT VERY ARRAY, it’s just that on WRITE a new variable is instantiated as a copy. The performance on foreach()’s is just fine.
Really, the only major difference between reference passing in PHP5 is that Objects are passed by reference by default now, which was not the case in PHP4.
Also, 99% of my PHP4 code has always been compatible with PHP5, even if it does raise some “strict” notices.
The author of that article obviously doesn’t know PHP as well as he thinks he does, and I would wager neither does the original poster.
Actualy I started with PHP, wan’t to bad wasn’t to good. But over all not my thing, tried to CherryPy since Python is my main langauge, nice but with something like 20+ frameworks geting hosting set up suckes and I haven’t found one for me yet. Looked at Ruby, interesting language, heared about Ruby on Rails, might use it, heared about the AJAX layer that dose the Javascript for me SOLED!!!!
I’ve got my reasons to chose what I chose. I like the beter is beter tool set. You like the worse is beter. Good for you, you think I’m an idot good for you, you think I care…
Can you translate that into english for us?
It was English. It was even understandable if you figured out where I accidentally dropt letters or words. Fact is I’ve tried PHP and know why I don’t like it. Fact is I’m a Python guy. Fact is that the web programming situation in Python at the moment is not ideal. And last but not least, fact is that I have found in Ruby on Rails that witch I’ve been missing in PHP and Python for web programming. This and nothing else is what my previous, hasty post tried to convey.
If you can’t read that I can’t help you.
PHP certainly doesn’t scale as well as Ruby on Rails, etc., but it isn’t entirely worthless. On the contrary, I’ve found it rather useful for simpler tasks (though there’s some overlap here with newer, ugly W3C technologies) and for XML parsing. Other solutions certainly are superior for larger tasks, but PHP has a niche.
The farthest I’ve gone with Ruby was installing the interpreter once, so don’t take this as scientific fact or gospel or anything.
The main (and probably most significant) difference between PHP and Ruby is that 99.9% of the hosting companies you can use out there support PHP. I don’t know what Ruby on Rails support is like, but I’m guessing it is significantly less.
Most people who learn PHP do so for simple, dynamic web sites. They aren’t creating web-based space shuttle diagnostic software with it. PHP scales just fine for most of the things people throw at it.
Syntax! People get used to everything looking like C they gloss over the exeptions.
Ruby:
http://rubyforge.org/cgi-bin/viewcvs.cgi/freeride/freebase/lib/free…
PHP:
http://cvs.sourceforge.net/viewcvs.py/phpmyadmin/phpMyAdmin/librari…
So, what would you rather look at for long periods of time?
Ruby:
http://rubyforge.org/cgi-bin/viewcvs.cgi/freeride/freebase/lib/free…..
PHP:
http://cvs.sourceforge.net/viewcvs.py/phpmyadmin/phpMyAdmin/librari…..
So, what would you rather look at for long periods of time?
Well, I’m a PHP coder, and I have never coded in Ruby so my opinion will be biased if I say I’d rather look at the PHP snippet
Truth be told? PHP. The Ruby code looks too wordy.
Also, I have a really hard time reading Ruby because of the way the code blocks are structured. I used to be a C programmer, so I guess I’m accustomed to that style and I like the curly braces.
The only language I really like that doesn’t use the C style syntax is Python. I think it is one of the most beautiful languages to look at.
Here is another tutorial for beginning PHP that does not require a registration.
Sort of funny that the site is ASP, but it seems like a good tutorial.
http://www.w3schools.com/php/default.asp
I’ve used PHP for about 5 years – very solid, and was able to do a lot with it. Mostly db-backed web sites.
But it’s a pain to make “CRUD” style applications – edit, update, delete data. I’ve been playing with Ruby on Rails since last December, and it is leaps and bounds ahead of Php. It is extraordinarily easy to build db apps with it.
I got a book on building PHP e-commerce sites last winter. It is very well done, and the code was factored out into the proper MVC components. And it was enormous – a ton of code to do updates, to handle grids. It just wasn’t worth it to implement for me. Rails literally cut the code from the book by 80%, while maintaining the MVC framework. Books are already coming out for Rails, so check them out and compare to php…
Whether Ruby is a good solution from a technical point of view isn’t important to many people who have to run their applications on hosting services since many hosts don’t have Ruby available. So they are stuck with php or perl.
There is a list of available hosts on the Ruby on Rails site. Rails is gaining in popularety right now, in no time there will be enough hosting availabe. I think in a year it’s probably going to be just as popular as PHP.
Someone posted a rant about PHP. It isn’t perfect, but it isn’t nearly as terrible as people think. For example, things like magic quotes and register globals can be easily set on an application basis with an ini_set.
The reason PHP has become so big is because it does everything web without much fuss. Wanna query mySQL, just call mysql_query(). No modules or anything. It’s just really simple and the configuration is pretty consistant across all of the cheap hosts out there. If I develop a Python application and want to sell it to a group that needs a web page, but doesn’t have a lot of money and doesn’t desperately need it, I can’t. With PHP, I can because of its near-universality. That’s not really a function of tha language so much as it is a function of market forces which seem to have blessed PHP.
Ruby on Rails is a framework. A very nice one, but you can’t compare Rails to PHP. Compare Rails to ezPublish or Zope or some other framework.
I’m starting my foray into web programming (working mostly on low-level C++ networking issues for many years), and after all the Ruby on Rails hyped, I’ve decided to take the plunge.
Besides hosting issues does anybody have anything negative to say about RoR?
I’d say documentation is another issue. Personally, I’ve been wanting to learn PHP since the version 3, but I was a bit young then and didn’t really have the patience for it yet. Now I’m going head first into PHP5, and having the documentation has been vital for me. I’ve bought on book for PHP, and it was useless for me, too much handholding. The documentation is where I am learning PHP.
However, when I try the same thing with Ruby [on Rails], I don’t find the same documentation. The best documentation so far has been a book by pragmatic programmers, but I find it’s method of teaching less then satisfactory. Perhaps I’ve been spoiled by the PHP documentation.
So ya, documentation is another factor to consider. I’ve been looking at Ruby the last few days now, and last night I saw how easy it was to use the ‘AJAX’ stuff with Ruby [on Rails] which definitely looks cool. I think I am going to try parallel programming my website and web apps in both PHP5 and Ruby [on Rails], and when Rails becomes more popular and easy to find good hosting for, than I’ll consider making the switch. Plus, getting experience in two languages is better than one
There are a few tutorials (some I’ve linked to) and here is a realy good ruby on rails book.
http://www.pragmaticprogrammer.com/titles/rails/
So the documentation is good enough. After all 1 good book is worth a million bad books right? (yes thats a shot at the quality of some of those PHP books)
No, documentation is not good enough. Not for me, or anybody else that wants to learn the way I do. You’ll often find people in PHP forums answer questions with a link to a function in the PHP documentation. The expectation is that one will first look at the documentation before asking a question. This would not be practical in the Rails world with the current documentation.
The PHP documentation is not good enough in my opinion. You like it, that’s good for you but I and other people don’t. All I want is that people evaluate PHP and Ruby on Rails, give Rails some time to sink in. I’m confident that the documentation and the book is enough, and I’m confident that if a new user gives Rails a chance it will win out on its own.
Disclaimer: I haven’t looked at Rails for nearly two months and I’m sure it (and the docs) have improved since then.
I agree that the RoR docs are weak. This may be just because the PHP manual is exactly what I want in documentation.
I love Ruby, it’s a great language and for scripts and small applications it’s my first choice. However, I wasn’t able to get into Rails and I think this is because of the documentation. Ultimately, I got wound up having to hunt about the web when trying to do something simple like a many-many table join.
A solid, centralised, web-based manual would do Rails wonders, for me at least.
Bingo! You hit the nail on the head buddy. PHP’s rise to fame was most certainly enhanced by their wonderful documentation. I can’t live without it. When I try to do something in Perl, Python, or Ruby, I find myself asking: Where the hecks the annotated documentation?
> When I try to do something in Perl
> Where the hecks the annotated documentation?
Perl features pretty good documentation bundled, and if it’s not enough for you there is a good Perl O’Reily books and online guides.
I’m currently developing a few web applications in ASP.NET 2.0 in Visual Studio 2005 (beta2). It’s quite fast working with databases, both inserting, updating and saving. No programming needed.
Are there any similar tools for developers working with PHP? If there’s not, it must be quite expensive for a company to develop any webapplications in PHP?
PHP is a perfectly fine language provided you are a disciplined, sensible programmer. I agree it makes it easy for newbies to shoot themseleves in the foot, but if you know what you are doing, you can blast out good code very quickly.3
I think most people comparing PHP or Ruby on Rails, J2EE, Python/Zope, blah blah blah, are missing the point of why PHP is so popular:
You can create a program using ANY ARCHITECTURE YOU LIKE.
There’s virtually no default PHP framework, and in many cases there aren’t any particular “ways” of doing things. Some see that as a big problem, but I see that as a blessing. I like to design things my way. I’ve created my own Web framework in PHP, complete with DB objects, templates, form validation, and so forth. I’m adding to it and refining it all the time. Why bother to do that? Because I know EXACTLY how my code works. I don’t know how other people’s code works half as well as I know my own.
I like PHP because I can download free chunks of code to do just about anything. Want a gallery, a “permalink” generator, a WikiWord engine, a BBCode parser? Just grab some code and stick it into your app any way you like. You’re in control, not somebody you’ve never heard of who decided to design a huge, elaborate framework in the “correct” manner. If there’s one thing about programming, it’s that it’s much more art than science. Sure, you need to be aware of mistakes, of security risks, of performance issues. But, at the end of the day, the goal is to create something clean, functional, portable, and *maintainable*. PHP allows me to do that for the Web better than any other language.
Jared
Yes you are right PHP dosn’t force a way of doing things on you and there is no standard way of doing it. This is part of the problem, the libraries are inconsisten (in PHP not its webframeworks) in order of arguments and in function naming conventions. The library could be made more object oriented to. Zend should concentrate on its IDE and indcorporate its chaging and other technologies into PHP mainline (all the other frameworks have it).
Either way, all frameworks in PHP could benefit from an ORM and AJAX abstraction.
Man, give it a rest. Go play your pathetic BS on a related topic. How fscking rude. PHP sucks, Ruby sucks, Python sucks, C# sucks, blah blah blah and boo hoo hoo. You are all the same — whiners and trolls. You ruin a topic because you think it’s the wrong topic. Sad…
All languages do suck to an extent but the warts on PHP are far more numerous then in the languages you compare it to. People should know what they get into when they learn PHP, its one of the most adhoc languages there exists right now and it will take another version or two until its half as nice as Ruby and Python are now. That’s not the big problem, the problem is that PHP is good for one thing, building small scripts for WebPages, and nothing more. Once you get to larger projects you either have to write your own framework witch takes time and you have to work around the numerous warts that it has or you use a prepackages web framework. There are only really two frameworks out there, bad imitations of ASP.NET and bad imitations of Ruby on Rails. And even if you still want to go with PHP you wind up with a language that is more or less web only (PHP-GTK is good for toying around but nothing more and the SDL bindings are long dead).
PHP is good if you know PHP or if you have no other choice, but if neither is true, you should be aware of other options.
“People should know what they get into when they learn PHP, its one of the most adhoc languages there exists right now and it will take another version or two until its half as nice as Ruby and Python are now.”
Obviously, you’ve never used Perl.
Obviously, you’ve never used Perl.
I’m a programmer Jim not a masochist.
If you had to start programming from scratch all over again, would you prefer PHP, Zope or Ruby on Rails?
Starting from scratch? Undoubtedly Ruby on Rails.
I’ve used Php for 5 years and it doesn’t come close to the db power of Rails. As for Zope, i have 2 books on Plone and one on Zope 3, and I still can’t get a decent handle on it. Zope 3 is powerful, no doubt, but it’s such a convoluted thing — none of those books actually walks you through building a complete web site: Css, static html, dymanic html, connecting to databases, CMS workflows, etc. They give you bits and pieces, but never pull anything together. I need to build db-based apps for clients quickly, and neither Php nor Zope offer that.
Rails already has 1 oustanding book (linked above) with a very long, practical tutorial that gets you up to an intermediate level. Then the Rails book goes into a deep analysis of each part of the MVC framework. 4-5 more books are in current development.
If zope 3 had an equivalent tutorial of that quality, it would be used more. I wouldn’t recommend Zope 2, as Z3 is a complete ground up re-write, and significantly improves life for the developer. Go to
http://www.z3lab.org
to see the latest.
well i have to }
{ admit the ruby looks
{
{{ cool…. but I cant stand
}}
squiggle marks and
}keeping up with them
{ so I am bias as well I recokon
as you may have guessed I suck at programming and cannot stand to do it because of cryptic words to remember and the squiggles, hashes, and indentions….
i am relegated to basic and a bite of pascal than ya
Its definitely ruby and perl. Ruby is ideologically true OO, powerful language, and perl is mature and extremely effective one with superb cpan modules library.
Will JSP die?
One can only hope. Same with ASP.
Well, having done a lot of work in PHP, and some work in Python and Ruby, I will have to say, Ruby is definitely a sweet language. I especially love the fact that syntax-wise there is no differentiation between methods and attributes, which lets you easily get around the whole accessor/overload/getter/setter debacle in most OO languages. I’m not so hip about Python, personally, although it is also fun to work with.
Yes, PHP is not particularly elegant, but it does have a simple, dependable (if somewhat clunky) robustness that I like. Maybe that’s because most of its functions are just directly mapped from C libraries, but that does mean you get a lot of functionality in a small package, and much of it is based on time-tested, stable libraries. With a few magabytes install base, you can have everything from database libraries to sockets to all kinds of cool 3rd party libraries like Curl, GD, etc… Yes, the default approach in PHP is to load the whole library collection on every script invocation, whether it is needed or not. However, PHP’s simple architecture means that there really isn’t too much of a performance hit for this. And, you can do any conditional library loading you want, either with custom INI calls in httpd.conf, or with dl().
And the comments about it being a web-only language miss one important area: PHP works great as a Unix scripting language, also. It’s really nice to be able to write scripts that do everything from system calls to database interaction, without needing to track down and load external libraries. Again the default bundled approach is a big gain for easy deployment. PHP also tends to handle loops in daemon mode quite efficiently. I leave many scripts running for days or weeks at a time with no problems.
IMHO, most of the ugliness around PHP comes from it’s ease of entry for non-programmers. So of course there are a million ill-conceived and poorly designed photo albums, CMS systems, etc… But this doesn’t prevent good design in PHP, especially with PHP5.
You can read plenty here: http://documentation.rubyonrails.com/<br/>” http://wiki.rubyonrails.com/rails/show/HomePage“