Dear PHP,

SeanW

Janitor
Oct 9, 2007
88
4
0
Winterpeg
I can't do this anymore. We need to break up. It's not you, it's me.

We've been together since you were called PHP/FI. At the time I was involved with PERL&CGI and you offered something fresher and with fewer strings. I could query a database, draw graphics, and all in one file! And boy, were you fast!

But things have changed. I find it hard to remember how some of our past projects work, which makes it hard to fix them if they break. Lately I've been trying a few frameworks to help with this. But all these frameworks seem to run up against language limitations. After spending a couple of hours trying to get a method to run before each request in CI, realizing it's an ugly hack, and then finding out I can't even pass a model to the frapping view, I lost it.

I must confess. For the past year and a half I've been seeing someone else on the side. Her name is Ruby, and she's got a hot sister called Rails. Together, they make things fun again. They're a bit heavier than average, but I don't care. Things that take a dozen lines in PHP take 1 with Ruby. And the crowd they hang with are so much more agile!

I thought I could rekindle the love with CakePHP. But it's just a bad attempt at making you look like Rails.

This doesn't mean we're never going to see each other again. We've always got our old stuff together, and you are everywhere. And we'll always have WordPress.

So thanks for our decade or so together, it's been fun. There are lots of guys out there that love you, I'm sure you'll be OK.

Sean
 
  • Like
Reactions: mattseh and Fat Tom


I can't do this anymore. We need to break up. It's not you, it's me.

We've been together since you were called PHP/FI. At the time I was involved with PERL&CGI and you offered something fresher and with fewer strings. I could query a database, draw graphics, and all in one file! And boy, were you fast!

But things have changed. I find it hard to remember how some of our past projects work, which makes it hard to fix them if they break. Lately I've been trying a few frameworks to help with this. But all these frameworks seem to run up against language limitations. After spending a couple of hours trying to get a method to run before each request in CI, realizing it's an ugly hack, and then finding out I can't even pass a model to the frapping view, I lost it.

I must confess. For the past year and a half I've been seeing someone else on the side. Her name is Ruby, and she's got a hot sister called Rails. Together, they make things fun again. They're a bit heavier than average, but I don't care. Things that take a dozen lines in PHP take 1 with Ruby. And the crowd they hang with are so much more agile!

I thought I could rekindle the love with CakePHP. But it's just a bad attempt at making you look like Rails.

This doesn't mean we're never going to see each other again. We've always got our old stuff together, and you are everywhere. And we'll always have WordPress.

So thanks for our decade or so together, it's been fun. There are lots of guys out there that love you, I'm sure you'll be OK.

Sean

Repped
 
I loled.

Unfortunately I'm gonna be bangin PHP for awhile. I don't have the time to start up a whole new relationship right now, too much to do. Settling.
 
to my estranged love, php --

once, i knew you, and it was beautiful. youthful lust and a thirst for understanding brought me into your care when i first tasted the nectar from your bosum nearly a decade ago. sucking at your tit was sweet.

but alas, i left, and i don't regret leaving. i moved on to bigger, better women of increased performance and capacity, who didn't make me wave my hands in the air and talk very slowly, as if to a five year old. i was serious when i said i never wanted to see you again. how we've found ourselves here today is... troubling to my concious.

i don't like to mix business with pleasure. i wish you'd never found your way back into my life. but here we are, two and a half months into a relapse of judgement, and i can't even ask you to leave. that my workplace uses your services is unfortunate, but we want you to know that it's only because of your general availability on the market and your history of enabling even the least-fit of men to use you, bend you, break you, and throw you out. it's because of this kind of abuse that i sit here today, again trying to fix you, and again wishing you were gone.

words cannot express how i loath you, php, and even if you're here to stay and i can't remove you, i want you to know how much i hate you.
 
  • Like
Reactions: stumpyb
But things have changed. I find it hard to remember how some of our past projects work, which makes it hard to fix them if they break. Lately I've been trying a few frameworks to help with this. But all these frameworks seem to run up against language limitations. After spending a couple of hours trying to get a method to run before each request in CI, realizing it's an ugly hack, and then finding out I can't even pass a model to the frapping view, I lost it.


lol shitty coder shitty coder lol

Don't blame a tool, because you can't figure out how to use it correctly.
 
lol shitty coder shitty coder lol

Don't blame a tool, because you can't figure out how to use it correctly.

The job of a framework is to make my life easier.

