Create your own HTTP Client: Build and design your own web project with Laravel, to consume services and APIs online.
During this course, you are going to learn all the required skills and concepts to consume from your own Laravel, PHP project, whatever service or API online.
Along this course, you are going to see how to perform requests over HTTP directly from your PHP code on Laravel.
Use whatever method of the HTTP protocol (GET, POST, PUT, PATCH and DELETE), to consume whatever service online that runs over HTTP, all of this directly from your own project with PHP and through advanced dependencies and facilities of Laravel, the PHP framework.
What are you going to learn?
Take full advantage of your tools and services (Sublime Text 3, PHP, Apache, Composer, PHP artisan, Laravel) and improve your agility and productivity to develop your projects.
What is HTTP?
HTTP stands for HyperText Transfer Protocol, which define HTTP as a protocol to transfer hypertext over the Internet. HTTP defines a set of methods/verbs and status codes to specify the way as how two points must establish a communication.
Many programming languages provide mechanisms to perform or receive HTTP requests and, of course, PHP is one of them, including therefore Laravel.
What is an HTTP Client?
In this context, an HTTP Client is a system capable of performing requests using the HTTP protocol to one or several systems or services, normally online, which one are capable of receiving requests over HTTP as well. Of course, an HTTP Client can only establish a connection with another system that works over HTTP too.
When a system performs a request over HTTP to an external service, that system becomes to an HTTP Client.
In this way whatever system, implemented in whatever language, like PHP, using whatever framework like Laravel, performs an HTTP requests becomes to an HTTP Client for any other service independently of the programming language (PHP - Laravel or not).
What is Laravel?
Laravel is the most popular PHP framework. With Laravel, you are going to be capable of developing whatever project, platform or system that you need using directly PHP and the best practices.
Laravel provides many features that allow you to implement your own complex or not features in short time and easily.
It does not end here! You will have for life access; it means that you can see the new classes, versions and sections of this course at any moment during your entire life.
What are you waiting for?Be a PHP professional with Laravel and take advantage of the web data with your own HTTP Client.
See you in classes!
Meet the instructor and learn some details about him: experience and skills. See what are you going to learn, during the whole course, and specific details about the results obtained along the classes
It is very common that certain terms and concepts of the world of web services or web applications in general, are a bit confusing leading to misunderstandings and even bad implementations. During this class, you are going to take a little view for the world of web services and APIs, terminologies, differences and technologies involved in this world.
During this class you are going to see some specific details about HTTP:
Some further details
The GET method for HTTP is the most commonly used HTTP method. Every time that you visit a website, you are performing a GET request through your web browser.
In the HTTP protocol and the REST services, the GET method is used to obtain information about several resources or a specific resource. This method is only used to obtain resources, not to create, update or delete its.
The POST method for HTTP is the second most commonly used HTTP method. Every time that you end a form in a website, you are performing (probably) a POST request through your web browser.
In the HTTP protocol and the REST services, the POST method is used to create a new resource, normally only one specific resource instead of several. This method should be only used to create new instances for resources, not to show, update or delete its.
The PUT and PATCH methods for HTTP are a "special" type or methods. Those are "special" because the browsers do not support them natively. Normally to use these methods from the browser we need to use method spoofing sending a hidden field in the form, specifying the real method.
In the HTTP protocol and the REST services, the PUT and PATCH methods are used to update an existing resource. Those methods should be only used to update existing instances, not to show, create or delete its.
The DELETE method for HTTP is a "special" type or method, like the PUT and PATCH, because the browsers do not support it natively. Normally to use this method from the browser we need to use method spoofing sending a hidden field in the form, specifying the real method.
In the HTTP protocol and the REST services, the DELETE method is used to delete an existing resource. This method should be only used to remove an existing instance, not to show, create or update its.
HTTP, being a protocol, defines a series of codes to follow and use, in specific cases, to communicate the result of an operation or HTTP request.
There exist several codes (some of these more used than others) that allow reporting if an operation went OK or if something went wrong.
XAMPP is a very useful tool for managing multiple services in one place. Services like Apache, PHP, and MySQL, can be easily managed from this tool.
One of the great facilities XAMPP is that it can be used on multiple operating systems, unlike other solutions such as WAMPP (windows), MAMPP (Mac) or LAMPP (Linux).
Composer, is an essential tool, for any project developed with PHP.
Through composer, you can easily access packages and open source projects that provide highly advanced features to a project.
Additionally, helps to easily manage the dependencies and self-generating scripts (autoload) for a functional code.
Sublime Text 3, is a code editor (different from an IDE) for building code in multiple languages in a very agile and effective way. It supports multiple operating systems and, in the case of Windows, includes a portable version.
Sublime Text has a huge community that develops many packages with different purposes, many of which facilitate code generation too.
Postman is a generic, multipurpose client, which allow you to test and consume online services via HTTP, using several HTTP methods; through a very simple and intuitive user interface.
A virtual host is a mechanism that facilitates the proper implementation and operation of a web project in the development environment. By having a virtual host in our system, we can easily emulate the operation of a real online application and avoid problems with the routes and the files, or to deliver our project to production
The great power of Sublime is the huge amount of packages available that expand the functionality of the code editor and help to be much more effective and efficient during the development.
During this class, you are going to install some very popular and useful packages which will be used and required during the course. With those packages, the development and code generation is going to be easier.
Before to start with the development and implementation of the HTTP client, it is necessary to know in depth, the service to be consumed.
During this class, you are going to see some important details about this service and how to take advantage of it along the course.
The API to consume provides multiple functions that can be executed via the HTTP GET method.
During this class, you will see how the API responds to GET requests and all the different possibilities you have for it. With this API, you can make GET requests to:
During this class, you will see the procedure to be followed, in order to obtain a valid access_token from the API and then be able to perform advanced operations on the API.
The API to consume also provides several operations that can be performed using the HTTP POST method.
During this class, you will see how the API responds to the POST requests and all the different possibilities you have for it. With this API, you can make POST requests to:
Of course, the API also responds to requests with the PUT or PATCH methods. In this case, the API threads the PATCH and PUT requests in the same way. With this API, you can make requests for PUT or PATCH, for this:
Finally, the API also allows removing resources, through requests using the DELETE method.
During this class, you will see how the API responds to requests using the DELETE method. With this API, you can make DELETE requests for:
Discover a very interesting way to resolve errors that you may face during the course and how to, effectively, use the source code of this project to improve your development and study experience.
With the tools installed correctly and with full knowledge of the service to consume, you can now proceed with the implementation of the client.
During this class, you will see how to obtain, through composer, the entire structure of Laravel framework to develop the client.
Normally on Linux and OSX, right after installation, you obtain a white screen, instead of the welcome message from Laravel.
To resolve this, you need to give permissions to some specific folders, so in that way, the framework can work properly.
Laravel is a comprehensive framework, so during this class, you are going to see its most important components, how some of these works and how to perform an initial configuration.
GuzzleHTTP is a very powerful and popular project that facilitates the task of making requests through HTTP. Guzzle will be a very great utility for your HTTP client.
During this class, you will see how to add and install Guzzle as part of the Laravel project and to make use of it.
During this class, you will create the first components that make up the client development.
In this class, you are going to see how to create a layout, a view, and a route.
The layout will be containing the HTML structure that is common to all views (avoiding repeat the same code in every view).
The main view will use the layout and will have a list of links that will be growing up class-by-class, giving access to all the different functionalities of the client.
The route is going to return/show the main view when the user accesses the main URL (/).
In this class, you'll see how is simple to use GuzzleHttp to make requests to online services.
You are about to implement a function that allows requests to any location with any HTTP method and with any number of parameters. Furthermore, you will learn the best modular way, to use the client and make requests on HTTPS and not only on simple HTTP.
It is time to implement the first client operation.
During this class, you are going to see how easily implement functionality that allows to consume the API using the GET methods and get the list of all students, then display it in a friendly way, to the user, using an HTML table.
During this class, you'll see how easily implement a functionality that allows you to perform a GET request to the API and get the list of all courses.
The procedure is very similar to the previous class, however, you have to keep in mind that the attributes change and therefore views must adapt to this.
It is time to practice and demonstrate the knowledge acquired during previous classes.
You have seen how it comes to display the list of all students and courses, so now, put hands to work and implements the functions and components necessary to display the list of all teachers.
It is the turn of GET requests, but passing values in the URL. In this case, for a specific instance, should be sent the student id.
During this class, you'll see how to implement functionality to send a GET request sending the id of the student, entered by the user and then get the instance of the student.
Let's do the same as in the previous class, but now to obtain a specific instance of a teacher.
During this class, you'll see how to implement functionality to send a GET request sending the id of the teacher, entered by the user and then get the instance of that teacher.
Let's now put things a little further and put into practice what has been.
Again, you've seen how to proceed to obtain and display a teacher and a student from a given id, so now, your task will be to implement the functions and components required to show a course from a given id.
The API that is being consumed requires a valid access_token every time it receives requests for any HTTP method, different than GET.
During this class, you are going to see how to implement a simple mechanism to obtain a valid access_token, which can be used to perform advanced requests through POST, PUT / PATCH, and DELETE.
In order to be very modular, we are going to implement a function that automatically obtains a valid access_token using the function implemented in the previous class and add that access_token to the Authorization header for the request.
In that way, you can use this function every time that you need to make a request that needs an access_token.
Once it is possible to obtain easily an access_token, you can proceed with more complex requests.
During this class, you are going to see how to perform a POST request to the API to create a new student, from data entered by the user.
Now that you have seen how a student is created, and all the necessary components, sure you are going to get the same in the case of a teacher.
This exercise requests that you implement everything required to create a teacher in the API, from the client.
This class can be understood as the knot of the course. This class requires all you has learned during the previous classes.
To edit a resource, you must first get the list of all available resources to edit, and that the user chooses one. From the resource chosen, you should get the details of it to show it to the user and then make the updating stuff.
It is time to solve your own knot of history. For this exercise, you require that the client allows a user to update the information of a selected teacher.
During this class, you are going to see how to remove a teacher from the API, via HTTP DELETE requests.
This class has an important detail that is necessary to emphasize; that is, a teacher can not be removed if already have associated courses.
You already know what to do :P It is going to be very similar to the process of remove a teacher. In fact, you do not have any kind of restriction.
I enjoy transmitting knowledge and skills to the people through classes and contents. Then, see how they build their projects and tools using the concepts learned.
Continually work on improving my speech, looking for the best way to reach out the students with the central concepts and skills, I love easy but effective ways to transmit every single idea.
I appreciate every minute developing, especially when I can use my skills to implement projects that can help other developers to learn or to make their job and lives easier.
I am constantly looking to work in new projects to leverage my skills and improving the lives of people with more facilities to share the experiences and findings with my students then.
I am excited to contribute to a better world teaching people new skills and, in the way, learn through the experiences and issues of them to improve our skills together.