Question

Im looking for some clarification to my understanding of client and server side languages.

I am starting a new project and want to decide if I should implement a client-side framework like angular or ember.

When I started to dig into it, the difference between client side and server side rendering came into question.

My understanding (most likely flawed) is that php becomes quite obsolete because all you need to use it for is communicating with databases and passing json to angular.

PHP's main draw was that you could render html on the server side alongside html, but this no longer is necessary.

With the introduction of client-side frameworks, is PHP still worth using?

Était-ce utile?

La solution

You'd want to use PHP in a few scenarios; note that this list is not exhaustive. It's also worth noting that there are obvious things, like generating the responses for client-side frameworks which I will largely ignore.

When security is important; If you have something that needs to happen and it can't be tampered with, keep it on the server side. Never trust users.

When generating page content. Search engines can't afford to execute every script they encounter, so they only parse the raw HTML. If absolutely everything relies on dynamic scripting search engines will not see any of it. Also, your users might not be able to use Javascript.

When clients have low-end devices Especially with early screenphones or netbooks that don't have huge amounts of horsepower, Javascript can become very intense for these devices very quickly. The more work you offload to the client, the slower the site will be to them. I've seen some java-heavy websites bring the whole device to a crawl. Older browsers without the latest JS engines can be horrifically slow. I have a relatively expensive phone but I've mentally blacklisted several sites because they destroy my device.

When stability is important. Unless you give PHP fatal errors, you can consider PHP pretty reliable compared to Javascript. If a page works for one person you know other people will get those pages. With Javascript, some browsers will halt the script if there's even a minor error or bad Ajax response without failsafes. Other browsers may not support Javascript in the same ways (looking at you, Internet Explorer 8-)

When you want more than just JavaScript-powered-pages. If you're using RSS, dynamic XML sitemaps, generated SVG images or generated CSS - you'll be using server-side to generate them because often there's simply no way to dynamically produce them otherwise.

Autres conseils

Client side frameworks will still require a server side to give it data. Plus, depending on the client's browser to be able to render your site the way you want is a big risk.

As for PHP, it all depends on what you want out of your site. If you want a large installed developer base to choose from, the PHP is an excellent choice. I like PHP, so I'll leave it at that. Others can put forth options if they feel the urge.

http://w3techs.com/technologies/details/pl-php/all/all

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top