DEV Community

Cover image for Choosing PHP in 2018
Andrew Davis
Andrew Davis

Posted on

Choosing PHP in 2018

I bet you do not see those words very often.

We live in a time where there are a plethora of programming languages and frameworks. As web developers, we have so many options, it can be very difficult to know what to learn and use to build a modern website. If you check StackOverflow, Hacker News or Twitter, you will see thousands of different opinions about what language you should be using. In many cases, you will see developers making fun of PHP, trying to convince you to use something “better”. I am here to tell you not to listen to them.

PHP has a low reputation for a couple reasons. First, the standard library lacks some consistency in a few areas. Second, it is a more approachable language leading to more beginners using it and some poorly architected systems being made. Both problems are easily combated with better training and education which we have plenty of in 2018.

By contrast, PHP has some great features going for it. First, it has several excellent web frameworks like Laravel and Symfony. Both are easy to learn and give you a great head start in building a website. Second, PHP is modernizing with better speed and excellent package management with Composer. The PHP 7 series has provided almost double performance, making it a very snappy scripting language. Composer provides great third-party package management on par or better than others like npm or Bundler. Third, PHP has an excellent object oriented class system and also supports functional programming features. It’s object oriented nature makes it simpler to write maintainable, clean and organized code. Fourth, PHP is still one of the easiest languages to deploy to a server. Most web hosts support a one-click install for PHP making it really easy to get your site in the hands of users.

It is a great time to start learning PHP. Don’t worry about the haters, just go make something great!

If you want to learn more, here are a few sites that have helped me:
http://php.net/index.php
https://www.phptherightway.com/
https://laravel.com/
https://www.laracasts.com/
https://symfony.com/
https://getcomposer.org/
https://packagist.org/

If you have been using PHP, write a comment about it so everyone can see the cool stuff you are building with it!

The PHP logo is from: http://php.net/download-logos.php

Top comments (66)

Collapse
 
ben profile image
Ben Halpern

PHP is backed by projects/companies that cover the entire spectrum of web development. Its ecosystem seems alive and thriving. I haven't used PHP in years but I kind of want to dip back into it.

Collapse
 
restoreddev profile image
Andrew Davis

The amount of companies using PHP is amazing. It may not have the Silicon Valley brand names like Microsoft or Amazon, but it’s used by more large companies than I think the average programmer realizes.

Collapse
 
itsdarrylnorris profile image
Darryl Norris

In Silicon Valley, there is a lot of people hate PHP. However, there are a still a lot of startups using it, or they are using it on a product like Drupal or WordPress.

Facebook was built using PHP, then they wrote another language, which the syntax is similar to PHP.

If you are curious about this language: hacklang.org/

Thread Thread
 
olal profile image
(ⓞⓛⓐⓛ 🇰🇪 II)

You forgot to mention Slack

Thread Thread
 
itsdarrylnorris profile image
Darryl Norris

I forgot to mention slack. Here is a good article about PHP from slack slack.engineering/taking-php-serio...

Collapse
 
okolbay profile image
andrew

you are not facebook
when opted for php and finding yourself knee deep in ehm, php, you won’t have resources to develop HVVM or new language on top, which solves your problem with php.

so until you are facebook, consider variety of other stack options out there )

Collapse
 
perttisoomann profile image
Pert Soomann

I swear the dev circle-of-life is about 3-5 years long - you wait long enough and what ever you are doing is going to be the hip thing again.

Collapse
 
itsdarrylnorris profile image
Darryl Norris

I love the native (since PHP7) type hinting support. If can make type hinting into your company standard this will bring a lot of bugs into the light. Also, the beauty is that does not need an external library like TypeScript or Flow.

Collapse
 
fmertins profile image
Fernando Mertins

declare(strict_types=1);
:-D

Collapse
 
okolbay profile image
andrew

I havent laughed so hard for a long time

try launching webserver with bare php?
try running gRPC server?
message queue comsumer, cli script - dont forget to stick it into supervisor to restart, if you dont want it to leak memory. kafka consumers anyone? reactive services?
php doesn’t cover entire spectrum, its barely covering specific bit of web development, competing with Ruby (RAD MVC)
excellent web frameworks mentioned in article are few years behind the rest of the industry

