PHP Frameworks - Are they solely personal preference? - php

I'm new to the world of PHP frameworks and, after some initial investigation, came up with the following list of popular choices:
CakePHP
CodeIgniter
Symfony
Zend
I'm trying not to repeat the "Which is best?" question, which seems to elicit not much more than personal preference. Is this the case? Is one truly "better" than the other? What are the strengths and weaknesses of each?
I apologize if the question is too broad, but any clarification would be much appreciated.

The thing with frameworks is that they're perfect up to the point you need them to do something they're not made for.
I've worked with all of the major PHP framework's you've listed, except Zend and this is what I can quickly tell you:
CakePHP enforces OOP, gets you up and running quickly, has a great community and relatively good documentation, comes packed with all the features you'd come to expect.
CodeIgniter gives you the most elbowroom of the first three. Doesn't exactly enforce OOP, it leaves it up to you. The easiest to implement and distribute of the three. Fantastic community and they keep the documentation up-to-date with new releases. I like to consider it as a perfect skeleton for whatever you want to do, how you want to do it. Also, the most fastest of the three.
Symfony without a doubt, the most powerful of the three and the closest to RoR. Expect having to learn PEAR and have access to SSH on remote servers. Very slow and I wouldn't suggest it on shared hosts if you want to develop a big application. It does enforce some strange practices and you'll see more PHP in your views than you'd particularly rather like, but it has a tool to help you start working on a solution for every problem.

I stumbled across this (old) question as I am looking for a PHP framework that works well in a shared hosting environment ; speed is important as in shared hosting CPU time is the tightest constraint.

Related

How to keep up with PHP Frameworks evolution?

So I'm about to start a big Property Management System for the cloud. This Hotel system already exists in VB.net technologies, and now we are porting the whole system to web.
We are trying to decide between ASP.net or PHP, we are thinking on PHP because ASP.net would cost too much on licensing and servers. So there is Laravel, Symphony, CodeIgniter, Zend, etc..
The thing is, this project is suppose to live for years to come. But we feel like getting constraint ed by using a PHP framework, because every time the framework gets updated then we need to update our whole system. For example.. now Laravel got updated from version 4 to 5. And the whole folder structure changed. I can't imagine having our big system needing to be updated and keep up to every Laravel version update. How do you keep up with this ?
Also, what would happened if Laravel disappears, its the trendy fashion now. But we see PHP frameworks come and go.
Would it be wiser not to use any php framework and building everything from scratch to have more control over it ?
You should first note that using a framework is primarily meant to solve two issues;
Force coding into a certain 'format'. Collaboratively working on code can generate 'hacked' solutions, or unmaintainable code. A framework can be the force which helps keep these things in check.
A framework comes with a certain core-code which handles for example database abstraction, routing, etc. which can save you a lot of time to develop yourself.
An extra thing to mention; when implementing new features, there is the possibility someone has built it before and maybe even better than you would have anticipated.
Keeping up with the framework should not be too hard, as long as you abide by the coding guidelines of the framework. With the bigger frameworks, new releases have (or after sometime generate) tutorials on how to port your previous version into the new version format.
Choosing which framework to use, is a question which is opinion-based and not suited to discuss here, but keep in mind that you choose your framework according to your needs. Also check how big the community is and how much 3rd party plugins/code exists (the more, the longer the framework will last).
Good luck!
You could see a framework as a base to start from. Remember that you get all the code! Look at the code. Do you like it? Does it fit your requirements? Using a framework gives you a huge advantage over making everything yourself from scratch.
But do you need to update? Would you update your own code constantly? Perhaps it's not always needed. Sure, if there is a security issue you should do something about it, but seeing every update to a framework as essential is just plain nonsense.
I build projects aimed at specific versions of frameworks and libraries. I try to build in flexibility so I can swap out frameworks and libraries, and versions, but I often find that I stick with what's working.
Some people might not like this, and argue you should always be on the latest version, but I find that completely impractical.

Continue with Self-Development in PHP or move to a PHP Framework?

