It's a bit of a Catch22 as well. We switched to using PHP for our agency client work because it was easier to hire developers. Not only that, but clients actually ask for it by name (and we lost a number of jobs because we didn't want to use PHP). The cycle continues.
If you create an app for someone in rails or django or luanode or some such then they are on the hook for maintaining it if you go away or find other work or just don't want to support it. And it's much harder to find devs for those stacks than it is to find PHP devs.
I have to admit that I've turned down potential freelance stuff when the customer requests PHP (or has signed up for a service that only allows PHP).
Of course, I have a full-time job, and the freelancing is usually to pay for a new guitar or something. Your situation is probably different from mine, and needs must.
I don't mean to belittle you or anything like that, but isn't it your job to consult the client on the best tool for the project? If they are adamant on using PHP, when it's clear PHP isn't suited, perhaps that implied an awkward client.
Not really, they look at it the same way - we're building something for them they need to support long(er) term. It's a pretty simple business decision really. A number of clients have been burnt in the past by having to support something a bit esoteric. Often clients actually ask for Drupal (which we downright refuse to do) for that very reason. They want something that's they'll be able to find developers for.
Choosing the "best" platform for the client has both a technical aspect and a financial aspect. In most cases that I've seen in my 20 year career we probably could have gotten the job done with nearly any technology. The choice was ultimately down to whatever platform was most comfortable for the developers or, to be honest, just plain snobbery on the part of one or more of the team.
Of course there may be an ideal platform from a technical sense. I may have a project and I decide that it's 100% ideally suited for Scala. Using PHP may be only 85% ideal. However, is that really best for the client? Are they going to be forced to blaze new trails for things that are already solved in PHP? Is the client going to be able to find Scala developers when we leave? How about in 5 years? How much are they going to pay for that? Is it worth the 15% of efficiency that was gained?
There is no real correct answer here, but I guess my point is that when you are talking about what's "best" for the client, it's not always just a technical question.
Well, yes, but awkward clients are still clients (read: people who give you money). Some of the consequences of the mentioned effect are that you may be forced to work with awkward clients or employers, or make otherwise awkward decisions.