Collapse
 
xowap profile image
Rémy 🤖

Look, PHP might be a not-so-terrible choice to create a website. I've myself been using PHP before register_globals was defaulting to false. I agree, it's workable. I've been using it professionally for years.

Yet, at some point I spent 1 month creating a project with Symfony (that was my first project and an old Symfony version). As I was not happy with the result, I did the same thing again but this time using Django. It took me about 3 days (that was my first time using Django and using Python as well).

Now Symfony has changed (I gave a it few tries in between 2008 and now) yet nothing from the PHP ecosystem managed to get my heart ever again.

We're in 2018 and now most of what we do is SPAs with just an API backend to be written in the language of your choice. What matters is the quality of the ORM and the ease to create a REST API. Well, the Django ORM is really a gem in this world. Amongst all its features, I like the most:

  • Its migration system, which is deterministic and plays well with branching
  • Its introspection capabilities which allow to create your REST API mostly automatically based on your data schema (and this without shady code generation)

I know that Laravel or Symfony kinda have that. But it's just not as good.

So, no PHP for me sorry.

Collapse
 
restoreddev profile image
Andrew Davis

Everything has its quirks, including Django. If you like Python, then go for it, but you can make just as good of an app in PHP. If you’re looking for an automatic REST API, PHP has Apigility. Laravel now has some efficient facilities for creating JSON APIs as well.

Collapse
 
meduzen profile image
Mehdi M.

You would probably love Laravel: it has, among a lot of other stuffs, a wonderful ORM (Eloquent) and a great migration system.

Collapse
 
xowap profile image
Rémy 🤖

That's true, it kinda reminds me where Django was 5 years ago :)

Thread Thread
 
xicarus profile image
Sergiu-Lucian Petrica • Edited

Yet judging by the subtle acidic remarks you're trying to make, it's clear as day that you still haven't actually tried building a proper app with Laravel even though I invited you to do so in the past.

You're biased as hell against PHP. It's easy to tell because in every other PHP post on this site I see you trying to convince people how Django is better. We already understand, you like Django and there's nothing wrong with that. Your reasons for liking Django however make sense to you and you alone.

To counter your little 'remark', if Django was so much more 'advanced' like you're trying to insinuate maybe that 0.25% marketshare that isn't really increasing was bigger. And I'm not even saying Django is bad, I think it's a very good framework backed up by a coherent language. The simple truth is that Django never brought anything new or significant enough to the table in order to displace a significant amount of marketshare, no matter how much you like it.

Do yourself a favor and actually build something with Laravel or even Lumen before you once again repeat the same single nitpicky anti-Laravel argument you have. Laravel and Lumen's strengths are something you should get educated about. If you're refusing Laravel because of some minor ORM issue that you can work around I'm afraid you haven't been paying attention, and once again proves you don't understand its strength.

You remind me of the people who laugh at TYPO3 CMS. Then at some point in their lives, they need a system which supports highly custom multilingual websites very well. That's the moment they stop laughing.

Thread Thread
 
olal profile image
(ⓞⓛⓐⓛ 🇰🇪 II)

Say no more 👏👏👏👏

Thread Thread
 
xowap profile image
Rémy 🤖

Ah but I learned, the last time we had this argument I didn't try to convince anyone to use Django and then I was urged to give the solutions I had in mind.

I guess giving alternatives wasn't a good strategy either then.

My point is still the same, PHP doesn't make sense and trying to make it better gets me tired.

What makes it clear that I havn't tried it? That I still haven't changed my mind?

Thread Thread
 
xicarus profile image
Sergiu-Lucian Petrica • Edited

The fact that you're still ranting about the ORM with complete disregard to the framework's strengths makes it clear you still haven't tried it. I already suggested that.
Developers appreciate Laravel's clean and beautiful code, you can easily understand what's going on just by glancing over it (more so than your average framework). This makes development a pleasure and is the main reason why Laravel completely trampled its competitors (like Symfony, CodeIgniter or Yii) even though it's the newer kid on the block.

