PHP is DEAD!

Why You Should Use PHP in 2019?

Before we start…

PHP stands for Hypertext Preprocessor, and it is a general-purpose, free and open-source scripting language, primarily used for web development as it can be embedded into HTML. 

It is a script language, meaning that, compared to compiled code, the PHP code is interpreted instead. Line by line, each one is evaluated and a decision is made based on it.

Although it is primarily designed for building dynamic websites and web applications, it is used for writing software in the widest variety of application domains, for example as long running processes to read and parse messages from a queue, perform heavy or complex operations, asynchronous files download or web crawling, and many many others. 

PHP is a server-side scripting language, meaning the script is evaluated on server, and then the output is sent back to the client – the web browser, for example.

Usually the output is an HTML file, but it can be anything – CSS, JavaScript, JSON, XML and so on.

Powering around 80% of websites across the internet it is probably the best tool for web development.

PHP is open-source and free, so anybody can download and use it. It is cross-platform, so it can be used on different operating systems, like Windows, Linux, MacOS, Solaris, etc.

Why is PHP important? What problem is it solving?

With PHP you can read from files on the server, add content into, create or delete files and directories on the local server. More than that, PHP is capable of reading from different types of streams, like I/O streams, HTTP and FTP, Compression streams and Audio streams among others. 

PHP can also perform read of data, create, update or delete records from a wide range of databases.

Also with PHP one can perform operations on images, from basic ones like resize or crop, to more complex ones like apply watermark, rotate, and even apply filters like blur, opacity, pixelate, contrast or sharpen to name a few.

PHP can also be used to manipulate a range of archive file types – RAR and ZIP to name some popular ones.

Cryptography is not a stranger to the PHP language. Using PHP you can perform operations like generating solid password hashes using modern algorithms, encrypt or decrypt messages, validate document signatures, generate random secret passphrases, and more.

Want to send an email using PHP? It has never been easier.  mail(‘my@email.com’, ‘My Subject’, ‘My message’);, run the script and you’re done. Of course PHP also supports a more advanced functionality when dealing with mail preparation and sending.

PHP can generate documents like PDF, Excel/spreadsheets, GnuPG keys and more.

PHP has caching capabilities using modern tools, from APCu, to Memcached, Redis and more.

What other tools are out there? Why is PHP better?

PHP is very easy to learn, it is simple for newcomers, especially for non-programmers. The learning curve is way shorter compared to other languages such as JSP, ASP or others. PHP is dynamically typed – the variables can be assigned mixed data types like integers or strings without enforcing a certain data type. Also PHP supports type coercion, meaning values can be converted to certain types in some contexts – imagine an addition operation between a string numeric “1” and an integer 1.

The PHP ecosystem is pretty large and mature, and there is a wide variety of available open-source packages maintained by an active community that solves specific problems. Then you can find powerful frameworks with great support from maintainers and community, suited for various needs – from small projects to enterprise applications.

It is super easy to get help as a PHP developer – the php tag is the 4th most popular on StackOverflow

With PHP you get increased productivity, using simple function calls while the complex work is done by the interpreter. A “Hello world” script is as simple as  print “Hello world”; ! So the script is human readable, and not too verbose – less lines of code results in many things accomplished.

PHP supports most web servers including Apache, Lighttpd and IIS. It is cross platform, and most web hosting services support PHP by default.

PHP is fast. And with the latest major version 7 it is faster than ever. Several optimizations were made under the hood. Also collaboration with Intel’s performance team had a great impact on language performance. The language evolution in terms of performance can be seen on the insight provided by Zend Performance Team.

How can PHP help developers?

It is very easy to start a project using one of many available open-source frameworks. Directory structure is set, defaults are set as well, a welcome page is waving at you; next thing to do is to add your own stuff, and apply customizations based on your own needs. 

From a scratch project to blog (CMS) and even e-commerce solutions, you will be ready to focus on specifications and create your implementation in no time. The Composer tool is very helpful in this matter, among others, like being a great dependency management tool. 

PHP allows us to build both complex monolith web applications and microservices as well. Again, open-source packages for creating PHP api platforms can give you a big leap in getting started.

PHP applications can be easily migrated to another stack – think of scalability – due to open-source adapters for services like caching, data persistence, session management. Database Abstraction Layers from ORM packages provide functionality for keeping the DB in sync with PHP mapped objects, making the migrations an easy task for the developers. So scaling a PHP application is easy.

