Live data from Hacker News

How I Build PHP Applications

ericharrison.info

1–10 of 56 posts

Re: How I Build PHP Applications

#3
I like this kind of post, but its not a topic I care too much about anymore. Like the author php pays my bills too, and most of my work is done alone. He doesn't like frameworks for reasons I don't like frameworks, abstractions are leaky. I still use frameworks because I'd rather have a team of people work on some of core features I use (orm, url routing, view engines) then just myself. I've also found that some php frameworks's abstractions are leakier then they should be (cakephp, and symphony come to mind).

The reason I don't care is that I'm moving on, and now php seems like such a mess. I used to not mind the arrays, the lack of proper objects. The oddly named functions. The years of backwards compatibility. I've been learning python over the past few weeks and using it for a few projects and I'm in love. Next up is probably Ruby but it looks like perl to me so I'm in no rush.

I feel like python is a better language because I'm better. Exposing yourself to different ways of thinking lets you pick up methods that work better then you knew before. I didn't even know what I was missing.

Re: How I Build PHP Applications

#4
I didn't know Ellis Lab had codeignitor.com pointing to codeigniter.com! From the article, I can only say the author didn't try CodeIgniter for a couple of hours otherwise he would know you are free to do pretty much whatever you want with the framework. I do use CodeIgniter for all my projects and I do write my own queries most of the time (I'm a query performance geek). I think the only thing you are not free to run away from is controllers but that's the basic structure of a (MV)C framework.

Re: How I Build PHP Applications

#6
post #4

I didn't know Ellis Lab had codeignitor.com pointing to codeigniter.com! From the article, I can only say the author didn't try CodeIgniter for a couple of hours otherwise he would know you are free to do pretty much whatever you want with the framework. I do use CodeIgniter for all my projects and I do write my own queries most of the time (I'm a query performance geek). I think the only thing you are not free to ru…

It's also one of the smaller frameworks compared to Cake, Symphony, and the other rails-on-php frameworks so I'm not really sure why the author singles it out as "large" framework.

Re: How I Build PHP Applications

#7
post #3

I like this kind of post, but its not a topic I care too much about anymore. Like the author php pays my bills too, and most of my work is done alone. He doesn't like frameworks for reasons I don't like frameworks, abstractions are leaky. I still use frameworks because I'd rather have a team of people work on some of core features I use (orm, url routing, view engines) then just myself. I've also found that some php…

Do you use a framework for python or do you code it all from scratch ?

Re: How I Build PHP Applications

#8
post #3

I like this kind of post, but its not a topic I care too much about anymore. Like the author php pays my bills too, and most of my work is done alone. He doesn't like frameworks for reasons I don't like frameworks, abstractions are leaky. I still use frameworks because I'd rather have a team of people work on some of core features I use (orm, url routing, view engines) then just myself. I've also found that some php…

As a python programmer who will probably have to use php on an upcoming project, I'm wondering if there are any php frameworks you can recommend.

Re: How I Build PHP Applications

#9
I use something similar to his /index.php solution and it has worked great for me. My .htaccess ends with:

    ### Disable direct access to *.php except main index.php
    RewriteCond %{REQUEST_URI} \.php
    RewriteCond %{REQUEST_URI} !^/index.php
      RewriteRule ^(.*)$ /index.php [L,R]

    ### Run the main /index.php controller file
    RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule ^(.*)$ /index.php [L]
In my index.php, I include my common functions and then call the appropriate file/class depending on the hostname and url. I don't know why he dirties with index.php call with: path=$1&%{QUERY_STIRNG} - that information is available in $_SERVER[] variable.

What this overall approach really means is that there is a single entry point for every single thing in my app. I can manage sessions, db, custom functions, login/admin, handle apis etc. through one piece of code that is (selectively) executed for every single request. I can also shutdown the entire site and all the operations with a "sorry we're down for maintenance" if I need to. I don't even store my php files in /www folder so you can't even access them directly. This approach can easily handle my traffic - 10k uniques/day on average, 100k/day on special events.

Post reply on HN