LebGeeks

A community for technology geeks in Lebanon.

You are not logged in.

#1 December 30 2014

user
Member

raw php vs framework

I currently got a new job and we're having a bit of a...dispute at work between myself and the older developer. I like to use a php framework(symfony 2, any symfony 2 developers in the house?) And he likes to use raw php, he argues that he can code just as fast with raw php and that frameworks are more or less useless. I'm not sure whether to just write code in raw php or stand my ground(going back to raw php feels like a big step down to me). I am afraid that if for one reason or another I have to leave, that no one would be able to maintain my code(of all the developers I know, only 2 others know symfony 2, and one of those 2 is the person who taught me and the other guy).

But anyway that is not why I wrote this thread, I just would like to get an idea of how many Lebanese php developers(although I realize the readers of this thread are a small sample size) use a framework vs using raw php? What argument would you give? I also would love to meet a new symfony 2 developer.

Offline

#2 December 31 2014

rolf
Member

Re: raw php vs framework

Don't be afraid about maintenance. Maintenance is a factor of how clean and well organized your code is. For most small websites, a small, minimal, well organized code base is much more maintainable than a whole Symphony installation. For one thing, Symphony developers are just a (small?) subset of PHP developers, so it should be easier to find someone to maintain the code (for such an imaginary scenario).

I for one would lend more toward your senior's opinion. If you ever quit the job (because of this disagreement, or similar), please put me in touch :)

Seriously now I know frameworks have advantages, but they can also be terrible and ugly and God knows how!

So anyway just don't fall into that sterile and potentially destructive argument of frameworks vs what you call raw PHP "in the absolute". I strongly urge you to be careful. Code doesn't exist in a void, so to have any kind of productive argument you must start to set the environment specifics, like what kind of project you have, what are your constraints, etc, and then you can weight the two approaches in relation to that situation and maybe you can see more clearly.

Last edited by rolf (December 31 2014)

Offline

#3 December 31 2014

Ayman
Member

Re: raw php vs framework

No matter how small what you are building, if it has any business value to the customer it will probably grow to a bigger application. As an application grows, maintaining it will become harder especially when many developers are working on it.

Frameworks have been made for many important reasons: Structure, modularity, productivity, easier maintenance, re-usable components, built in unit/integration testing, etc... I think you probably understand the benefits already.

Its not just about how fast a PHP dinosaur can churn out code, its about how maintainable the application is, and how sane and familiar the structure is. Its never about what someone 'likes', its about whats better for the project, thats what he should clearly understand.