Lumen is a microframework based on Laravel. The fact that you can seamlessly transition towards the full framework if you want to is its main strength. It aims to address Laravel's slower nature by having the granularity of only using the features that your project is actually using.

PHP always made and will make sense for a long time, it's your anti-PHP opinion that prevents you from seeing it. Right now aside from the standard library inconsistencies (which really mean nothing if you're using an IDE) the language is actually very good.
Improving its weaknesses is a sign that the language will be with us for a long time from now on, to your obvious dismay.

Thread Thread
 
xowap profile image
Rémy 🤖 • Edited

The reason I'm ranting about the ORM is because nowadays it's 80% of what matters to me in a server-side framework. If you're fine representing your models as a stack of migrations you have to hold in your head I guess you'll have a better memory than I do. If you're fine merging migrations that will run in random order you'll probably get rich in Vegas.

None of 100-something files generated by default nor controllers you have to create will be as readable as the code you don't have to write when doing the same thing with another framework not so slowed down by the language's flaws.

I used to see the beauty in PHP and now I see the truth. It made me lose long hours I could have spent doing something else. Every time a client requires me to code PHP is a painful reminder of that.

But then again, if Laravel floats your boat then go for it, be free. You're the only judge of what you need. (This sounds sarcastic but it's not)

Thread Thread
 
xicarus profile image
Sergiu-Lucian Petrica • Edited

Migrations in random order? What do you mean by that? Laravel's migrations are very much executed in the order of creation date (you can change that order if you really want to but to be frank I never needed to do that).

It sounds to me like you're required to support older PHP versions, because PHP post-7 is actually a decent piece of language and is fun with a good framework. I'm not confident about you being up to date with the current PHP ecosystem, that's all.

Likewise, if you like Django that's perfectly fine. I think it's great too. But again, I think your reasons for preferring are alien. Perhaps your projects are different than mine and that's why.

Collapse
 
aturki profile image
Ali Turki

