To Use a PHP Framework or Not? [closed]

淺唱寂寞╮ 提交于 2019-11-27 03:20:50
Sadegh

What are the benefits of using MVC PHP frameworks ?

Well there are many benefits of using PHP frameworks, let’s see some of the main benefits of using them.

  1. These PHP frameworks follow some design pattern, so when you use a framework you have to follow their coding convention, which makes your code clean and extensible for future purposes.
  2. The Popular PHP frameworks like CakePHP, CodeIgniter, Zend Framework, Symfony follow Model View Controller (MVC) design pattern which separates business logic from user interface, also making the code cleaner and extensible.
  3. As everybody can guess, these frameworks contain a lot of libraries to make your job easier. For example: to validate a form you don't have to write as much code as you have to do in normal coding scenario (without using a framework), just a few lines of code calling the library is usually enough for it.
  4. While working on a large project in a team, an MVC PHP framework will be a great tool for development as you can assign a developer to develop one part of a module for a developer and integration will be quite easy of these developed modules at final level.
  5. These MVC frameworks really help you to develop the project rapidly, if you know a framework well then you'll never worry about the project deadline.
  6. Most of these MVC frameworks use clear url approach making your web project SEO friendly.

check article

My philosophy is that you should only use something when it solves a need that you currently have.

There's a real tendency, particularly in this realm, to simply use a framework for the sake of using one or because you feel like you should be using something. I discourage such practices. Also frameworks I think have the most value when you've done things the hard way so you have a good understanding of what problems you have and how the framework can help you in that situation. Framework choice does depend on the situation.

That all being said, the MVC pattern with Web applications is useful so it certainly wouldn't hurt you to learn at least one. I'd stick to a fairly minimalist framework however. CodeIgniter springs to mind here.

Lastly, the other danger with frameworks is that they can be so invasive that you're no longer doing PHP, you're doing CakePHP, Symfony or whatever. That's not necessarily a problem but the danger in it being so invasive is you don't get a good grounding in PHP and if you ever want to change it'll simply be too hard that you'll never be able to do it.

One of the great perks of PHP frameworks are that they minimize reinventing the wheel in a great number of common web application needs. Security issues, graceful exception handling, RESTful URLs, and reusability of code across your site are fairly universal considerations.

It may be easier to familiarize yourself with the tools of a framework and then see if you want to take on the full MVC system it supports. For that end, I'd suggest familiarizing yourself with the Zend Framework. ZF works as a library of classes which can be implemented individually for particular uses--anything from security to Lucene search--but contains classes which, when used together, implement a fully fleshed out MVC paradigm.

i just want to tell about my own experience in programming, I'm still newbie though

  1. first by using framework you'll get used to their coding style/rule, which is good because most of the framework are deeply thought about how they write their code. in short i get better style and cleaner code
  2. Usually framework come with many arsenal (plugins and or library), which you can find in internet, this will reduce your coding time, cut wasted time. In short you can make your own precious time thinking on business process
  3. with using open source framework, there's other programmer who already know and probably mastered the framework, then you can easily collaborate with others.
  4. in truth i'm not a well organized programmer, but it was before i 'm using some open source framework. perhaps like me you'll get more organized

That's all I can share with you for now, i'm not good with writing in english, sorry for that. but the point is i recommend you to use framework

Happy coding friend.

I think it's undoubtedly a good investment to spend the time to learn a PHP framework. For one, it'll teach you how someone has tackled the problem of architecting the framework, how to organize your PHP code, and how to handle things like sessions and database accesses...etc...

For the most part, if you are serious about developing web-apps, you will need to use a framework of some sort rather than writing your own framework from scratch.

Some reasons why you should NOT write your own framework:

  1. You're re-inventing the wheel, when it's been done many times over already.
  2. You're not very likely to do a better job than an open-source framework, which has been tested and iterated over by many developers.
  3. You'll spend all your time writing and debugging your own framework than you will spend on actually creating your application.

So yes, learn a couple of frameworks and find one that suits you the best!

Diclaimer: I'm NOT a php programmer and I have not EVER written a php application. On the other hand, I have installed, customized and used alot of php cmss for my site and shopping carts.

In my opinion php suffers from serious problems. The biggest one is that “framework” seems to be a foreign word for almost all big and even successful projects. Php code tends to become quickly spaghetti salad: spaghetti html mixed with spaghetti code and spaghetti sql.

osCommerce, one of the most successful shopping cart ever, is mostly unmaintable. That applies also the big majority of php projects.

Whether you should use a framework for you project, I say yes! Definitely! No matter how big is your project, using a web framework helps you tidying you code up and writing maintable code.

It also impact your programming style even when you are not using a framework.