CI, for example, converts everything in the array passed to the view to a string. This means I can't pass it something like "user" => current_user and then pull out current_user.address and current_user.name within the view. Instead, I have to break it out in the controller, or provide a model method. __to_string just doesn't cut it. Yea, maybe I could write a model method to convert the object to an array of strings to make it past that, but then I'm into other problems.

CI also doesn't let me do the equivalent of a :before_filter in ApplicationController without a lot of work. Google around for how to extend the Controller class to find all the different ways to do it. Why am I using a "hook" when all I want to do is override a controller? strace apache sometime when it's running a CI script, it's looking for dozens of files that don't exist, what's one more?

Rails, on the other hand?

Code:
class ApplicationController < ActionController::Base
 around_filter :persist_current_user

 def persist_current_user
   @current_user = User.new(session[:user_info])
   yield
   session[:user_info] = @current_user.to_h
 end
end

I'm sure CI is great -- the reason I gave it a try was because of a quote from Rasmus saying he doesn't like frameworks, but if he had to choose one he'd go for CI.

PHP works, but it's not fun anymore. I always feel like I'm reinventing the wheel, and the language itself isn't elegant. Frameworks solve the first problem, but they always run into the second.

I'm beyond the need to prove my macho by going through crap just to do what I want. I just want to get the code written and enjoy myself at the same time.

Sean
 
The job of a framework is to make my life easier.

CI, for example, converts everything in the array passed to the view to a string. This means I can't pass it something like "user" => current_user and then pull out current_user.address and current_user.name within the view. Instead, I have to break it out in the controller, or provide a model method. __to_string just doesn't cut it. Yea, maybe I could write a model method to convert the object to an array of strings to make it past that, but then I'm into other problems.

CI also doesn't let me do the equivalent of a :before_filter in ApplicationController without a lot of work. Google around for how to extend the Controller class to find all the different ways to do it. Why am I using a "hook" when all I want to do is override a controller? strace apache sometime when it's running a CI script, it's looking for dozens of files that don't exist, what's one more?

Rails, on the other hand?

Code:
class ApplicationController < ActionController::Base
 around_filter :persist_current_user

 def persist_current_user
   @current_user = User.new(session[:user_info])
   yield
   session[:user_info] = @current_user.to_h
 end
end

I'm sure CI is great -- the reason I gave it a try was because of a quote from Rasmus saying he doesn't like frameworks, but if he had to choose one he'd go for CI.

PHP works, but it's not fun anymore. I always feel like I'm reinventing the wheel, and the language itself isn't elegant. Frameworks solve the first problem, but they always run into the second.

I'm beyond the need to prove my macho by going through crap just to do what I want. I just want to get the code written and enjoy myself at the same time.

Sean

I'll admit I don't know crap about CI (assuming Code Igniter?) , but from what I saw in google the proper way to do it would be creating a file called MY_Controller in the libraries directory that extends Controller. All your controllers will then extend it.

I'd assume something like

MY_Controller extends Controller
{
// stuff here
}

Some_Controller extends Controller
{
// stuff here
// call method here in MY_Controller
}

CI is using a "Cascading File System" which is why it's looking for files in different place, which is why the above solution should work and be the proper answer.

As far as the views are concerned I have no clue why they'd do that other than bad design or you're doing it wrong. That makes no sense for them to convert everything to a string. That should be left up to the programmer.
 
I'll admit I don't know crap about CI (assuming Code Igniter?) , but from what I saw in google the proper way to do it would be creating a file called MY_Controller in the libraries directory that extends Controller. All your controllers will then extend it.

I'd assume something like

MY_Controller extends Controller
{
// stuff here
}

Some_Controller extends Controller
{
// stuff here
// call method here in MY_Controller
}

CI is using a "Cascading File System" which is why it's looking for files in different place, which is why the above solution should work and be the proper answer.

As far as the views are concerned I have no clue why they'd do that other than bad design or you're doing it wrong. That makes no sense for them to convert everything to a string. That should be left up to the programmer.

Indeed I did that. And spent a while stracing apache to find out exactly what the file name should be called. And when I got that, the capitalization rules aren't obvious if you are trying to use multiple words in your class name (eg, ApplicationController).

After figuring that out, I had a controller in one directory that derived from a controller in a different directory, which is not at all obvious to a third party. And I still had to go through the hooks system to run a function before the controller gets fired, which happens in yet another file.