I'm building this web site for my friend's startup. The site when its complete should be able to handle 10,000 users at a time and should have great security.
I've been developing the site individually till now and everything seems to be pretty feasible, but some of my developer friends suggest that i move to a framework.
What are the pros and cons of moving to a framework?
Also i have developed a pretty big part of the website till now, so can i just move it into a framework environment. I've never worked on any kind of framework before.
Cons of going to a framework:
a learning curve
you may have to approach things differently then you would normally
performance overhead (probably slight)
Pros (of a GOOD framework):
much of the mundane coding is already done
helps you write clear, compartmentalized code
libraries included to help you with security, database communication, etc
easier for other developers to jump into the project
bug fixes from the framework's community
The number one benefit of moving to a framework is that the people who developed the framework already solved (most of) the problems you would face if you would do everything yourself. I think this argument should be enough to answer your question.
If you need help in choosing a framework, stackoverflow has lots of already answered questions in this area. You should take a look at some of the opinions already posted and decide what you need.
Why do you want to invent the wheel over and over again? Building your own system is, in my opinion, only usefull if you want to learn how to build such a system and get familiair with the basics of a CMS. The problem with it is that you have to do all the debugging yourself which will take ages. With a framework, other people already did that work for you, so you can make progress much faster.
There is no thing like a best framework. I have worked with Zend Framework and Kohana 3. Both are really nice frameworks but if it was up to me I would take Kohana. Remember there are many more frameworks and this is not a complete comparison. Just give it a google and choose the one you feel most comfortable with.
Good luck!
I would suggest the Zend Framework as per your requirement.Just look at site view futures,but it some what difficult to learn in start.But if you want customization then Core php is the best.For security you have to know the things some better way like sql injection & design the architecture according to it.For faster development you can also move to ROR.
Have Dream Day
Further to my comments, I find working with other peoples frameworks rather a procrustean endeavour. Because I wrote it, I know my framework inside out and can rattle code off very quickly whereas when I am coding for a popular framework like CodeIgniter, Zend or Symfony it takes me that little bit longer to remember how I'm supposed to do something in the way they want me to.
Of course, a lot of the hurdles, common tasks and security issues will have been encountered and solved for you if you use a framework. However, if you've already written a large part of the website code then refactoring it to leverage a framework could be quite a substantial undertaking unless you've been quite clever with your initial architecture and have things loosely coupled.

Solar PHP framework

We are currently looking joining an open source PHP farmework project instead of continuing to work on our own PHP MVC code. Likely candidates are Yii and Solar, because they appeal to our own coding style, have tackled issues that we feel need tackling.
I realize there are plenty of PHP frameowrk related questions on SO already. However, I'm having a really hard time finding people that actually use one of these (esp. Solar) in a real world environment.
So, my question: did anyone work a real life project with one of these? How did it work out for you? What were the major issues?
I'm not looking for benchmarks or excitement about the theories behind each of these. It's clear that their creators of both frameworks did a tremendous job. What I want to know is:
did you use it?
did you like it?
pro's and cons based on real world use?
I use Solar daily for internal applications at work and personal projects at home. It is a top-notch, solid framework that I can highly recommend to anyone. It is in beta3, but stable should be coming along in the next couple of months.
A common criticism is the lack of documentation. I am happy to say that that is changing rapidly. New documentation is being written daily. In fact, two new chapters are already up.
A great way to get involved in Solar, or to get questions answered is to visit the IRC channel #solar-talk on freenode, or join the Solar Talk mailing list.
Visit the Solar website for all the info.
I can't comment on Solar or Yii because I've never used them. When I've given both a cursory look, they did not seem as stable as frameworks I've used before. I've developed with CakePHP for years and have run into the PHP 4 barrier with it, where continuing to develop for PHP 4 does not make sense any longer. Ultimately, it just costs more money.
If you are looking for a framework to build upon, I would recommend looking into the following:
Zend Framework
Lithium
All are very modular by nature (including Solar and Yii), with support for integrating excellent tools like the Doctrine ORM. Some assume Doctrine is your ORM of choice. Honestly, it should be.
ZF is decidedly PHP5 only, which I like. I also appreciate the modularity of it. I can create a base "project" and then add individual "apps" to it, each with their own models/views/controllers. You can also use its classes/features individually without the entire framework bootstrapping process. It is backed by Zend, and is very mature -- I'm assuming because so many trained eyes have used and improved it. The consequences of this are fantastic: just browse through the web site, follow the quick start and look at the available components in the reference guide and you'll see what I mean.
Lithium was forked off from CakePHP's Cake3 project, aiming for a framework with support only for PHP 5.3 and PHP 6. It is decidedly PHP 5.3 only, which means it has hitched its wagon to the newest stable PHP with the most features, such as anonymous functions, a native MySQL driver, and much more. Worth looking into if you are able to move your team to a PHP 5.3-only environment, especially if you have people who know the value of more modern programming techniques found in languages like Python or Ruby. It is a young framework, but has much of the same talent behind it that CakePHP has had, so that gives it a huge thumbs up in my book.
I've used Yii a bit now and have found that it's worked quite well for me. The main con against it is that it's still relatively new and most people haven't heard about it.
That said though, if you were to pick it up as your main framework, that would help it become better known and you might even consider helping Qiang with some development work.
Just when you are deciding, make sure you've had a look through the issues list to make sure that you are aware of what the current bugs are, and what the upcoming features/changes will be.
I can't comment at all on Solar.
I've worked for a handful of digital and new media design agencies in the North East of England for a couple of years now and have yet to come across an instance of the development team using a framework.
Most web design and development agencies these days favour creating their own framework or CMS; I guess it's a form of validation for them. They don't feel they're worth their salt unless they can develop their own systems and solutions from scratch. Hell, I'm the same and have build my own CMS!
The advantage of using an existing framework is that development time is reduced as commonly-used libraries and helpers are already pre-built and ready to be implemented. However, the use of a framework can easily become a con if the framework used isn't commonly known.
So for instance, if you use an obscure framework like Solar that not many developers are familiar with, any other developers working on your sites are going to have an additional learning curve, which in turn increases development time; the opposite of the desired effect.
Hope this helps you. Commonly-used PHP frameworks out there at the moment include CodeIgniter and CakePHP.