PHP benefits from excellent debugging and profiling tools, helping the developers to inspect the application state at a certain point in execution, find bottlenecks and part o code that uses most resources, allowing them to re-think into a solution that would optimize the code execution in terms of time and resources usage.

Advice for PHP newcomers

Learn and use Composer for dependency management. 

So, when you need to use some open-source library available for PHP, you won’t have to copy and paste that code into your project tree, but you will import it by instructing the composer to do so. More than that, you can use version ranges for your packages (dependencies), so you could benefit from the latest security patches and new features just by invoking the composer update command.

Organize your application.

Create a structure that allows you to have PHP in one place, then config files, CSS, Javascript and others grouped in their own place. Also separate the logic from the view. Of course, if you start using a framework, this structure will be dictated in most part by the framework, and you will not have to worry much about it.

Make use of frameworks and open-source tools.

Not only will they speed up your work and will make you more productive, but also you can be sure these tools are thoroughly tested by community members on their own apps, they treat some edge cases, and are optimized for best performance.

Always sanitize the user input

Simply put – do not trust the user input! Ever. If you’re expecting an integer, then cast the input value to integer, if you expect an email then use the sanitize PHP’s built-in function filter_var or other tools to validate and sanitize value of the input parameter, and so on. Of course, use only the sanitized values next in code.

Top PHP Myths

PHP has a bad design

PHP imported the syntax from many other languages in its way to add more features. There are some inconsistencies among function naming, some optional arguments position, to name a few. Well, this is a thing we developers have to live with, still. Or if one prefers, he can also come up with some abstractions that would wrap those functions into “nicer” looking solutions. 

PHP is not scalable

I’m not sure that scalability is about the language. I see scalability is more tight to system and server architecture. Anyway, PHP is used by some large organizations, using large amounts of data, like Facebook, Wikipedia, Mailchimp, Tumblr, Slack, DailyMotion and Etsy.

PHP encourages bad programming habits

Well, the thing is that PHP started in ‘94 as a templating engine, and very simple (and few) functions were used at the beginning. But because it was an easy to use tool, it was rapidly accepted and new features were requested. At some point this project evolved from the templating engine into a scripting language. So in many legacy projects you can find PHP code that queries databases from presentation files (html), files inclusion all over the project, and unreadable code overall. Nowadays things have evolved. It is possible to write beautiful and maintainable code with PHP. Of course, since PHP is so flexible it still allows you to do certain “bad” things, but it doesn’t mean you should do that. In this matter the community has pushed forward and established PHP coding standards, has contributed in developing frameworks that would organize the code and would dictate some discipline in developing a PHP application, and thanks to this now, using the current features, PHP is a way to go for modern web applications, with beautifully crafted, well designed and optimized apps.

PHP is procedural oriented

PHP is an Object Oriented Programming language as well. So with PHP you can choose which approach best suits you. Anyway, who says OOP is the way to go and POP is garbage? 🙂

PHP is a dying language

PHP is here for years, it’s been around longer than many trending languages nowadays, and it keeps its position for a reason. Active development and maintenance of the language proves that it is still strongly wanted and demanded. PHP – a dying language? Not anytime soon.

Bottom line

Many blames were addressed in the past to earlier versions of PHP. These have been taken over and promoted by other developers without verifying whether they are still reliable or not. Modern PHP is a mature language that can compete with any other scripting language out there. 

Summary

With the fast paced evolution of web development PHP has managed to stay relevant and keep the pace with the modern requirements. It is a choice for so many organizations because it is one of the best options when it comes to fast response to new market challenges, given the increased productivity, performance and the resource usage. It is also one of the most cost-saving solutions in terms of expenses for hosting services.

It is easy to get a job if you know PHP. Powering around 80% of websites around the world, PHP is one of the most demanded languages. The market evolves, the language evolves as well, and developers are needed to respond to current market needs.

PHP is a language that allows you to build fast and robust applications of different sizes – from tiny APIs to complex enterprise applications -, and on different architectures – monolith or microservices. It’s mature and a proven competitor on the market with its large and mature ecosystem which provides support for all programmer levels, as well as free and open-source libraries that are well documented, tested and actively maintained.

With PHP you don’t only bring results much faster than in other languages, but you do it in a flexible way.

The maintainers drew the roadmap for upcoming versions, ones with new features and more improvements, meaning PHP is here to stay, as a competing modern tool for web development.

PHP is DEAD… (Damn Easy for Application Development)! 😊

Leave a Reply

Your email address will not be published. Required fields are marked *