News for hackers. Stuff that matters.
Re:Can you use PHP without frameworks nowadays? by cletus on Friday February 18, 2011 @10:36AM (#2235776)
I had to do some PHP 2-3 years ago. I had always had a negative view of PHP prior to that despite knowing almost nothing about it, which I think is a not uncommon experience.

Anyway, there are lots of things that offend people about PHP that are basically inexcusable: like the inconsistency in parameter order (needle, haystack or the other way around?) and the inconsistent use of underscores in API method calls.

But all of that is just noise. Use something like PHPStorm, Netbeans, Komodo or whatever and it'll tell you the right order or if the function doesn't exist (I know some people are still in love with their raw text editors; I'm not one of them). And you learn quickly enough the right names and orders.

One thing I love about PHP is the simplicity of it. Edit the file, save, refresh in the browser. I love this short feedback loop. It was a refreshing change from doing Web apps in Java (for example), which added a compile/build/package step in between.

After doing this I investigated the common frameworks (CodeIgniter, Kohana, Zend, etc) and frankly I was horrified.

These things are so hideously overcomplicated. It's like a zealous Java programmer tried to recreate "Super-Struts" in PHP in a devilish plan to destroy all of the advantages of PHP while leaving a lot of the negatives.

The number of times I got bitten in the ass or just wasted time trying to figure out how the "magic" in Zend worked was infuriating.

Take something as simple as a controller. This is stupidly easy to implement yourself that any sort of generic framework is just going to bring you pointless crap you don't care about to the stuff you do by a factor of probably 10:1.

The ORM side was even worse. Java is kinda built for ORMs. It has stateful Web containers. PHP isn't (and doesn't).

The one bright spot I found was templating. It is common to say "why use a templating language with PHP when PHP is a templating language?" and you have an entire valid position. I too have said this.

That being said, I found Smarty to be incredibly useful just from the point of view of caching parts of the page and creating my own plugins/extensions for tasks that were common to me. Smarty had other issues like I wasn't completley fond of it's caching model and the speed, prior to Smarty 3 at least (which I've never used), was also questionable.

But despite all that I liked it a lot.

So can you use PHP without a framework? Sure you can. Not only that, I'd highly suggest it if you know what you're doing.

Re:Can you use PHP without frameworks nowadays? by emilsedgh on Friday February 18, 2011 @11:17AM (#2235977)
One of php's main advantages is the availability of many options. You have the option to do web apps in plain php. You have the option to do web apps in many mature frameworks.

Languages like ruby and python lack this. Can you do a website in plain ruby as easily? How many mature ruby web frameworks are there in ruby? There are many in php. Zend Framework, Agavi, Kohana, CodeIgniter, Prado, Yii, Symfony and many others.

Of course some stuff in php suck hard. I would personally love an string-object to replace all the stupid str_*() functions, but php is in the right direction of adding features. (My last issues are fixed by 5.3's late static bindings)

And im surprised how php community quickly adopts changes. PHP 5.3 breaks compatibility but i see more people using it everyday.

I think despite all the negativity, PHP is going to stay for long-term.

Re:Can you use PHP without frameworks nowadays? by drdaeman on Friday February 18, 2011 @11:33AM (#2236058)
> Can you do a website in plain ruby as easily?

Don't know about Ruby, but as for Python - yes, you can. There is Python Server Pages in mod_python, which are similiar to mod_php.

However, mod_python is ugly (in a same way mod_php is), so it's generally frowned upon and considered to be Bad Thing.

Re:Can you use PHP without frameworks nowadays? by zeemonkee on Friday February 18, 2011 @12:42PM (#2236396)
It's not just ugly, it's unmaintained.
Re:Can you use PHP without frameworks nowadays? by krakensden on Friday February 18, 2011 @01:34PM (#2236614)
There's always mod_wsgi and writing a raw wsgi app- which honestly, isn't particularly hard or bad.
Re:Can you use PHP without frameworks nowadays? by drdaeman on Friday February 18, 2011 @01:32PM (#2236606)
I believe, this is a consequence of being ugly.
Re:Can you use PHP without frameworks nowadays? by IsaacL on Friday February 18, 2011 @01:07PM (#2236513)
"Can you do a website in plain ruby as easily?"

I've written websites in plain Ruby, as CGI scripts running on Apache. I actually find this easier that PHP, as Ruby doesn't have nearly as many weird inconsistencies. I think I'm pretty unusual in being one of the few Ruby programmers who didn't immediately begin with learning Rails.

Re:Can you use PHP without frameworks nowadays? by kreek on Friday February 18, 2011 @12:20PM (#2236289)
Ruby with Passenger can be used for a simple website. Throw in Sinatra with Datamapper or ActiveRecord and you've got a lightweight setup - with better options for string manipulation than PHP :)
Re:Can you use PHP without frameworks nowadays? by sedachv on Friday February 18, 2011 @01:35PM (#2236617)
"The number of times I got bitten in the ass or just wasted time trying to figure out how the "magic" in Zend worked was infuriating."

This is true for all frameworks in all languages. Instead of doing the Unix thing and providing well-behaved libraries that do one thing well, people build a pile of opinionated spaghetti. To quote HN user mahmud:

"snippet -> program -> application -> library [STOP HERE]-> framework [GO BACK]->platform [GO FUCK YOURSELF]"

Re:Can you use PHP without frameworks nowadays? by cletus on Friday February 18, 2011 @01:50PM (#2236679)
That's a great quote. Is there a link for it?
Re:Can you use PHP without frameworks nowadays? by sedachv on Friday February 18, 2011 @04:35PM (#2237370)
Re:Can you use PHP without frameworks nowadays? by rabc on Friday February 18, 2011 @11:25AM (#2236023)
Exactly all of that!

Everytime I tried to use any of these PHP frameworks, I got frustated because they demand you to be stucked inside the "convention over configuration" and you can't do anything more complicated into your code without having to read a lot of docs about how to make something outside the "normal code". You always have to inherit you controller from something else.

This is why I built a framework fomr the ground ( http://github.com/rabc/Simple-Framework ). Just because I wanted to craft my own code.

Re:Can you use PHP without frameworks nowadays? by DjDarkman on Friday February 18, 2011 @10:47AM (#2235837)
In my opinion, I found a framework(or so called un-framework) that gets ORM just right in PHP: http://flourishlib.com/

I too ended up using Smarty and doing the rest myself, but I feel that this particular framework has gone in the right direction.

The best thing about Flourish is that it doesn't pretend to be Java, it acknowledges PHP.

Bottom line: it made my code smaller and a lot readable. I highly recommend checking it out.

Re:Can you use PHP without frameworks nowadays? by nolok on Friday February 18, 2011 @10:54AM (#2235864)
While I agree about the Zend framework, Symphony and others trying too hard to be full of features, frameworks like Code igniter are really light. Sure for some very very basic projects it might still be too much, but for an actuel interactive websites chances are higher of it missing features than having too many ...

Can you give an exemple of something it does by default that is "pointless crap" ?

Re:Can you use PHP without frameworks nowadays? by jasonlotito on Friday February 18, 2011 @11:47AM (#2236133)
Pointless crap is subjective. Zend_SOAP, I imagine, would for many be considered "pointless crap", but having it available means I don't have to go looking for a SOAP library when I need it to interface with a gateway.

People always confuse features with bloat. Disk space is cheap, and these frameworks aren't hurting things by having additional features.

Now, complexity I can get behind, but stop relating complexity to weight or bloat. CI is less complex than ZF because it does substantially less. It requires developers to do more to accomplish the same tasks ZF developers can do a lot faster. However, it takes a lot more work to get to that point.

Personally, I'm glad we have these choices. We can choose the right tool for the job. =)

Re:Can you use PHP without frameworks nowadays? by jonstjohn on Friday February 18, 2011 @12:07PM (#2236236)
Really about Zend? We use Zend Framework extensively and find that while we can roll our own (and I certainly have), it is a well-documented MVC framework that provides a decent foundation for our applications. Zend probably only solves 10% of our issues - the remaining 90% are very application-specific logic.
Re:Can you use PHP without frameworks nowadays? by ww520 on Friday February 18, 2011 @02:56PM (#2236963)
As for the edit/compile/deploy/run cycle in Java web app development, the Play Framework pretty much reduces that to just edit/refresh. It's really amazing.

I've done two projects with Play and both development cycles are extremely fast.