What framework(s) would you suggest for a strong, extensible dev platform? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
First, let me apologize for Yet Another Framework Question. But I think this is different enough from the usual "What framework should I choose?" to warrant it.
Here's my situation: For the past year I've been using a custom framework. It's been used on everything from small CMS's to larger sites and even a mid sized social network. It's worked great but I now see its limitations. So, I've decided to switch to a 3rd party framework. The simpler frameworks (CI, Kohana, Cake) seem too inflexible from what I've heard - so this led me towards ZF. But, I've also heard that ZF may be too flexible and thus hard to work with. What further complicates this is that I'm looking for a one-size-fits-all solution; I need a setup that works on small projects to very large projects. I am the main developer, but I need my partner to eventually be able to learn the system and help with the less complicated programming tasks.
I've researched Doctrine and I love it. So I'm leaning towards Symfony (with Doctrine) as the main framework with ZF to fill in the gaps. Plus, I need the ability to add my own pieces to this platform parallel to any 3rd party libraries. I hope this will provide me with a solid, extensible platform, as we really can't afford to be switching out frameworks every few projects.
I'm looking for advice from others who have been in the same situation as I am in now. Any advice would be greatly appreciated.
Edit: I've posted my solution below in hopes of helping other people in the same situation
After some research I've decided to go with Symfony. Here are my reasons:
Less verbose than ZF
Seems very customizable due to usage of YAML files (yet I never feel overwhelmed by them)
Autoloading of custom classes doesn't require any extra work like in ZF (albeit it's not hard to set up in ZF)
The developer toolbar is great, and they're adding some nice features to it in ver 1.3
The ability to use pieces from other frameworks (ZF, eZComponents) makes me feel confident that I won't have trouble finding what I need
Comes bundled with Doctrine and is very easy to set up (in fact Doctrine will become the default ORM in ver 1.3)
It seems like there's a much larger community for Symfony. Google "symfony tutorials" versus "zend framework tutorials" and you'll see a massive difference in the number of results
Plenty of documentation: tutorials (the Jobeet tutorial so far is very good), API references, and a more human readable description of the framework and its underlying principles
Yahoo! has used it for a few of their own projects - it's nice to see a Big Name back a framework IMHO
Edit: For the sake of hopefully helping others in the same situation, here are some things I don't like about Symfony:
Does not follow the PEAR naming scheme (ZF does)
Internal classes begin with "sf". This is contrary to the practice of capitalizing the first letter of the class name
Variables and functions are written_like_this, yet class methods are camelCased - this seems sloppy to me
These are all cosmetic issues though; things that bother me because I like to do things my way. I realize that whenever you use third party software you must be willing to make some sacrifices.
ZF is certainly a nice framework, but I feel using Symfony as the primary framework and extending it with pieces of ZF is the best choice for me and my team.
Edit
It's been 2 years since originally posting this, and since it's still getting hits I thought I'd give a quick update. I probably built about 25 - 30 projects using symfony 1.x in the last 2 years, and I'm very happy with how it performed. As a full stack MVC framework, partnered with Doctrine, it handled almost everything I threw at it. And whatever it couldn't handle, it was easy to add my own custom code. In fact, that's what I love most about symfony - how easy it is to extend. I ended up building a bunch of plugins and Doctrine behaviors that greatly reduced development time. And the admin generator tools have been a god-send. I'm still using symfony 1.4 for a few projects here and there, but have decided to mainly focus now on using Symfony2. It's a completely different beast than symfony 1, but I really appreciate its architecture. More importantly, it seems even easier to extend than symfony 1.x. I do miss some of 1.x's features, but that's the sacrafice you have to make when switching frameworks.
I like using ZF because of strong conventions. You can be sure, that everything will be as you expect it. Class names, function names, variable names, directory structure, ... all of it. It really speeds up the development if you stick to it. If you adapt it it's more like looking into your own code, when checking the ZF internals ;)
Let's be honest. ZF is not fast. Not as fast as Nette, CodeIgniter, etc. But the difference is that there is a class for everything. And if there is not, there is a class you can extend or interface you can implement.
All the other frameworks try to gain on the "wow" effect (blog in 30secs, twitter in 2 hours, etc). But when develioping a real life application, you realize, that it's the use at will, flexible and extensive architecture, that you need.
Zend Framework: Huge, Flexible, Modular.
I'd use only if am building a enterprise big ultra system.
But, I'm using Yii Framework and I like it.
Because: Very Fast, Simple, Widgets (easy to reuse component, this is very nice).
Yii it's easer to use, because is not a enterprise framework, and have all Basic features you really need in most cases.
*
EDIT: Now that I nearly understand HOW
to improve the ZendFramework using
your own code (as asked here Adding
3rd Party lib to Zend and here
Using 3rd Party lib within Zend),
I switched back to ZendFramework. I
currently design my application and
each day which I work and test
anything with ZendFramework it gets
more and more familiar and it easily
quickens my developement. My advise:
Use ZendFramework.
*
I have currently the same problem:
My story:
I was using CakePHP until I wanted to expand my project's size.
CakePHP was not as flexible as I wanted it to be.
So i tried to use ZendFramework.
The very first time I read the 'QuickStart' guide, i was a little bit afraid of having that much files for a simple guestbook application.
After a time of 'playing' with the ZendFramework I decided to use ZF as a 3rd party lib in my own custom framework.
The problem is, IF you use Zend's MVC components you might be forced to use 30% of the whole framework, because the MVC components are one of the biggest part of the ZF.
I mean if I use that much of a framework WHY shouldn't you use the rest, too?
After that, I decided to write my COMPLETE custom framework without using ZendFramework as 3rd party lib.
Now I am sitting in front of mountains of papers, full of sketches about code design.
I will keep you up to date about my further decisions.
I honestly think it really depends on your style. There's no end all be all answer to this question.
ZF relies heavily on classic and proven design principles. It's also very extensible, but requires more "configuration" than "convention". I personally do not trust 3rd party code by nature, so I'm a fan of more verbosity, for the sake of being more familiar with the technology I'm working with. But that's just me.
I've also used CakePHP successfully and two other frameworks proprietary to a company I worked for with great success. They're all trying to do similar things, just pick what feels best for you.
I've personally used CakePHP successfully for both large and small projects, however it is often difficult to make it budge the way you want. My reasons for using Cake continue to reside in the fact that the community support is top notch, the security updates are often, and they do not force meta-packages (such as unit testing) upon you (although this is bundled, you can just bin it if you're not interested in using the built in package).
Altogether, it's made a nice system for me over the past few months, however I have heard time and time again that Symphony is fantastic, so you may perhaps be on the money with your first thoughts. With NetBeans support for Symphony in the pipeline, I may too find the need to switch before long.

