Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php frameworks - build your own vs pre-made

Tags:

php

frameworks

I am building an application currently in PHP and I am trying to decide on whether to use a pre-existing framework like codeigniter or build my own framework. The application needs to be really scalable and I want to be completely in control of it which makes me think I should build my own but at the same time I dont want to reinvent the wheel if I dont have to.

Any advice greatly appreciated.

Thanks

like image 556
christophmccann Avatar asked Mar 25 '10 12:03

christophmccann


People also ask

What is the best framework to build a PHP web application?

Laravel – a popular PHP web framework with great extendability for high-quality applications. CodeIgniter – one of the most popular PHP frameworks with MVC support, great for creating lightweight web applications. Symfony – a modular PHP framework with a built-in debugging system and extensive documentation.

Which is the best PHP framework for beginners?

CodeIgniter is the top choice for a beginner-friendly PHP framework that is easy to use and quick to learn. It works on the MVC architecture, is easy to install, offers several guides and is easy to understand for beginners to get started with developing web applications on PHP.

Should you use a PHP framework?

You can use PHP frameworks to build secure, flexible, high-performance websites and web applications. A modern PHP framework is a beneficial and powerful tool in web development that solves many problems.


1 Answers

Use an existing framework.

First of all creating a framework from scratch represents a massive investment in time and effort. The process involves a lot of trial and error, because you're designing something that needs to be both simple and powerful. For every design decision you'll have to ask yourself how it will affect every single future project that will be built on your framework.

You'd think that you could take each design decision and weigh it against the requirements like you would do for any other software project, but the thing is you don't know your requirements. You can't know them, because a framework is supposed to be able to do almost anything (or have the ability to be extended to do almost anything) within its domain. Future project a will need to be able to do x. Can your framework allow that without turning it into spaghetti code? And what if project b needs to do y? What if project c needs to do z?

Have you predicted everything?

Now the normal response to this is that if something doesn't work, you'll just change it in the future. It's software after all. A framework however isn't like a simple application. It's supposed to have an interface and once you expose that to the software that will be using it, you can't change it. You can extend it, but not change it. So now you have to think about deprecating methods, api versions and version compatibility. It's a whole new set of problems to deal with along with normal framework maintenance and new application writing.

Then there's documentation. You need an API, tutorials, example code. Once you build your own framework you have to deal with this as well. You could ignore it, but I assure you that eventually you yourself will need to find out what that method you wrote 6 months ago does. What does it return? What if special case x happens? Have you written all that down, or do you need to step through the code again? And I wont even mention how easy it will be for a new team member to get started on a custom framework whose documentation lies completely or at least mostly in your head.

You also have to acknowledge that unless you're working with the very best and brightest (and have a budget to match) you'll never have the extensive set of libraries that existing frameworks boast. Can you analyze, design, code, test and debug faster than an open-source community?

Finally you should ask yourself if you are proficient enough to be writing a framework. Have you dived deep into the code of a modern OO PHP5 framework to find out what makes it tick? And most importantly do you know why it does things that particular way? Keep in mind that any mistake you make in your design can blow up in your face months from now and you can end up paying for them over and over again.

To sum things up I'd advice you to go with an existing framework; it doesn't mean however that you have to pick one and like it. Take the time you'd otherwise devote to developing a new framework and devote it to learning an existing one. Then you can extend it to fit your needs. Also remember that there could be things you wont be able to do. But I assure you there would be things you wouldn't be able to do with your own framework either, so it doesn't matter all that much. A framework imposes a few limitations. It's the price you pay for being able to develop applications faster.

like image 185
Manos Dilaverakis Avatar answered Oct 19 '22 08:10

Manos Dilaverakis