Using PHP 7 for a new project in 2017

And when it comes to wtiting apps that scale or can natively handle multi-threading, it is hard to compete with .NET. .NET makes it dead simple and based on https://trends.builtwith.com/framework, .NET has roughly 21% and PHP has 26%… so… /shrug.

Enterprises typically lean towards Java and or .NET, whereas, most small to medium businesses or just basic websites, lean towards PHP. Not because PHP is better, but because getting it up and running is easy and takes minutes versus hiring a good server admin too oversee the architecture/server configuration.

I actually know of a few fairly large companies that are Ruby too (CoverMyMeds, for example). They were just acquired for 1.1 billion dollars (yes, that is a ‘b’).

2 Likes

If that was even remotely true, we wouldn’t be seeing these parrot articles would we?

1 Like

Sorry, I couldn’t resist when I read that, just yesterday I watched a funny video: Episode 1 - Mongo DB Is Web Scale and now I’m over-sensitive to the word scale. And another one: Node.js Is Bad Ass Rock Star Tech. This one might also be relevant: Episode 2 - All The Cool Kids Use Ruby. :smiley:

They should be taken with a grain of salt, of course, but nevertheless I think they convey an important message…

These are very good points, I started designing websites a long time ago (2000) using Microsoft Front Page and, yes I know now just how bad an idea that was, however it did enable me to build my first few sites, come 2005 I had been reading about PHP and how it interacts with websites and databases etc for things like HTML form processing and storing information to databases and so on, as time went on I learned about design patterns, object oriented programming (OOP) as well as best coding practices for PHP, by this time I had my own web hosting account so was able to actually upload sites and make them available on the internet, this is when I ran into limitations. to answer the Ops question I use the version of PHP that my web host uses which at the moment is PHP 5.6, this is one limitation you may run into, I also now use PHP frameworks to help speed up site development and helps me stick to the best coding practices and enhance security for my sites. PHP is a very useful language to learn but because it is loosely typed I would recommend starting to write PHP with security and best coding practices in mind from the start, there are plenty of free tutorials out there to help you build your first sites properly

I hope this helps you and good luck in the future

True, there are. But unfortunately there are also many tutorials out there that teach poor coding and legacy standards, and for a newbie it can be difficult to differentiate between a good and a bad tutorial, so do be careful where you lean from.
I see so many posts by people just starting out with php who are using code that was bad 10 years ago and wonder, if they are new to this, where are they getting this from? Bad (old) tutorials, that’s where.

2 Likes

Yes this is very true, it took me a while before I figured out the good tutorials as opposed to absolutely terrible ones

Oh, no, there are other languages that scale well too. I recently wrote a Node.js app that has little to zero problems scaling, it isn’t multi-threaded though (didn’t need to be either). I also have seen several Ruby applications that scale well, but also are not multi-threaded. So yes, you can scale just able any language, how you scale it and the requirements you may have, may direct you to a specific language that is best suited for the job.

When I’ve deemed .NET to be a good fit for a job, I’ve had zero issues in scaling it and making full use of its multi-threading ability to squeeze every bit of performance out of the servers it runs on. If our CPUs and RAM usage are not 70-80% all day long, I worry we did something wrong, but the apps we have in .NET are meant to do processing all day long.

I’m a big fan of Ruby and Node. Heck, I still have a soft spot for PHP too (still no love for Java though :laughing:)

still no lover for Java though

You should, since C# was created as its clone. Think of it like .NET, without a few extra bells and whistles, but isn’t mostly running on an awful backwards GUI based OS. :rofl:

Well, it doesn’t help that the Java apps I’ve had to deal with, are absolutely a terror. JasperReports for one has been a total pain in my *******.

Maybe one day, I’ll give it a fair shot, unfortunately, I don’t see that happening anytime soon.

1 Like

I don’t know what other languages you are referring to, did I write about any languages not scaling well? I just posted links to the videos and to me the gist of them is not which languages scale well or bad but that basing design decisions on current fashion may not be the best idea without actually learning about these technologies. I have no doubt node.js, ruby or MongoDB can scale well, as many other technologies, it all depends on how well you apply the tool for the job.

Now back to PHP - I like this comment under the infamous article, not that I agree with it but it’s a good example of how some programmers regard PHP:

This is actually what a lead developer from Spotify said: “You need to understand that PHP was written by Rasmus Lerdorf more or less by accident as a constantly growing number of helper functions when doing web programming”.

Basically, PHP is the way it is because it started out as a disjoint clusterfuck of web programming functions for the personal use of Rasmus Lerdorf. It is made for just quickly putting together a quick solution for a problem, kinda like using duct tape to fix everything. This might have been fine back in the 90s when the world was simple, but not today when web apps are the main work horse of major World Wide Web players like Wikipedia or even public companies like Facebook. Actual web apps require something more like Java Enterprise Edition or Python’s web app frameworks like Jinja or Flask.

:smiley:

1 Like

The OP was intending to write a business application, I believe, so in this case this is not a problem because he doesn’t need to save every penny to bear with cheapest hosts. BTW, I saw many cheap hosts adopting PHP 7 more than a year ago and now they are offering 7.1, too. And there are those who allow you to choose from a number of versions per domain. Let’s leave PHP 5.x hosts for those looking for Wordpress hosting. There is no shortage of competition in this area. I think any new and serious project should start at least at PHP 7.

3 Likes

Actual web apps require something more like Java Enterprise Edition