What's a good way to encapsulate data access with PHP/MySQL?

Most of my experience is on the MSFT stack, but I am now working on a side project, helping someone with a personal site with cheap hosting that is built on the LAMP stack. My options for installing extras are limited, so I'm wondering about how to write my data access code without embedding raw queries in the .php files.
I like to keep things simple, even with .NET. I generally write stored procedures for everything, and I have a helper class that wraps all calls to execute procedures and return data sets. I'm not looking for a full-blown ORM, but it might be the way to go and others who view this question might be looking for that.
Remember that I'm on a $7/month GoDaddy account, so I'm limited to what's already installed in their basic package.
Edit: Thanks rix0rr, Alan, Anders, dragon, I will check all of those out. I edited the question to be more open to ORM solutions, since they are so popular.
ActiveRecord seems to be the state of the art at the moment. I can't recommend any good PHP frameworks for that though. I tried Propel which, while nice, is not easy to set up (especially on a host that you can't install anything on).
Ultimately, I rolled my own ORM/ActiveRecord framework, which is not too much work and very instructive. I'm sure other people can recommend good PHP frameworks.
Take a look at the Zend Framework, specifically Zend_Db. It has a Database Abstraction layer that doesn't require anything other than the MySQLi extension to be installed and isn't a full-blown ORM model.
Maybe Doctrine would do the job? It seems to be inspired by Hibernate.
rix0rrr hit on it a bit, in that many tools are a pain to set up. Of course, I have my own solution to this problem that has been working quite well for the past few years. It's a project called dbFacile
I also wrote a bit of a usage comparison of the tools I found a few years ago. It's incomplete, but might give you a good starting point.
You mentioned that you don't want to embed raw queries but you don't want ORM, so I'm a bit confused about the middle ground you're hoping to find. I also have an ORM project that aims to require minimal setup and great ease of use.
The only requirement for my projects is PHP5.
I would try a framework. Zend Framework has been cited. Symfony seems interesting. It's based on ideas from Ruby on Rails.
You could also take a look at Prado. http://www.pradosoft.com/ It uses Active Record and DAO. Also if you use .Net then some of the formatting and conventions are similar.

Categories