At our company we use PHP and Symfony on a daily basis.. the framework is so awesome and so weel thaught thst we decided to settle for Symfony for of our applications. Doctrine (the defacto ORM/ODM) has an excellent support for relational and non relational DBs. As a result, we are actually working on a set of bundles (like a zero conf admin generator) that improve the framework capabilites out of the box. In my case, nothing to complain about in thr PHP ecosystem (except maybe the $ sign. But that's a matter of personal taste)

Collapse
 
ellisgl profile image
Ellis

Doctrine tries to support everything, but has several issues since not all DB supports certain features. Cross db foreign keys are not support, and IIRC there's an issue with date/time type columns defaults of null(?). The last one, there's an easy work around. The first one, there is a code mod you can do, but modding the library will end up with issues later on when you want to upgrade.

I actually like the '$' variable prefix.

Thread Thread
 
xowap profile image
Rémy 🤖

I didn't think I'd take the defense of Doctrine one day but in the case of cross-DB foreign key the reason is pretty simple: it makes no sense at all.

Maybe your application can't get around it but if you ask me, solving this at ORM level is like the most convoluted and misleading way of doing it. Just saying.

You'd better treat it as an external service like an API or something in that mood...

Just my 2 cents

Collapse
 
perttisoomann profile image
Pert Soomann

Excellent points, happy to see others feel same way about PHP.

After all, it's just 1 and 0 that tell hardware to "do stuff", just slightly different way than some other language.

Sadly it's very easy to start doubting yourself, specially with so many articles that don't really give specific reasons, just state that PHP is obviously very bad. "I've never run into these issues, is there something I'm missing? Maybe I'm not at that level yet to see it?"

Even worse when these discussions happen on non-technical level - investors, clients, etc.

Personally I believe it's not the tools you use but how much care you put in it that makes the difference for clients.

Collapse
 
xowap profile image
Rémy 🤖

IMHO how much you care gives you an effort budget. The more hurdles you'll find on the way and the more you'll tap into that budget. So while you can accomplish anything in PHP (Wikipedia and Facebook for starters) sometimes it's just not worth spending your budget while other things are so much easier to use.

Collapse
 
develcharlie profile image
DevelCharlie

I think that PHP is hated by technosnobs, by posers and by coders who don't know PHP. PHP is a way to develop efficients web applications in many flavors at reasonable cost. It's stupid today to speak about old register_globals=on or forgetting to use ===, because a serious coder knows the difference between == and ===, and knows too that data input have to be filtered as he knows that prepare statement is a good starting point, with filtering, to avoid SQLI.

Collapse
 
perttisoomann profile image
Pert Soomann


... things are so much easier to use

Can you give a bit more detailed example? You see, 99% of posts/articles say "it's just simpler", but hardly ever give examples of what these "things" are that make other languages better.

Just trying to understand what other peoples concerns are, and then figure out how would I overcome same issues with my choice of language.

I can see from your other post that ORM is something you consider important. There are independent libraries that offer ORM capabilities, and there's one packaged in with most, if not all, PHP frameworks like Laravel or CodeIgniter.

Did you highlighted it because "it's not built in as part of language"?

Completely agree with "effort" budget - if you have to do same things over and over and over again, it'll get boring and as a dev, you loose interest.

Thread Thread
 
xowap profile image
Rémy 🤖

PHP has a lot of pain points. Printed errors vs exceptions. Someone forgets to use === and creates a security issue. The empty and inconsistent standard library. The lack of primitive types like sets. The fact that you have to implement modules loading yourself. I can still go on for a while...

Indeed, Laravel fights this and has gone a very long way. But why spend hours trying to figure which of your 200 files prints that space at the end of the JSON (that you didn't notice for the first hour) while you could just use a framework that is able to write your REST API at run-time using simply your data model and a tiny bit of configuration?

Thread Thread
 
jmolivas profile image
Jesus Manuel Olivas

Talking about building a REST-API and GraphQL application using PHP you can use the API Platform project api-platform.com/ (based on Symfony components). You can enable any model as REST/GraphQL endopint by simply adding an annotation to your model class.

This project includes 4 components:

  • API Component
    Build a fully-featured hypermedia or GraphQL API in minutes. Leverage its awesome features to develop complex and high performance API-first projects. Extend or override everything you want.

  • Schema Gen Component
    Instantly generates a PHP data model from the Schema.org vocabulary. Let the ORM create the related tables.

  • Admin Component
    Adds a convenient Material Design administration interface built with React without writing a line of code. It's a Progressive Web App!

  • Client Gen Component
    Scaffolds a Progressive Web App (React or Vue.js) or a native mobile app (React Native), and edit it to fit your needs.

Collapse
 
thinsoldier profile image
thinsoldier

I would like to hear your Django over node.js arguments

Collapse
 
biros profile image
Boris Jamot ✊ /

I use PHP with Slim framework to build a mobile banking backend that is used by millions of people and it does the job. It has an awesome set of tools that help to build maintainable products. The major drawback is about asynchronous tasks, but it can be achieved somehow else, with Swoole for example.

Collapse
 
tadman profile image
Scott Tadman

Something I'd like to ask to those using PHP is "What do you know about PHP now that you wished you knew when you started?"

Collapse
 
restoreddev profile image
Andrew Davis

I wish I had known to learn a framework and to learn security from the start.

Collapse
 
tadman profile image
Scott Tadman

I've been trying to push for this more on places like Stack Overflow but there's a surprising amount of resistance to the very idea, something that I find is relatively unique to PHP.

I get a lot of "this is just for testing, security can come later" and "I want to learn, I don't want a framework to dumb it down for me" as push-back, which is not always easy to address.

PHP desperately needs more security and framework proponents.

Thread Thread
 
perttisoomann profile image
Pert Soomann

So it's more developer issue than issue related to PHP itself - any language can cause SQL injection, if you pass data straight from user to DB query as is.

I do relate to push-back somewhat tho, 8-9 years ago my attitude was "I can do it, why do I need a framework for?!", because I desperately needed to prove I was worthy in the company, but now... Not sure I can even write raw PHP anymore without help of a framework, it just makes it much quicker :)

Thread Thread
 
restoreddev profile image
Andrew Davis

StackOverflow is a tough place to change opinions. A lot of people on there have unwelcoming attitudes. Unless you are making a really small website, there is no reason to not use a framework. Even for a small site I would recommend using something like Slim. Not taking security seriously is pandemic to all of programming, but it feels worse in PHP. I do wish there were more books or sites that focus on PHP security. It’s something I have thought about writing.

Thread Thread
 
perttisoomann profile image
Pert Soomann

This is pretty good place to start:
owasp.org/index.php/PHP_Security_C...
owasp.org/index.php/PHP_Configurat...

Even new CodeIgniter refers back to OWASP
bcit-ci.github.io/CodeIgniter4/con...

Could be that because PHP entry level is so low, you do have a lot of people that haven't got their fingers burned yet.

It really needs to be multi-level approach, as if your sys admin (if that's separate person) doesn't do server bit, the app is still wide open for abuse.

If you are considering writing an article, I'd sure be interested in reading it.

Thread Thread
 
tadman profile image
Scott Tadman

You can SQL inject in any language, absolutely, but it seems like the drivers that ship by default with others have examples with placeholder values as a rule. While the official PHP documentation does a great job of walking people through how to use things like PDO or mysqli, these pages are buried SEO-wise by a metric ton of junk that doesn't, especially in the YouTube department.

The PHP world has an unusually high number of frameworks, maybe a dozen depending on your definition. In the Ruby world we've got basically two. Python? Three-ish. Node? Everything builds on Express.js. PHP has so much choice!

Thread Thread
 
tadman profile image
Scott Tadman

I think the problem is so pervasive, it's basically endemic to large parts of the PHP world, that it calls for some kind of intervention. An article won't be enough. This requires a pretty serious effort to disrupt what the current top-ranking results are for common inquiries like "how to php mysql" and such.

As much as I appreciate OWASP, it's a bit too theoretical for most people to absorb, especially newcomers who just want a how-to type introduction. It's at that point they're the most vulnerable to bad advice.

Thread Thread
 
restoreddev profile image
Andrew Davis

It’s hard to turn the direction of a large ecosystem, but it would probably take creating something like a PHP security initiative which would provide high quality documentation and videos that would become the reference point for good security. It would have to be something the whole community can get behind.

I think frameworks have made the situation much better since they have more secure defaults. However, developers need to be able to understand what the framework provides so they use it appropriately.

Collapse
 
connollyglen93 profile image
Glen Connolly

PHP does not support multi threading in a Web Development environment.

Not a big thing, but definitely leaves you pining for other languages when the need presents itself.

Collapse
 
tojacob profile image
Jacob Samuel G.

I do not like PHP. But to say that it is bad for things like: "If you forget the '===' you create a security problem", is silly. Well, do not forget it! They pay us for this, if you forget something like that it is doing bad work and period, it has nothing to do with language.

Collapse
 
xicarus profile image
Sergiu-Lucian Petrica

No PHP developer that can pull his own weight forgets '===', it's just Remy being silly again.

Collapse
 
onin profile image
Nino

I love what FB did - they started with PHP and then instead of switching to Rails or Go as they grew larger, they created their own fork which both outperforms the original and was way more advanced before PHP7 was released.

Even nowadays I find HHVM hot - you can utilise cooperative multi-tasking simply by prefixing your method with async and then awaiting at runtime, how neat is that?

Further reading: docs.hhvm.com/hack/async/introduction

Collapse
 
devhead profile image
dev-head

If you have been using PHP, write a comment about it so everyone can see the cool stuff you are building with it!

At my current company the core services are all written in PHP. We have API's, sites, jobs, daemons, sockets, etc. We even have services still running after six or seven years (untouched for the most part) and we recently finished a new product using the venerable Symfony project. In my experience, which significantly leans towards many years of PHP work, it's a great language to work in and build upon. (We do however also rock Java, Python, NodeJs, Ruby in specific places where those languages or features of them held more value to a project than defaulting to PHP. )

So yeah, there is plenty to still like and be excited about with PHP in 2018! As developers have matured around PHP over these years, there continues to be really solid foundation of experience and community to be a part of.

My journey has taught me that there are many many many amazing tools and languages out there and the more opportunity you have to expose yourself to them better informed your decisions will become.

I hate to generalize too much, however I'll allow it this time... I do suspect that some of the discourse against PHP is coming from people who identify with a specific language or use case; which leads them to take the defensive stances against PHP. Instead of a perspective it becomes dogma to them, built into a belief system of sorts. Making it more challenging to discuss a differing perspective or opinion.

So in conclusion, PHP is a great language to build something with; get out there and make something!

:cheers!

Collapse
 
arandilopez profile image
Arandi López

I really love Laravel, it's a beautiful monument of software architecture. But I also recommend to Ruby and Ruby on Rails. In both frameworks/languages you can built amazing things easily.

PHP has the defacto OOP specs, but ruby is magic and, as everything is a object (EVERYTHING), I consider it THE OOP LANGUAGE YOU MUST LEARN too.

BTW. If someone is about to complaint in favor of Node and JS, check out AdonisJS framework, a really truly MVC framework for Node, aaaaand is based on Laravel. Also, try adonis too.

I think languages and frameworks has their strengths and weakness. Node has async execution and websockets made easy. Ruby a easy language to run. PHP a good and easy deployable code. Also there are many strengths more.

Thanks for your post!!

Collapse
 
levelcoding profile image
levelcoding

Think simple, dependes buget and needs.
Except javascript i think every language it's incomplete.
I'm fan of php but i think every programmer should use 2 or more language.
For example i use javascript, i don't love it but i need it, so i used.
I wanna learn python because it's usefull for what i need, i want.

Collapse
 
nitinsbuzz profile image
Nitin

Building an erp system in php. It works better than any other erp system, based on languages other than php, i have seen and used so far. Besides, it might have its drawbacks, most are user based...the language is not unfriendly...

Collapse
 
erinburba profile image
Erin Burba

I was dreading the PHP aspects of my current internship before I started, but it's been amazingly convenient for bulking up the company's ERP and CRM software. Works very well with MySQL databases to create reports and handle web forms.

Collapse
 
iamalaajerbi profile image
Alaa Jerbi • Edited

PHP has been dominating the world wide web since its first release in 1995.

It's relatively easy and can get the job done quickly. I don't see why I would abandon it anytime soon.

Let's all PHP (Punch the Haters Passionately) <3

Peace!

Collapse
 
fishbulb81 profile image
Brian Foley

When I talk to fellow devs about PHP, it's usually not the language itself that they are afraid of, it's the fact that most of the PHP work out there is:

1) Wordpress Development
2) Cleaning up someone else's terrible, horrible, no good, very bad PHP app.