Using MVC-framework will make your development more easier. Especially database-related applications. It provides you a crystal clear folder structure and plenty of code libraries. I would suggest you start from CodeIgniter.

Frameworks are great when you got a team of developers working on the same project. The MVC controller integrates the designer + programmer beautifully. However, creating "framework-like" elements and "reinventing" the wheel isn't such a bad idea. If you're working on a huge project, it's better to get down and dirty with your code and customize EVERYTHING to fit your needs. It'll become a stronger product as it will be developed entirely for the project.

KSwift87

The following post is in response to a thread that was immediately closed as I was writing my answer to RenderIn's post at: https://stackoverflow.com/questions/3265509/what-are-the-benefits-of-using-a-programming-framework . The thread was closed and in the comments a link was placed directing him to here, so I'll attempt to answer his question here. In quotes below is what I was ABOUT to submit:

"Allow me to recommend Joomla! to you and your organization. At my last employer, I had to pick-up PHP (having no prior experience with it), and after about a month and a half of doing some manual hand-coding of PHP, I was tasked to code a Joomla! component that would serve-up videos to users. I also had to create a backend that would allow non-techie administrators to categorize, edit, delete, etc., the videos as well as provide thumbnails for them, etc.

Now to get a working prototype for that, it took about two months (I was an intern at the time and only working 20-24 hours per week, so if you have quite a bit of PHP experience as well as experience with MVC development methodology, you probably could've gotten a working prototype up a LOT quicker than me)."

Now in response to the OP of THIS thread: Spending the time to learn a framework is definitely worthwhile (I haven't seen it mentioned in here until my post so I'll say it again: for a PHP-framework I'd recommend Joomla!).

Some of the benefits of learning a framework (an open-source one like Joomla!):

  • A huge community of people who can help answer your questions (besides stackoverflow; lol)
  • Access to ALL of the source code, so you can customize it however you want.
  • Lots of free (and paid) third-party plugins to enhance functionality.
  • Lots of tutorials.
  • Frameworks take care of performing a lot of mundane tasks automatically.

In reference to bullet four: Joomla! takes care of things for you such as database connection management and such so that you don't have to bother creating all your own custom functions to connect to your MySQL database or return different types of database results (e.g. one record, first result of first record, list of records, etc.), you simply place calls to theirs. Joomla!'s API is openly available on the web at their site: http://api.joomla.org/

Anyway hopefully this helps RenderIn and anyone else wondering about frameworks (especially PHP-related ones).

A framework to me is a good tool to speed you up and save your time for the sake of you just don't want to spend time to redo it, not because you want to save time that you don't know how much it is. You will pay for it if you do so.

To me framework is good if you are already a experience programmer and you have the touch or feel that you know how the framework roughly work below (just roughly not exactly) and have the confident to say ya if I want to I can re-create sort like simplify of this framework. Then a framework is a express car for you and it won't cause you the pain if you want to do something that the framework not ready for or something unusual or other odd thing.

If you don't, you better try to solve your problem using plain old PHP and go through the pain of playing the language at your finger, and learn about good programming practice and paradigm and pattern first. Else you will be one of those fresh graduate joining a large team and their first project is working on a project with a very powerful framework that require very less coding and more on configuring and patching. You will never be a good programmer and can't build a good PHP application from scratch.

How if you are in an organization that use a complex framework?

Spend some of your very own time to solve the problem in plain old in this case PHP until you get the touch of what I mentioned above. Else, you will never find your confident in programming and keep telling yourself, "I just know those are the steps are the way to do it". That is not programming (a bit extreme :)) .

Complex vs. Simple Framework

Some of the framework although used by many, is just to overwhelming. There is too many layers that you will lose track of. Those frameworks are usually for something which is stereotype, a lot of configuration files and if you want to do something unusual, you do better be the framework writer(a bit exaggerated here :)). I do not want to mention any name here, but you will know it when you encounter one.

CodeIgniter is a product of EllisLab team and their main product is Expression Engine which developed with CodeIgniter.

After some time of using CI I found that using Yii Framework is more convenient. It has a lot of extensions. And not so difficult to understand with good docs.

CakePHP, I think, close to CodeIgniter.

I would strongly recommend using a framework for anything more than a simple script. It may seem overkill sometimes, but I would argue that it's not. I've had a few occasions where I thought I don't need it (simple app, basic CRUD in 3 db tables).

Shortly after, I found myself doing manual mysql_escape_string, XSS filtering and so on. From then on, I only write non-framework code when I think that the setup will take more that the working code. And that happens very seldom.

If I would have to recommend a PHP framework, I'd have to go with CodeIgniter or Yii Framework, depending on how complex your project is.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!