Category: classes

Composer: how to autoload php classes outside the “vendor”

The Composer (https://getcomposer.org/) is a dependency manager (packages) widely used in language PHP and provides many facilities, since it is responsible for checking, download to engage our project all the “libs” of third parties that we will need.

These “libs”, when downloaded by Composer, are grouped within a directory called “vendor”. In addition, a file called “autoload.php” is also created in this folder, responsible for “loading” all the classes we need to use. Basically, all I have to do is import “autoload.php” into a file of my project and I will have access to all classes of “libs” downloaded by Composer.

Continue lendo

Understanding Interfaces

In the various php projects that I have already been involved in and those that I am still involved in, I realize that the Interfaces, which is something very important in the Object Orientation Paradigm, are very little used and / or most of the time, NOT used. Several programmers don’t give a damn about the interfaces. Some deem it unnecessary, others unimportant but in general I believe that this underutilization is due to the lack of knowledge of its characteristics and its conception.

That’s why I’m here writing this post. To try to explain to you readers what an Interface is, what it is for, how to implement / use it and what are the advantages it brings.

Continue lendo

DataValidator: is_date () method

Hi guys! Continuing our series of posts on the DataValidator class , today we are going to address the is_date () method , which, as the name says, is a function for validating fields of type Data (or Date if you prefer) .

The method is very flexible because it allows the validation of both instances of the DateTime class and a date (including time) in a specific format defined by the user.See a validation using an instance of the DateTime class.

Continue lendo

DataValidator: contains() method

In the last post I presented to you a class for data validation that I implemented and made available through my link on GitHub for the whole php community to be able to use, guess and why not contribute.

Well then. From this post and in future posts I will address some of the validation methods that I think are important and that it is interesting to emphasize the techniques for a better use of them.

Continue lendo