I would suggest that you ask him about valid reasons on why he would go with such an archaic approach. Then give your valid arguments on why, his approach for this project is plain wrong. Then you can suggest some good frameworks to use. One reason behind his view might be that he is afraid of learning something like Symfony 2 because of its learning curve. You could then suggest a much simpler and straightforward framework like Code Igniter (I wouldn't recommend it a lot but still better than nothing). Another nice framework that is a bit more complex than CI yet much more friendlier that Symfony is Laravel 4 you should totally check it.

In this context I assume raw PHP without even using Composer Packages and PHPUnit. Whatever framework or approach you follow, it is absolutely a must to use a dependency / package manager. For PHP, composer is the best choice you have.

To answer your question about usage, I built things in "raw php" a couple of times in my life, that when I first learned PHP. And even then, I felt the need for structuring my application, so ended up following an MVC approach as much as possible. Then dived into Symfony 2 when it was still in beta, then Silex, Code Igniter, and now Laravel 4.

And by the way, if you have the opportunity of moving away from PHP as a language, don't hesitate. PHP is a very practical and useful language for web development, but it really lacks the fun, elegance and thoughtfulness of others like Python, Ruby or C#.

And at least, explore other languages, learn from them and try building things with them (that applies to whatever you are doing).

Last edited by Ayman (December 31 2014)

Offline

#4 December 31 2014

Joe
Member

Re: raw php vs framework

We've discussed this before. A quick search shows me at least two topics:

My position remains the same after all these years. You absolutely need a framework. "Raw" PHP (or any other language for that matter) is a maintenance nightmare, a pain in the ass to keep secure, and is highly unlikely to be as good as something like Symfony or Laravel. A lot of man hours have been put into making these open source framework performant, secure and flexible enough. It'd be a shame not to take advantage of them. The only reason I see people avoiding them is because they don't want to learn something new, and are generally resistant to change.

Think of code as a liability. You want to have as little of it as possible. Do you realize how many lines of code are saved if you don't need to take care of routing, security, scaffolding, ORM, and testing? Why should you be the one maintaining these? Let the upstream take care of it and apply patches when needed. You should focus on the business logic of *your* website.

PS: Most of what I think, I've already exposed in my previous answers (cf Why Use a CMS?). There's one thing I've learned since. Be obsessed with testing. Automated tests are probably the most important part of your code (and sometimes the most complex one). It is absolutely vital that you pick a framework that treats testing as a first class citizen. I've heard of frameworks that will force high testing coverage or else they won't run. Go for something like that. You'll thank me later.

Offline

#5 December 31 2014

rtp
Member

Re: raw php vs framework

As Joe noted, "You absolutely need a framework".  The downside of a framework is that you need a little more time to get the hang of it and that's about it.

What is a framework anyway?
Framework solves your typical problems.  You can use Php and solve the problems yourself.  So you solve the problem the first time, second time etc.. and then you realize that these problems keep repeating themselves from one project to another.  Thus, you come up with this genius plan to write a set of "libraries" and "architecture" that solves these typical problems.  That's the essence of a framework.  You will either end up writing it yourself or you will use an already proved framework that thousands of people are contributing too, such a hard decision!

Offline

#6 January 1 2015

rolf
Member

Re: raw php vs framework

I don't think that you absolutely need a framework any more than you need a dogmatic and rigid attitude.
You need to structure your code, and in this sense you need a mental framework, at least, if you don't want to make a mess.
Buy anyway I have my own lightweight framework that I use. It evolved across projects. A lot of man-hours went into that as well.

rtp wrote:

Framework solves your typical problems.  You can use Php and solve the problems yourself.  So you solve the problem the first time, second time etc.. and then you realize that these problems keep repeating themselves from one project to another.

Which is more or less what happened to me, and which would explain why there are so many frameworks out there.

But the reason why the problems repeat themselves, is because the projects repeat themselves and they are very similar. If one day you are assigned a very different, unique project, you have to stop and ask yourself if using a framework is the way to go.

Last edited by rolf (January 1 2015)

Offline

#7 January 8 2015

user
Member

Re: raw php vs framework

We're sorting it out between us developers at work. Mainly I like my framework because I don't really have to think much about the structure of the application, or about the queries. There is a fixed and already given way on how you should do them, and this discipline makes all my projects easy to figure out, and makes any project made by any developer anywhere in the world using that framework, also easy to figure out and use.

edit: of course you can break the rules of the framework if you like, it is php deep down after all, but it is very discouraged.

The more I see regular php the more I get convinced that it's not for today's complex apps. It's really ugly looking. And yes this is not a "scientific" thing to judge a programming language based on, but it is. The way the html gets mixed with the php in the template, and the database queries with the code logic... Some frameworks and languages are just a pleasure to work with.

Last edited by user (January 8 2015)

Offline

#8 January 9 2015

rolf
Member

Re: raw php vs framework

user wrote:

The more I see regular php the more I get convinced that it's not for today's complex apps. It's really ugly looking.

You're not the first to say that.
So basically your framework is not a modern and complex app, because, hey, it's written in PHP. And don't you write your code in PHP when you use the framework anyway?

You can see that there is a paradox in the logic that you're using.

I also want to add one more thing, I try to avoid template languages built in PHP, such as Smarty, because PHP itself is a templating language.
Not that it's forbidden to do such thing, but I'm afraid developers would use Smarty without realizing that PHP already does what they need without the added complexity and performance cost.

user wrote:

And yes this is not a "scientific" thing to judge a programming language based on, but it is.

I would say the problem with your reasoning is that you talk as if all PHP code is equal. If I take some time for that I can show you ugly PHP and good PHP. Maybe you will both find them ugly but you will surely see that there is a big difference between the two. But we don't know what kind of code you're talking about.

Last edited by rolf (January 9 2015)

Offline

#9 January 9 2015

user
Member

Re: raw php vs framework

Well for one I don't use php in the template at all(it's twig) And that is mostly where the ugly parts are. Controllers and entities are in php and in that php is good. And yes I am sure anyone can write their own extremely clean framework. But rather than put so much effort and hours trying to make one from scratch, I can use one that already has been updated alot.

Offline

#10 January 9 2015

rolf
Member

Re: raw php vs framework

user wrote:

I can use one that already has been updated alot.

I am not against that at all.

Offline

Board footer