PHP At 20: From Pet Project To Powerhouse
snydeq writes: Ben Ramsey provides a look at the rise of PHP, the one-time 'silly little project' that has transformed into a Web powerhouse, thanks to flexibility, pragmatism, and a vibrant community of Web devs. "Those early days speak volumes about PHP's impact on Web development. Back then, our options were limited when it came to server-side processing for Web apps. PHP stepped in to fill our need for a tool that would enable us to do dynamic things on the Web. That practical flexibility captured our imaginations, and PHP has since grown up with the Web. Now powering more than 80 percent of the Web, PHP has matured into a scripting language that is especially suited to solve the Web problem. Its unique pedigree tells a story of pragmatism over theory and problem solving over purity."
Go on, we know you want to.
The great thing about PHP is that it's the one language that native, Java, .NET, python and ruby guys can all make fun of together.
Here's to another 20 years (or maybe 19, depends)!
Mod me down, my New Earth Global Warmingist friends!
This almost makes me wish Dice would go back to starting its flame-wars with stories on gender inequality.
Hello world in PHP:
No Bullshit Boilerplate (TM), no needing 5KLoC of code and configuration, no application server to babysit 24/7, no need for catalina+tomcat+jakarta+jre+struts+hibernate+Xmxwtfbbq16GB, just load one module and every single customer sharing the server can use it... No need to understand the CGI protocol, no need to understand the HTTP protocol, no need to understand HTML even.
... blames his tools. Crap code an be written in any language. Good code can be written in PHP. While not my first choice of languages, I have found myself on PHP projects and been fairly comfortable using it although during moments of frustration put in comments such as "These following 10 lines could be written in the following one line of Perl...".
In a band? Use WheresTheGig for free.
It's definitely a house, but I'd disagree about the power part.
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
PHP is Turing complete, so it's technically possible to write anything in PHP that you could write in another language. That seems to be about the most it's got going for it. PHP does nothing to help programmers write sane, maintainable code. It's almost impossible to develop without having a browser tab open to php.net ("The online docs are great!" "Well, they'd have to be."). There is zero consistency with things like argument order. Dangerous legacy concepts like "mysql_real_escape_string" are only recently deprecated and don't have a set removal schedule. It's a one-trick pony that's nearly useless outside its niche as a web page generation language. It's just a mess - a dangerous, unmaintainable mess.
I won't refuse to use an app just because it's written in PHP, but I do heavily weight it when comparing alternatives. PHP is a powerhouse in much the same way as McDonald's. It may be ubiquitous, but it still sucks and you have to question the judgement of anyone who chooses it to start a new project.
Dewey, what part of this looks like authorities should be involved?
:: isn't namespacing. It's the scope resolution operator.
\ is namespacing.
Non impediti ratione cogitationus.
I used the original, or close to it.
In 1995, I worked for a company in San Diego (MediaShare) that did Tesco's first online store.
MediaShare had a publishing tool called ProductBase, that put product details in a database, and you could publish to print or CD-ROM (remember those?). I proposed to my boss that we could also easily publish to HTML, and he let me explore it.
This turned ProductBase into basically a static-site generator, and Mediashare built some sites for some of their existing clients ("the threes" - 3COM and 3M - we put the 3M Adhesives catalog and 3Com's catalog of network products online for the first time) and some new ones.
One of the new ones was Tesco, and I built a little shopping cart with a very-close-to-1.0 PHP script running under Netscape Server CGI.
I would have never thought that PHP would still be kicking around this many years later. That was the last time I ever used PHP.
The author had no pretensions about PHP. It was a simple little script to help him with his personal home page, and he admitted his lack of programming expertise. Others turned it into a Frankenstein's monster.
Just like good Perl is possible. That being said, if you are going to take the time to write correct, well-architected, maintainable, etc. system, you will spend equal amounts of time in any language or framework. PHP makes some things very easy, but that easiness is skin-deep, and it's exactly the same with Ruby on Rails. Yeah, you can rapidly prototype things and get stuff running in front of people. Scaling it, making it robust, and making it part of a whole ecosystem of mutually self-supporting tools, applications, and utilities? You know... real world software needs? That's going to take a good amount of effort and design in any mature framework.
Now that MS is putting dot net everywhere, we are going to jump ship for C# and ASP Web API to create a SPA.
You criticize closures, dependency injection, generators........and you want to use C#?
"First they came for the slanderers and i said nothing."
The most popular language on the web HTML.
The second most popular language on the web is Javascript.
The third is XML.
Neither html or xml are programming languages. They do nothing until a programming language comes along.
putting the 'B' in LGBTQ+
PHP does not power 80% of the web, it is merely present on at least one server behind 80% of TLDs. That's not the same thing.
You misspelled "Whorehouse" guys...
Populus vult decipi, ergo decipiatur...
"Force shits upon Reason's back." - Poor Richard's Almanac
PHP is the shitiest language out there except for all of the others.
So what? If you don't like it, don't use it.
How would one go about writing an extension for an existing large codebase, such as phpBB, MediaWiki, or WordPress, in a language other than PHP? And it's likely that some of these codebases began years ago when shared web hosts charged extra for languages other than PHP.
i don't think you read what i wrote properly. i'm complaining about those things being implemented over stuff that could have a real impact on productivity, rather than a 'me too!' race to keep up with the big boys features.
Got it.
as for C# the ASP.net libraries look pretty good, as is the entity framework, linq is quite cool...
ASP.net is fine, and linq is cool, but I would stay away from Entity Framework. I've seen so much sorrow is produced by Entity Framework and Nuget.
If you do use Entity Framework, keep a clear line of separation between the DB layer and the rest of your code (ie, don't spread entity framework objects all over the place), so it can be removed without too much pain if necessary. You should have a clear line between DB code and the rest of your code anyway, just as general practice.
FWIW, I interviewed at Microsoft a couple years ago, and not even they were using ASP anymore, they were mainly doing stuff in Javascript (probably Angular+typescript, but I would stay away from that too lol). I still think ASP is fine, but caveat emptor.
That's my current view on the topic. A lot of skilled people are switching to python for the backend. I have an irrational hatred of Python, but Django seems like a good option if you're being forced to use a 'proper' language. Look at CSS Zen garden for front-end ideas.
Those are my two-cents.
"First they came for the slanderers and i said nothing."
The person I was responding to did not specify "programming language".
Did the person I responded to specify "programming language"? (Hint: NO)
There is far more HTML and Javascript and XML on the web than there is English.
Please define "programmer" for us.
BeauHD. Worst editor since kdawson.
JavaScript isn't just client side. If you disagree, I'll get MEAN with you ;-)
-- Support a free market in the field of government
I can't say I love it, but it's usually available, and it usually works. What's the problem?
The == operator is broken
The same is true of JavaScript, which is why Douglas Crockford in JavaScript: The Good Parts recommends always using ===. PHP developers would be wise to read that to see what warts PHP shares with some other popular languages.
Anyone using PHP is a non-programmer by definition.
I'm a professional software engineer working on OS-level software for a heavyweight in the tech industry. I also use php in a non-work context. And I actually enjoy it
Guess you'll have to peddle your absolutisms elsewhere.
People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
"Someone who writes PHP and LIKES IT."
As in https://speakerdeck.com/nineties/creating-a-language-using-only-assembly-language
PHP doesn't dominate; it's attached to WordPress. That's it. If WordPress had chosen any other language....
Yes, there are some weird/frustrating/awful things about PHP, but I love it- it's made me a ton of money as an independent site owner/operator and hasn't cost me anything.
Just cruising through this digital world at 33 1/3 rpm...
Gee, then I must not exist. I've been making a good living writing PHP for over a decade, perhaps you can tell me what I've actually been doing all this time?
Just cruising through this digital world at 33 1/3 rpm...
Node exists because it can, not because it should.....
Actually, you're mistaken. I understand exactly what I need to do to get the results I want, and doing it in PHP earned me a nice living. Using PHP (the LAMP stack, really) has allowed me to work for myself, create businesses, earn money, and live pretty well. I have a hard time understanding what you don't like about that, unless it's based in jealousy. If you don't like PHP, don't use it. You're welcome to use whatever programming language you like without fear of me telling you why you're "wrong".
Just cruising through this digital world at 33 1/3 rpm...
Yep, PHP makes things simple, and there's an excellent selection of modules that can be loaded for more unusual requirements. When I saw all the junk that was required to use a typical RoR app, I laughed and closed the page.
Just cruising through this digital world at 33 1/3 rpm...
Equality is not transitive in PHP (null equality is not consistent)
True, PHP == is brain damaged. But is there a case where ($a === $b) && ($b === $c) && ($a !== $c)?
Yep. I won't touch PHP. Ever. Any time I run across something I want to run and it says "requires PHP", I skip it. Even if there are no alternative programs/applications/projects.
You use this decision making process for everything? i.e. If you don't like something you simply won't use it even if there are no alternatives? Interesting attitude.
"lt;dr" is the correct response to most of my posts.
What language exists that doesn't allow you to write bad code, has no security vulnerabilities, and will still help solve the real world applications that, in this example, PHP is used for? Actually, with PHP being a wrapper for C, which is the cause of most of the issues, please let me know what gives programmers the same power and flexibility, while not allowing bad programming.
With Apple's reputation, Swift might have been a contender, but apparently even Apple doesn't try to wall programmers in so tightly..... possibly because any such language that limits you that much doesn't really see much use, as it's incapable of achieving the same tasks.
Just like chefs need to handle knives and flames (these days, also liquid nitrogen, etc) and can produce inedible meals, an expert chef can produce a tasty meal unharmed with damn near anything edible (yeah, I watch too many cooking shows).
If you didn't allow a chef anything they could screw a meal up with, you'd not be getting much that wasn't screwed up either.
"lt;dr" is the correct response to most of my posts.
You are an untrained monkey pounding on your keyboard until it sort of works, although you don't know why it does.
And you're an anonymous coward with nothing meaningful to say.
People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
Well, CSS isn't a programming language either.
But combine HTML and CSS and you have a beautiful little Turing Tarpit in which to write your universal computations.
SJW n. One who posts facts.
Why garbage? Here's why:
1. Standards change all the time. What's the default value for that global? Depends upon the version. What? That global didn't exist when you wrote your code, so you can't check its current value to see if it affects you? Go fuck yourself.
No one cares. Nobody uses global anything since 4.x.
2. Libraries and APIs are added, replaces, and sundowned at will. Want to do an http redirect in the current version? Go fuck yourself!
No one cares. I can find all changes with 20 seconds on php.net, one of the best PL documentations every. The differences and deprecations and changes are listed per version. And they're a good laugh during a boring coding and debugging day. Especially those parameters and function names. :-)
3. Error handling. Look it up. Or, rather, the designers need to do that and then implement something sane, and do it consistently.
Yeah, right. Like you - or anybody else - uses error handling consitently, no matter the PL. *I* only use it when I don't know what to expect from the adjacent API. And then I usually leave the catch loop empty, except for some printed output or something.
We suffer more in our imagination than in reality. - Seneca
Don't bring facts to a PHP-hatenanny!
I've been working for more than 9 years with PHP and pretty much have seen it all. From cheap quality boilerplate code hell, to really well designed code.
The main problem with PHP is that it's lack of features sometimes forced you into using bad practices. See for example the lack of namespaces/packages way over the time every other language had an implementation for that. This is solved for now, but there is a lot of legacy code that is still out there and making other programmers pull their hair.
Nowadays PHP has evolved, and frameworks have started using the new features in an elegant and powerful way. Some of the criticisms to PHP are still valid, other don't apply anymore. I for one think that PHP has get enough good features to ditch the "you're bound to write shitty code if you use PHP" motto. There are better languages, yes! I use them and I like them, but that's not a good reason for believing that using x language makes you a shitty developer and using y language makes you a good developer. Still... some languages might make it harder to write good code, and that's why you have to be wary and consider options.
I don't love PHP, I won't marry PHP (that's why I'm currently learning other languages to expand my career or simply having fun) but I wouldn't marry any other language either. I love programming and I see each language as a tool which might or not be useful, I'll keep learning, but I won't trash what I know because bashing it becomes trending topic among IT freshman.
This entire discussion is about programming languages. You should have defined your terms.
putting the 'B' in LGBTQ+
Someone trained enough to know PHP is shit.
+100000 All the butt hurt PHP losers hate it when you point out that they are untrained.
Cue the untrained PHP fanboys who think that proper CS is "snobbery".
PHP is a blight on my craft and is argument #1 why programmers need to be certified like public engineers.
Are you stupid or something?
./configure
Oh wait, you are an uneducated PHP monkey, of course you are stupid.
Try installing PHP from scratch and come back here with your bullshit. It is only easy because all the work was done for you. If you want to setup PHP where it is only 90% insecure instead of 100%, add about 6 days of work.
PHP is not easy for a beginner because it is insecure by default and tons of errors get ignored. It is not easy for a professional because it is so damn hard to not fuck something up. PHP is the only language that makes doing the wrong thing easy and encouraged and doing the right thing difficult.
Ask any Facebook programmer what they think of PHP. They will all say it is utter dogshit.
As for Ruby it is trivially easy to set up and set up in a correct and secure manner.
I can go from blank VM with only the base OS installed to a fully installed and configured Rails app in 20 minutes, without anything but bash.
wget ruby_url/
tar -zxf ruby.version.tar.gz
cd ruby
make && make install
gem update --system
gem install bundler
gem install passenger
passenger-install-nginx-module
cd to location of rails app
hg clone rails_app
cd rails_app
bundle install
rake db:migrate
rake db:seed #if db needs some default entries
rake assets:precompile
#paste in a few lines in nginx.conf
start nginx
That is 20 minutes in a slow instance. That all can be easily scripted
To update the rails app
hg pull
hg update
#precompile assets and run bundler if needed
passenger-config restart-app
or you can automate that will capistrano which makes it cap deploy It is even easier on Heroku.
Fucking PHP cretins need to die in a fire and stop making the internet such a dangerous place.
You losers are a blight on my craft. Programming is a professional endeavor. If you aren't intelligent enough to get properly educated, get the fuck out.
Only PHP retards would read PHP for fucking numbskills, copy/paste some insecure code and call themselves professionals.
You jackasses are the reason we need a professional society with a required certification needed to produce public-facing code. Like real engineers.
when shared web hosts charged extra for languages other than PHP.
They did that? Why?
I assume it must have had something to do with PHP's "safe mode", which enforced additional application-level sandboxing on top of what the UNIX permission model already enforced, restricting access to exec and to even world-readable files owned by another user. PHP has since abandoned safe mode but still retains open_basedir, which doesn't let a user open files outside a whitelist of directories. Other languages tend not to ship with analogous measures. Python, for instance, tried Bastion but abandoned it.
OK, so you don't know what a programmer is. Got it.
BeauHD. Worst editor since kdawson.