Ask HN: Thoughts on PHP frameworks?
I haven't used a framework since.
I have become complacent writing everything from scratch. I have a ton of PHP code that I reuse in a lot of my projects which saves me a lot of time. Scaffolding is a time saver too. Here are my pros and cons of each.
Pros --------------- 1. More secure. Your code isn't available for the world to see. If there is a hole, it will take a lot longer for an exploiter to find it.
2. You know every character of code...since you built the darn thing!
3. If you want to know how everything works, you don't have to look over some other dude's 10,000 lines of code.
Cons --------------- 1. Not as simple to code (most of the time)
2. Cool features specific to that framework have to be implemented by hand
What do you guys think? Am I too independent with my code?
1. I was naive to think that my code would be better than the code of an established frameworks that have undergone through extensive testing by a big community.
2. It's a lot harder to bring people on board to help with coding. I can navigate my code very easily, but many people who are used to how to do things in a framework found it very hard.
3. Without the help of a community, I had to code EVERYTHING myself. There is no gem or plugin to install, which will REALLY help speed things along. In a startup environment, speed is a real competitive advantage, every bit of speed you can gain over your competitor should be pursued. I can't stress this enough.
4. When you run into serious problems, Google search is unlikely to help if you don't use a framework. You're likely the only one with that problem. Whereas if you use a framework, there's a very high chance other people have run into the problem before, and the error thrown out will be in a Stack Overflow or a bug tracker somewhere. Your life will be much easier when trying to track down serious bugs.
I used to use PHP for about 5 years, and I think the problem with PHP and frameworks is that there are so many frameworks around, and we just don't know which one are the one to use. So many developers have this question. Code Igniter or Kohana or CakePHP or... 20 other frameworks out there? It really sucks when you have to put in the time to figure out which frameworks work for you, and it's one of the reasons why people don't use a framework in the first place. Where as for Python, Django is a clear winner and Ruby, there's RoR. Those languages have many other frameworks too, but they have a clear winner with a large community who could help you.
As for me? I'm now doing almost everything in Ruby and Rails, and not looking back. I feel very good about the way I work now. I have become as good with Rails as I was with my own code, and it only took a few months. I suggest you give it another try. It will be time consuming at first, but it's very worthwhile in the long run.
P: 1. open source code is exposed to the whole bunch of users doesn't necessarily mean the code will end up unsecured, let's take it as we get lots of contributor around to find and patch those security holes. 2. once you get working with PHP frameworks understanding the code will be easy. 3. why not bother looking at the framework code if you get benefits on every work onwards?
C: 1. Most of the frameworks follow MVC separation, understanding that takes time, once you get the idea, writing code and using your existing code as plugins/libraries to the framework will be super easy. 2. The whole community is contributing, it will just take few posts in community forums or few minutes of googling to find the feature you are looking for. if you ended up coding the feature yourself, give it back to community. that is how you become part of the community and how the frameworks grow.
In situation when you need to hire someone to work on your codebase, use of available opensource frameworks will save a lot.
i will suggest any one of these frameworks to work with: https://github.com/tylerhall/simple-php-framework (structured code) http://codeigniter.com (easy to start with, very good documentation) http://www.symfony-project.org/ (nice documentation yet steep learning curve, once you get it as easy as CodeIgniter)
i personally appreciate your approach too, that is a lot of effort you put there, but if you don't feel like using frameworks such as Symfony/CodeIgniter etc.. at least you may want to workout your code in the MVC or HMVC structure.
Now (more like, since a week ago), I have started to use a template system. I am still writing most of the code myself, since the template is used to organize the code into in MVC manner.
The site I am using it @ http://peri.me/2B1A/
Even if you don't want to use a framework, there is no harm in using a template system. I use http://www.twig-project.org
Which framework did you use?
The introductory documentation and tutorial are excellent. The Jobeet tutorial walks you through how to create an entire application, with the Symfony developers' best practices being implemented right from the start.
Only con: I do have trouble at times finding answers to the obscure questions I have. There seem to be a lot of forum threads about Symfony, but not quite so many answers. If you can find an experienced Symfony developer, I highly recommend talking to them and getting a few pointers in the right direction. That said, I think it's a great framework, a little on the old side in terms of style, but still quite flexible.
I also go back and forth between framework and homegrown. I've done homegrown for years. Framework does have the advantage that you get to use a lot of code others spent time on, so I'm sticking with that for now.
I dislike the Yii approach (it generates code based on your db). Don't think it's necessary, I have no problem coding and optimizing some mysql queries, no need to hide that behind a black box.
The way Components and Behaviours are used throughout the system makes it very easy to combine and plug in disparate modules of code, and it's the most Rails-y framework I've found so far (barring CakePHP which appears to have come leaps and bounds in the last couple of years since I used it last).
(In summary, it matches how I want to work. :) Keep looking until you find something that does the same for you.)