views:

245

answers:

6

I'm getting back into web dev after a four/five year hiatus. I was wondering what you folks think the Current Big Thing™ is in PHP dev; i.e., if I'm going to try to put myself back in the game after a break, what should I brush up on? I heard that the model/view/controller method of development is getting popular in php, using Zend Framework or something else; do people actually use that for development? Is templating (à la Smarty or something similar) still popular? Is php even still The Popular Language, or has ruby on rails taken over?

In other words, (in your opinions,) what have I missed? Thanks!

A: 

Don't go back to php, use Django :-)

EDIT:

Yeah, I'm a man of few words. That's why I chose Python ;-)

I have done only one project in php and it was many years ago. I had to do all sql calls by hand and didn't use any framework, so I would be very biased. That's why I don't want to compare PHP to Django, since I can't do it well.

But, if you are coming back to life and want to do some web development, then Django is a great choice for this purpose. It's stable, provides ORM for most popular databases, it's very clean and allows easy management of a project. I have done both orthodox Django project, as well as having a completely custom model backend written by ourselves in Python. It just feels good to code in Django :-)

gruszczy
You make a compelling argument.. wait.
Mike B
I'm not tied to php. Assuming you weren't being sarcastic, could you expound on your post a bit?
eykanal
Hey's a python programmer... Which means he just expressed everything on one short line. Wait...
gahooa
So you're comparing one thing you know well to one you doesn't. Very useful indeed.
kemp
I am not comparing :) I am just saying, that Django is a good choice :-)
gruszczy
Django is indeed a great framework, but you can do everything you can do in Django with PHP and its framework, such as Zend. So you are comparing apple and orange, which to me, is not comparable.
Jay Zeng
+2  A: 

gruszczy mkes a good point, but if you must ...

Ewan Todd
maybe you meant SPL?
just somebody
indeed ..........
Ewan Todd
+5  A: 

PHP is a capable web scripting language, but there are languages, some more expressively powerful and more organized ( namespaces ), cleaner languages such as Python, Ruby which you may want to look at, with frameworks such as Ruby on Rails, Django, Pylons ( my personal favorite ) which are all MVC based and that is pretty much the common trend nowadays as it's a great design pattern to follow.

PHP is a natural templating language therefore using Smarty is counter-productive. However other languages such as Python which aren't geared towards web templating, in those languages you would use a templating language such as Mako, Cheetah, Genshi, Jinja, and usually you would do these in the templates/views:

<p>Hello ${name}!</p>

For database interaction, most high level developers don't do things procedurally, but instead rely on high level wrappers such as Zend_Db, in other frameworks you have ORM based applications such as SQLAlchemy and Doctrine and proprietary ORMs such as Django's, I like ORMs because you basically define the table schema in the form of classes and do whatever you want. A SQLAlchemy/ORM example:

page_table = schema.Table('page', meta.metadata,
    schema.Column('id', types.Integer,
        schema.Sequence('page_seq_id', optional=True), primary_key=True),
    schema.Column('content', types.Text(), nullable=False),
    schema.Column('posted', types.DateTime(), default=now),
    schema.Column('title', types.Unicode(255), default=u'Untitled Page'),
    schema.Column('heading', types.Unicode(255)),
)

Another popular trend is using a database cache mapping system such as memcached in which you store items as key/value pairs in order such that there's less of a performance hit on the db, memcached can be used in combination with pretty much be paired with any framework that doesn't have a similar native functionality.

For client-side scripting you should rely on a framework such as jQuery which is really great because it makes DOM scripting cross-browser compatible, it's extendable and the syntax is fairly easy to pick-up. This snippet attaches an event handler to every anchor and invokes the alert method.

$('a').click(function() {
  alert('you clicked on me!');
  return false;
});

It's also worth noting that you should use some sort of localization system instead of hardcode strings into your application such that it can easily support multiple languages, I personally use and recommend gettext, which stores language strings in the form of mo files, which you compile from an editable po file, though there are numerous ways of going about this such as storing them in arrays or csv's, mo files are very efficient. In Zend particularly there's Zend Translate which you could use for this purpose.

$locale = new Zend_Translate('Gettext', 'locale/i18n/en/app.mo');
<div id="greeting"><?php echo $locale->_("Hello"), ' ', $name;?></div>
meder
will make more edits when I have time, I know I left a lot out.
meder
+6  A: 

People are getting more professional. At least, that's my impression. I'd say have a look at

In the Tiobe index PHP has recently gained and is now at position three. If this makes PHP still/more popular or better/worse/whatever than RoR or any other language, well.. that you should decide for yourself.

PHP has it's quirks, but so do have other languages. I'm sure there will be enough biased answers to this question :)

Gordon
And Alchitect (shameless plug) - http://alchitect.com
Darrell Brogdon
Hey, I charge an upvote for shameless plugs in my answers or their comments ;)
Gordon
No one's mentioned Ruby on Rails so far... is that just because no one here is a RoR programmer, or did that one just come and go quickly?
eykanal
**In my opinion** the hype around RoR has cooled down. RoR does what it was designed for pretty good, but it aint the holy grail or a silver bullet. And there is a lot of people who don't believe in ActiveRecord or the automagic RoR gives you.
Gordon
+3  A: 

No php isn't popular any more. That's why only 30%+ of the most visited websites in the world use it.

Speaking specifically on the current 'big thing' in the world of php - I'd have to say the common CMS's - Wordpress, Joomla & Drupal but also E-Commerce platforms.

Zend Framework is doing some marvelous things for php and php 6 is coming.

DamienRoche
Only 30%? That seems like a rather short number.
Alix Axel
"30%+ of the most visited websites". Actual usage in general is much higher.
Darrell Brogdon
most <fill in the number here> visited websites?
Jay Zeng
yeh, probably more by now. Either way, doesn't matter, coz we can't agree on anything except that php IS favored by many many high profile organizations. Exact figures? I don't really care. PHP puts food on the table for me, so I'm happy.
DamienRoche
+1  A: 

If you've been away 4/5 years chances are you didn't play much with PHP5. If it is so, then you will find a good number of changes, especially in the OOP department.

PHP is still a perfectly fine web site/application development language, it has its flaws but in the hands of a sensible programmer is as good as any other. Choose a good MVC framework, take a look at an ORM like doctrine and you're set. Also, with PHP you don't even need a templating engine :)

Don't be fooled by the current tide of PHP hate, you don't have to feel dirty if you like it.

kemp