Ask HN: I program in pure PHP - Should I be doing something different?
I graduated from a state university with a degree in Marketing, but I started programming as a junior in high school. Besides a few high school courses, I have no formal training and program for the web in php with no frameworks (except jquery for javscript/ajax functions).
I see a lot of rapid development discussion and I like cranking out relatively simple websites quickly, but I think I am limited by the programming techniques I am using. For example, I programmed (isWearing.com and SmarterFootball.com), and I used a lot of the similar features into a prototype I made this past week (foodmarkit.com). All three sites are relatively uncomplicated (mostly database driven), but it took a long time to recreate the same basic processes. I'm assuming "there's gotta be a better way". So... what is out there?
I've heard a lot about django, ruby on rails, pythong etc... What do you think is the best option for me and rapid development?
(
17 comments
| 6 points
| on HN
)
You will not be as productive end-to-end on day 1 as you are with your current tools - that's OK, because after learning a framework, you will be more productive than pure hand-coding for any web-app of any complexity. You'll likely be safer, because there's been more effort put in to most frameworks to help protect against web attacks (SQL injection in most cases).
Learning a framework will teach you to think differently about your development process, as well as introduce you to a community of like-minded developers all using the same tool. It will help you develop a development process.
You'll get to the point where you're comfortable and productive, and then you'll start noticing limitations in whatever framework you're using. That's the time to start looking for another one, and either jumping over to using that, or more ideally, looking at what ideas and components you can reincorporate in to your current tech stack.
I love Grails (Java) because, while it's niche, it makes model-drive development a snap. I create classes, identify relationships, and the system can generate the db layer (tables, etc) for me automatically. There are ways to do some of this in PHP, but the language itself makes this extremely verbose. However... I still use PHP (now using zfkit as a basis) for some projects, and have done some .Net work where it made sense (on an MS-only project, to be precise).
It's easier to jump around now because I've spent time understanding not just the particular languages involved, but thinking about how web apps are commonly abstracted (MVC, service layers, db layers, etc). Understanding those common patterns makes it easier to swap between frameworks and platforms as needed.
Gentle plug - I'm working on a starter kit for zend framework - zfkit.com - which aims to bring a somewhat better 'out of the box' experience to ZF (at least from my perspective). You can download and it's bundled and preconfigured to use the Doctrine ORM tool. That said, if ZF and Doctrine rather make you say "huh?" it may not be for you just yet. :)
Another way to go would be to learn a ORM (doctrine) and a templating engine (tinybutstrong or smarty). I have never done any big php project without the help of frameworks, but some of my work friends find this approach (templating engine + ORM) more easier and better. I can't agree with them, though.
Frameworks are not all about rapid development. If used properly, they structure your application and make it easier for maintain.
Taking this route will also help you realise what you like and don't like about PHP. THEN, you will be in a better position to judge if something like django or ruby on rails would suite you better.
http://www.yiiframework.com/
Two types of frameworks : "Full stack" and "glue" "Full Stack" are more automated and 'easy' to start and create CRUD. "Glue" are more powerful, full of libraries but less automated and a learning curve more demanding.
Full Stack - Cakephp - Symfony - Kohana - CodeIgniter
Glue - Pear - Zend Framework
The two extremes are Cake and Zend Framework
If you want to stay with PHP try Kohana. If not, Rails (Ruby) or Django (Python) are the best out there.
I recommend you to stop deciding and start doing something with one of these.
Catalyst framework, Mason and TT templating works quiet well for me even with existing static site rewrites. The templating also helps me manage many other text files,like invoices. For a CRUD the external database can reuse the nicely generated Schema and Model classes.
catalyst is written in perl and parts of it in c.
I also used php4, django, pylons, and zope and find catalyst the lesser problem when moving from webservers to webservers, version to version, config to config etc.
You will love it, and I bet you'll enjoy python! :)
[1] http://webpy.org/
[2] http://pypi.python.org/pypi/Jinja2
Are you using Drupal? if you are doing a lot of the same boiler plate it may be because you are not using a CMS that will allow you to reuse components across sites. Something like Drupal may help you to make your UI components more reusable while still allowing you to use PHP.
I use a variety of languages and frameworks, and CodeIgniter is the closest to what you described you're used to with some great boiler plate code. I've done everything from simple one off CMS apps to very robust multi site automated apps, all in Codeigniter.
Check it out, it's easy to get started with, you don't need the command line, there's no magic. Just helpful code.