What is Vanilla PHP?

Vanilla PHP is basically plain PHP, without the use of extra frameworks and libraries to help you in the development process.

4176 views
d

By. Jacob

Edited: 2020-07-25 00:39

PHP, vanilla is plain PHP.

Vanilla PHP is also known as plain PHP; as the name suggests, there is really nothing special about it—it is simply PHP without libraries and frameworks.

These days, probably very few people will be coding everything themselves using plain PHP. It is much easier to find a library that does what you need it to do, and then implement that. Tools such as composer will make this much easier; but you can also find a compressed file, such as the well known .zip or the lesser known .7z, that contains the code; then you can install the library the old fashioned way.

Even something as basic as installing a library can actually be quite difficult, since it requires a solid "core" knowledge about computers and file managers. Perhaps, many of us tend to take this for granted, since we might have grown up with computers. Working with file system paths, compressing files, or extracting compressed archives, is no more difficult to me than riding a bike—just for example.

Composer is supposed to make that easier for PHP developers, and allow us to focus more on the coding of our applications.

Vanilla PHP vs Framework

Should I use a framework or stick with vanilla PHP? Well, if you already know vanilla PHP, then you also know how to use a PHP framework; that is something people often seem to overlook.

Unfortunately, if when looking for hired work, many places they might require preexisting knowledge about a specific framework, and they might even ask you about this doing the interview process. This might have the unfortunate side effect that they overlook the best programmers in the process.

It can therefor be useful to spend a few days learning about different frameworks; it is not like this is something that takes very long. I would simply sit down and try to make some basic guestbook applications using frameworks of interest. You can even keep the stuff around in your GitHub repository, as you never know when you might need to go back and see how you did something.

Vanilla PHP is not dead

There is a difference between being able to use PHP and actually knowing PHP, and being able to come up with your own solutions. To do the latter, you will need to memorize the various characteristics of the language, including the syntax of control structures, loops and conditional statements—not to mention individual build-in functions, and how to do object orientated programming in the language.

Beamtic is still developed in vanilla, object orientated, PHP; I have probably created something that looks more like my own framework by now. So, I can not exactly call it "vanilla" anymore. The original code was procedural, and I only later refactored everything to an object orientated approach.

My main reason for doing this is learning. Object orientated programming is not easy, and the best way for me to learn, is a combination of reading and applying what I learn in practice. The problem is with many of these more complex topics is that we do not normally get to use them otherwise—you probably rarely have to write your own router class if you use a framework like Symfony or Laveral for example.

This is probably the rare exception; but I am sure there is a lot of custom PHP still being developed and worked at out in the wild. This does not mean I am not using frameworks—one does not rule out the other.

Tell us what you think:

  1. In this Tutorial, it is shown how to redirect all HTTP requests to a index.php file using htaccess or Apache configuration files.
  2. How to create a router in PHP to handle different request types, paths, and request parameters.
  3. Tutorial on how to use proxy servers with cURL and PHP
  4. When using file_get_contents to perform HTTP requests, the server response headers is stored in a reserved variable after each successful request; we can iterate over this when we need to access individual response headers.
  5. How to effectively use variables within strings to insert bits of data where needed.

More in: PHP Tutorials