And all data that gets sent to the parser in the Parser class gets treated as a string with a str_replace, unless it's an array in which case it's recursively converted to an array of strings.
(EDIT: I'm using the CI template language, so maybe it would work if I went with straight PHP in my view. But fuck, once you try HAML/SASS you don't want anything else)


PERL has a wonderful philosophy: easy things should be easy, hard things should be possible.

Sean
 
Are you saying a filter before the base controller is fired or before the controller you're calling is fired?

I believe their reasoning is if it's a hook it's a hook and doesn't belong in the controller / model / where ever it belongs in a hooks directory. It does seem confusing at first glance, but from reading their docs for a min it kinda makes sense and should really make sense to anyone that's used the framework. I disagree with some of what I read, but then again I didn't read the reasoning behind it either.
 
Are you saying a filter before the base controller is fired or before the controller you're calling is fired?

Since the action specific controller is derived from the base controller, it's all pretty much the same. All I'm trying to do is reconstruct some information based on what's stored in the session, render a page using the updated information, and persist it back to the session when it's done.

I understand what they're doing, it's just not obvious from looking at the code. You've got code in the controller, code in the base controller (which is somewhere else), code that runs as part of the request cycle (which is in a third place) that is set off by a config file in a fourth place.

Contrast this with the Rails way of putting it all in the controller (and having the base controller right alongside all the other controllers) and you can't help but see it even if you don't understand what it's doing.

I could probably bitch about Ruby and Rails for days (like the bug that makes $1.01 rounded to two decimal places change to $1.10, not helpful when you're WRITING A FUCKING PAYROLL SYSTEM), but after a particularly exasperating day with PHP I figured I'd write a light hearted breakup letter.

Sean
 
lol shitty coder shitty coder lol

Don't blame a tool, because you can't figure out how to use it correctly.
You're a dumbass - You googled his code problem with a framework you've never used, found half of a wrong answer, then called OP a shitty coder. QFT.

-Rep
 
You're a dumbass - You googled his code problem with a framework you've never used, found half of a wrong answer, then called OP a shitty coder. QFT.

-Rep

Sorry I don't know every fucking framework for PHP. I was responding to the part that I quoted dip shit. The part saying he couldn't remember wtf his code did after a period of time. Doesn't matter how good you are at programming if you can't / won't document the code.

-rep for being too stupid to follow a thread.
 
I understand what they're doing, it's just not obvious from looking at the code. You've got code in the controller, code in the base controller (which is somewhere else), code that runs as part of the request cycle (which is in a third place) that is set off by a config file in a fourth place.

Contrast this with the Rails way of putting it all in the controller (and having the base controller right alongside all the other controllers) and you can't help but see it even if you don't understand what it's doing.

Honestly, with CI you can put them all in the same folder, but then you'd have to extend every controller with the name of the controller instead of just Controller.

The only real purpose this serves is organization, but that doesn't mean it's a good way to organize the files.
 
Don't do "user"=>current_user...

Code:
$user = $this->user_model->get_user(0);
echo $user[0]->address;
 
Rails is succeeding because those guys managed to get all the crowd behind one single framework, because Rails itself was released as "the" framework.
In contrast, the world of PHP frameworks was, and still is, fragmented, with Zend, CI, CakePHP, Symfony, god-knows-what-is-next, etc.

Second reason: Rails effectively meant just David Hansson and his 37signals, so it was easy to set the path, as opposed to the different PHP groups and companies which were (and still are) trying to grow by cannibalizing each other.
 
Fucking retards that need frameworks, lol.
Pretty much this.

If you've been around computers for more than (how old is Ruby on Rails again?), you'd know that MVC has been around since the 1970s (long before Facebook and Web 2.0), that MVC is nothing new, and that essentially when you're creating any type of (web) application, you're essentially applying MVC.

And in all honesty, you are a shitty coder if you can't roll your own slim and to-the-point MVC framework (if you really need to). OMG brb scaffolding (really? rofl). Unless you work for NASA with 500 other coders on the next gen shuttle OS, ANY framework is 99.9% overkill.

Of course, it makes shitty coders think they are good (or was it cool?). I shouldn't generalize, though: there are probably a LOT more shitty PHP coders than there are shitty Ruby coders.

But people that hate any language are the kind of coders that hate C because they don't understand it's a systems programming language or they hate Java because they don't understand it's a WORA language. I.e. shitty coders.

The no-framework PHP MVC framework - Rasmus' Toys Page is a good read.