I know it’s just a quote, but had to pick that out since they took the time to type it all out. Very few companies doing new stuff use JEE. Spring is pretty much the defacto standard and doesn’t require JEE. I’d say that pretty much anywhere using JEE, especially J2EE, is somewhere you’d probably want to avoid unless you’re already very familiar with the Java landscape and understand what you’re getting in to.

This Quora answer explains it pretty well, if you’re interested.

1 Like

Interesting, this only shows how misinformed some PHP bashers are. There’s usually a distinction between idealism (what elegant tools programmers should use) and practicalism (what “ugly” and cheap tools are used in practice - and the ugly sometimes turning out not to be so ugly).

I’ve used Java for some simple desktop and mobile apps and it felt to me much more elegant and organized than PHP but I don’t think I’d like to use it as a server side language of a web app.

1 Like

The context of my commentary was in regards to the OP’s project, which was:

A “local business website” is not an enterprise application, i.e. Twitter, Amazon. I don’t know why we suddenly switched to enterprise context.

I’ve seen no “local business” websites running Java or large scale systems. And regarding .NET, I’ve only ever come across two sites using ASP for the website, and both sucked, requiring constant server maintenance reboots and downtime (yay Windows servers!)

I can’t think of a reason to use anything other than PHP/JS for a “local business website”. I mean, I guess you could use a Node server, but why? I guess you could use Java or Ruby based systems, but there is technical debt if you have to learn a lot of new things. And finding developers may be harder, and more expensive.

And if one hosts their business website on almost any inexpensive host (assuming moderate need for bandwidth or HDD), then PHP is almost the only game in town. The host may provide ability to use Python, but who does? Of the thousands of freelance jobs I’ve browsed over the years, nobody needs help with their small business Python, or Java websites. 99% of the time, they run Wordpress on a stupid GoDaddy host or something. I’m dealing with a small biz site right now where the host is running PHP 5.3.3.

Anyway, I can only speak from my own observations, it’s not necessary to insult.

Get with the times, with .NET Core, Windows isn’t required anymore. :wink:

1 Like

A “local business website” is not an enterprise application, i.e. Twitter, Amazon. I don’t know why we suddenly switched to enterprise context.

This has nothing to do with what I quoted.

Apps made from Java tend to be legacy systems.

I do agree that OP should probably use PHP, probably running on Drupal or WP, for this use case. But context has no bearing on this statement when you took it out of context by saying “systems”, a website is not a “system”, it is a brochure.

Either way, OP wasn’t really clear on how much functionality is required.

And if one hosts their business website on almost any inexpensive host

Also untrue. For $5-20/mo you can get fine hosting from AWS or DO for a brochure site that will probably by far out perform any shared host for the same price point.

Fine hosting, for sure. Typically SSD, but not much storage or RAM allotment. Often no SLA or guaranteed uptime. Unmanaged, no automated backups. Sometimes not even the ability to snapshot the VM.

I personally use VULTR right now, switched from DO. A little more RAM for the money, was faster, and let me do live snapshots without having to shut down the box.

Regardless, the typical end user doesn’t want a bare VM. They want pretty control panels with big buttons never have to type commands to manage anything. I need to be able to explain how to add an email address, and take screenshots of where to click and what to do.

Good to know! Though I still can’t find a reason to build a website in .NET. I mean, maybe they have a leg up with dev tools? Pretty much stuck with VS? I feel like a more open environment such as PHP/JS live in gives more freedom to developers. And I have to believe there is much more tooling available!

I had a job recently for a client who was moving hosts. Their site was in .NET. I couldn’t even work with the thing. I had to install Visual Studio just to be able to open it and then export the project in preparation for moving to the new host. Felt very rigid.

2 Likes

No, there is Atom, Visual Studio Code (not clunky like Visual Studio), Mono and more options coming out each passing month. Jetbrains even created one, Rider.

Scott Hanselman wrote a good article about the state of .NET development recently
https://www.hanselman.com/blog/ChoiceAmongstCrossplatformNETIDEsVSCodeVisualStudioForMacJetBrainsRider.aspx

2 Likes

I had written my first website in PHP and MySQL in 2015 as a means of learning programming, the reason choosing PHP is that looked simple to me compared my abilities. But as I remember I didn’t care much about the security and best practices. I just wrote what ever came to my mind. Over the time, I read about security of applications your are writing, readability of the code, the performance of the application, and so on. And so this post!!

@Ganapathi004 Well PHP 7 has been optimised for performance and I would use it if possible, my web hosts do now have support for PHP 7 but I found that a few of my websites do have issues usually the ones developed using something like WordPress and its not WordPress itself that’s causing the problems it’s usually some of the plugins that fail, so far, the sites that I have developed using my PHP framework of choice run equally well on PHP 7 as they do on PHP 5.6 except under PHP 7 they are much more responsive I also no longer use MySQL but use MySQLi as this seems much more secure natively, using MySQLi is a matter of slightly changing your syntax for interacting with the database there is also the option of using PDO if you want to connect to various databases like, for example MySQL,PostgreSQL and others, again it all comes down to what your web hosts support.

If I am developing a website I try to match my local environment as near as possible to my web hosts environment so I develop on my local server to make sure the actual site functions properly and then upload it to an area of my web account I call my test or staging server so the client can see the results
(and I can check that it works on my web hosts servers), if the client approves it I can then set up a domain name for them and put the site live under their chosen domain name, I design the code for the site in such a way that it can detect whether it is running locally, on my staging server or live automatically, so I don’t have to reconfigure it specifically for each server.

I hope this helps you

1 Like