Join Justin Yost for an in-depth discussion in this video PSR-7 bodies, part of Consuming RESTful APIs in PHP with Guzzle.
- [Instructor] Now that we've seen how to process a request…and a response, let's now see the PSR-7 bodies.…To do this, we'll open up the first file…and copy it, and we'll create a new file,…label it PSR seven body dot PHP,…and we'll paste in the contents from first in here.…The body of the message, of course, we've seen…that we can read the entire body all at once.…But if we wanted to pull off, say,…the first 20 bytes from the message?…Can we do that?…Why, indeed, we can.…
Let's update line 12 to read as echo response get body.…In this case, we'll call a method off of our get body,…read, and pass in the number of bytes we want to read.…In this case, 20.…We'll also go ahead and add on here our new line.…So we'll add in period, and then in double quotes,…backslash R, backslash N.…Let's save this file and go to our terminal application,…and we'll run the command PHP PSR seven body dot PHP.…
And now you'll see that we've only read the first 20 bytes.…We get the user ID and its value,…and then we get the first quote…
Author
Released
3/28/2017- Installing Guzzle
- Sending basic requests
- Sending asynchronous requests
- Sending concurrent requests
- Sending query data
- Sending request data
- Advanced Guzzle request options
- Reviewing basic Guzzle responses
- Processing response headers
- Reviewing PSR-7 requests, responses, bodies, and headers
Skill Level Intermediate
Duration
Views
Related Courses
-
PHP: Clean URLs on Apache Server
with David Powers1h 36m Intermediate -
PHP: Managing Persistent Sessions
with David Powers2h 41m Intermediate
-
Introduction
-
Welcome1m 2s
-
-
1. Guzzle Basics
-
Guzzle and HTTP5m 17s
-
What is REST?5m 46s
-
Installing Guzzle4m 6s
-
Our first Guzzle request6m 31s
-
-
2. Requests with Guzzle
-
Sending basic requests4m 43s
-
Sending concurrent requests3m 52s
-
Sending query data3m 5s
-
Sending request data4m 41s
-
-
3. Responses with Guzzle
-
Basic Guzzle responses4m 54s
-
Processing response headers7m 51s
-
Exceptions and Guzzle5m 13s
-
-
4. Guzzle and PSR-7
-
What is PSR-7?6m 24s
-
PSR-7 requests4m 59s
-
PSR-7 responses5m 14s
-
PSR-7 bodies3m 39s
-
PSR-7 headers5m 50s
-
PSR-7 streams6m 55s
-
PSR-7 middleware8m 39s
-
-
5. Testing and Guzzle
-
Basic Guzzle mock responses6m 29s
-
Guzzle request testing7m 14s
-
-
Conclusion
-
Next steps1m 12s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: PSR-7 bodies