Category: classes

Guzzle: a HTTP client to php

At a time when interoperability between systems has become increasingly important and the creation/use of APIs is increasingly ascending, it is always important to think about the consumption of third party services within our projects.

In php, although it is relatively simple to make requests “http” with the native resources of the language itself, it is recommended that a library be used for this purpose, since this way we have more security and resources that facilitate and make this process more agile procedure.

Continue lendo

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

Object-oriented programming: 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