Functional PHP: A First Approach

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.

Link: https://dzone.com/articles/functional-php-a-first-approach?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

PHP vs. Golang: A Comparison

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.

Link: https://dzone.com/articles/php-golang-a-comparison?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

Processing Large Files Using PHP

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.
Memory Limitation
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.

Link: https://dzone.com/articles/processing-large-files-using-php?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

Dynamic Class Instantiation and NS in PHP

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.

Link: https://dzone.com/articles/dynamic-class-instantiation-amp-ns-in-php?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

JavaScript and Underscore.js Type Methods in PHP

I’ve been working with PHP since 2000 and with JavaScript even longer. Over the last decade, JavaScript has evolved drastically. It had a promising design from the very beginning and gained its current incredible shape with the shift to ES2015 (Harmony). PHP, though, didn’t change that much. Apparently, it’s doomed always to suffer from its own legacy. It arrived in the mid-90s as a simple CGI app to maintain Rasmus Lerdorf’s home page and have been more like spontaneously developing ever since. That resulted in syntax inconsistency, a mix of functional and OOP-based assets, and absence of a decent language specification. So every time I switch to PHP I miss the rationality, predictability, and flexibility of JavaScript. This made me consider a library which would bring a JavaScript-like development experience to PHP. Eventually, I came up with Extras, which extends PHP types with JavaScript (other than Underscore) methods, unlocks chaining, and introduces the PlainObject type representing an object-literal.
JavaScript Meets PHP
The library enriches with JavaScript and Underscore.js methods the following PHP types: array (both sequential and associative), string, number (integer, float, NaN), function (callable), collection (Iterable, ArrayObject, Iterator) and boolean. Every added method is a static method of the class representing the type. So we can access any directly, without the creation of a chain like Arrays::map.

Link: https://dzone.com/articles/javascript-and-underscorejs-type-methods-in-php?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

Handle Webhooks With Serverless PHP

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.

Link: https://dzone.com/articles/handle-webhooks-with-serverless-php?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

VS Code for PHP Development

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:

Link: https://dzone.com/articles/vs-code-for-php-development?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

Simple Task Scheduler With PHP

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:

Link: https://dzone.com/articles/simple-task-scheduler-on-php?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev

What’s New in PHP 7.2?: Literally Better Everything

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.

Link: https://dzone.com/articles/whats-new-in-php-72-literally-better-everything?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev