Functional PHP? Well, PHP is not a functional language but some functional techniques may be used to improve our code: better readability, easier to maintain => cheaper code.
For many years, PHP was scripted in a procedural way, all in one file with functions everywhere. After version 5.*, applications have been written using the Object Oriented paradigm (OO). But rarely do we think of PHP in the functional paradigm. Of course, PHP is not a functional language, but we should be able to use the best of each paradigm. It’s not about OO against functional programming (FP), or to define which one is better.
The PHPvs. Golang comparison is a tough one. Initially created in 1994, PHP has been around for 24 years. Since then, PHP has seen its popularity rise due to its open source format, ease of use, and stability. However, as happens in every other aspect of life, the old have to make way for the new if they are not able to adapt to modern times. Even the most recent versions of PHP such as PHP 7 have left a lot to be desired in terms of security, scalability, concurrency and more. As times have changed, so have the demands of applications. Quickly deployable, concurrent, scalable, bug-free, low maintenance, and cost-efficient applications are the demand of the day.
Golang has time and again proven itself as a safe bet for Enterprise Applications. The following are just some of the features in which Golang outperforms PHP and turns out to be a wiser choice for businesses.
If you want to process large files using PHP, you may use some of the ordinary PHP functions like file_get_contents() or file() which have a limitation when working with very large files.
These functions rely on the memory_limit setting in the php.ini file; you may increase the value but these functions still are not suitable for very large files because these functions will put the entire file contents into memory at one point.
The first step in developing every program’s business, right after designing and defining the required classes, is class instantiation. And it is a very straightforward process. You call the class constructor which is exactly the same as the class name, followed by the respective namespace, pass the required arguments (if any), and that’s it.
The scenario described above is exactly what happens in nearly all situations. But there is a condition where exceptions may arise: whenever you try to instantiate a class dynamically.
Did you know you can serverless with PHP? OK, so serverless is clearly not a verb, but since I love serverless tech and have also loved PHP for longer than I’m going to admit (the dates of the earliest posts on my blog might serve as a clue), using these technologies together is definitely my idea of a good time.
I included an example of a serverless endpoint to receive incoming webhooks in my talk at PHPUK and I got a few questions about it so I thought I’d share that example in written form. Serverless makes a lot of sense for API endpoints in general – and also for webhook endpoints since they’re essentially the same thing. Deploying individual functions to the cloud makes the endpoints independent of one another, and serverless platforms scale on demand so if the API calls or incoming webhooks all arrive at once (the reality of the internet is bursty traffic), everything will still work well.
Although most of my work time is spent on ASP.NET and SharePoint development, I also have some PHP projects. I have my own favorite thin tooling for PHP but I decided to give Visual Studio Code (VS Code) a try with one of the projects. This blog post describes what I have in my dev box and what my first impressions are of using VS Code for PHP development.
Why VS Code?
VS Code is not an IDE like Visual Studio. It is also not a simple code editor with a few commands and syntax highlighting. It sits somewhere in the middle, making it a simple yet powerful tool thanks to the fact that it supports extensions. The main reasons why I considered trying out VS Code for PHP development are:
During a more or less large project, a situation may arise when the number of scheduled tasks (cron jobs) becomes so large that their support becomes a DevOps nightmare. To solve this problem, I came up with the idea of creating a PHP scheduler implementation, thereby making it a part of the project, allowing the tasks themselves to be part of its configuration. In this case, the necessary and sufficient number of cron jobs will be equal to one.
Some time ago, I was able to develop a module for event planning. It was just a simplified version of Google/Apple Calendar for users of the application. For storing the dates and rules regarding the repetition of events, it was decided to use the iCalendar format (RFC 5545), which allows one line to describe a schedule for repeating an event, while taking into account the days of the week, months, the number of repetitions, and much more. A few examples:
As we all know, most web developers either love or hate PHP with a passion. I’m one of those developers that absolutely love it. I know PHP like the back of my hand. Now, since 7.2 has been released, my love is growing even more! Let’s talk about the awesomeness that the newest version brings to us. Security Is the Most Important Thing Here The 7.2 Release offers some highly needed improvements to security.