A lot of times these two are the same app. A lot of languages out there have significant problems (e.g. Javascript), but I don't think you end up in this situation with most of them, unless it's a language that's even more obscure than PHP.

Collapse
 
restoreddev profile image
Andrew Davis

That’s a valid concern, a lot of PHP jobs are related to WordPress. PHP is just as capable as Python or Ruby, but since those two languages are more popular in startups, that has an effect on developer perception.

Collapse
 
mahendrachoudhary profile image
Mahendra Choudhary

I have been writing code in PHP from last 4 years and currently working with ruby(rails) and python .One thing I would like to say about PHP is it gave programmers a freedom to accomplish certain task in there own way. It is not bound by certains rules .Embedding PHP into html is breeze as comparing to rails and django .

If I talk about speed of execution of code PHP7 done great job with this and in most of the cases speed won't matter .

Most I love about PHP is its oop , class-autoloading features .

PHP docs are one of best around the web as compare to the other languages .

Today , a one can deploy a PHP app easily in one click .

For sure , rise of javascript challenged PHP in recent years and why not javascript evolved rapidly .

I am little disappointed that PHP is not evolving as fast other language s , but I am sure with realese of new version PHP8 , PHP will again rises . I hope to see native support for no-sql databases , and more compatible to build real time apps using PHP