My Account Log in

2 options

Building RESTful web services with PHP 7 : Lumen, Composer, API testing, microservices, and more / Haafiz Waheed-ud-din Ahmad.

Ebook Central College Complete Available online

View online

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Ahmad, Haafiz Waheed-ud-din, author.
Language:
English
Subjects (All):
Application program interfaces (Computer software).
Web sites--Design.
Web sites.
Physical Description:
1 online resource (1 volume) : illustrations
Edition:
1st edition
Other Title:
Building representational state transfer web services with PHP 7
Place of Publication:
Birmingham, [England] ; Mumbai, [India] : Packt Publishing, 2017.
System Details:
text file
Summary:
Learn how to build RESTful API and web services in PHP 7 About This Book Leverage the Lumen framework to build RESTful API endpoints for your applications Understand how to increase efficiency and security of your web service. Learn to apply the concepts by implementing the examples covered in the book Who This Book Is For This book is for PHP developers who wish to learn about the REST architecture to be able to build and consume REST APIs in their applications. What You Will Learn Understand the REST API architecture and its benefits Write RESTful API web services in PHP 7 Address security-elated issues in a REST API Leverage the importance of automated testing and write tests for API endpoints Identify security flaws in our current API endpoints and tackle them effectively Observe the working of Lumen microframeworks and write RESTful web services in it In Detail REST is the most wide spread and effective standard to develop APIs for internet services. With the way PHP and its eco-system has modernized the way code is written by simplifying various operations, it is useful to develop RESTful APIs with PHP 7 and modern tools. This book explains in detail how to create your own RESTful API in PHP 7 that can be consumed by other users in your organization. Starting with a brief introduction to the fundamentals of REST architecture and the new features in PHP 7, you will learn to implement basic RESTful API endpoints using vanilla PHP. The book explains how to identify flaws in security and design and teach you how to tackle them. You will learn about composer, Lumen framework and how to make your RESTful API cleaner, secure and efficient. The book emphasizes on automated tests, teaches about different testing types and give a brief introduction to microservices which is the natural way forward. After reading this book, you will have a clear understanding of the REST architecture and you can build a web service from scratch. Style and approach This book will get you started with REST architecture and will also teach you different methods to build web services from scratch.
Contents:
Cover
Copyright
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Table of Contents
Preface
Chapter 1: RESTful Web Services, Introduction and Motivation
Web services
Why a web service?
REST architecture
Client server
Stateless
Cache-able
Uniform interface
Resource identification
Manipulation of resources through representations
Self-descriptive messages
Hypermedia as the engine of application state (HATEOAS)
Code on demand (optional)
Layered system
RESTful web services
Conventions of RESTful web services
HTTP verbs and URL structure
List operation
Create operation
READ operation
Update operation
Delete operation
Why RESTful web services?
REST versus SOAP
Nature of HTTP methods
Safe/unsafe HTTP methods
Idempotent and non-idempotent methods
HTTP response
Response type
Response codes
Case study - RESTful web service endpoints for a blog
Blog post
Requirements
Endpoints
Creating blog post
Reading blog post
Updating blog post
Delete blog post
Listing all blog posts
Blog post comments
Creating the post's comment
Reading a comment
Updating a comment
Deleting a post comment
Listing all comments for a particular post
More resources
Summary
Chapter 2: PHP7, To Code It Better
Scalar type declaration
Return type declaration
Null coalescing operator
Spaceship operator
Group use declarations
Generator-related features
What are generators?
Generator return expression
Generator delegation
Anonymous classes
Closure::call()
Errors and exceptions
PHP7.1
Nullable types
Symmetric array destructuring
Support for keys in list()
Multi-catch exception handling
Summary.
Chapter 3: Creating RESTful Endpoints
Creating a REST API for a blog in PHP
Creating a database schema
Blog user/author table schema
SQL for users table
Blog post table schema
Blog post comments schema
Creating a RESTful API's endpoint
Code structure
Common components
DB class
Router class
Code sync
Creating blog post endpoints
REST client
To do
Visible flaws
Validation
Solution
Authentication
Proper 404 pages
Chapter 4: Reviewing Design Flaws and Security Threats
Finding problems in the current code
Structural and design flaws
Missing query builder layer
Incomplete router
Usage of OOP
Separate Configurations from Implementation
Should write tests
Input validation
Handling 404 and other errors
Meta information missing
DB fields abstraction
Security
Securing API endpoints
What is Auth middleware?
Common security threats in RESTful web services
Use of HTTPS
Securing an API key/token
Not passing an access token in the URL
Access token expiration
Limited scope access token
Public and private endpoints
Public API endpoints
Insecure direct object reference
Restricting allowable verbs
Available reusable code
Chapter 5: Load and Resolve with Composer, an Evolutionary
Introduction to Composer
Installation
Installation on Windows
Installation on Linux/Unix/OS X
Global Installation
Usage of Composer
Composer as a dependency manager
Installing packages
Installing using composer.json
The composer.json in detail
The require object
The require-dev object
The autoload and autoload-dev
The scripts
The composer.lock
Composer as an auto-loader
Example
Composer for creating a project
Chapter 6: Illuminating RESTful Web Services with Lumen
Introducing Lumen
Why micro-framework?
Why Lumen?
What Lumen provides
What Lumen has in common with Laravel
How Lumen is different from Laravel
What exactly Lumen provides
A Good Structure
Separate configurations
Router
Middle-wares
Service Container and Dependency Injection
HTTP responses
Eloquent ORM
Database migration and seeding
Unit testing
Installing Lumen
Configuration
Setting up the database
Writing migrations
Writing RESTful web service endpoints
Writing the first controller
Lumen routes
REST resource
Eloquent ORM (model layer)
Creating models
Eloquent relationships
Controller Implementation
What we are missing?
Validation and negative cases?
/api/posts with GET method
/api/posts with the POST method
/api/posts/1 with the GET method
/api/posts/1 with the PATCH/PUT method
/api/posts/1 with the DELETE method
User authentication
Other missing elements
Comment Resource Implementation
Chapter 7: Improving RESTful Web Services
Dingo, simplifying RESTful API development
Installation and configuration
Simplifying routes
API versioning
Rate limiting
Internal requests
Responses
Authentication and middleware
JWT Auth setup
The Manual way
Simpler way through Lumen JWT authentication integration package
Log in
Invalidate token
Refresh token
Transformers
Understanding and setting transformers
Using transformers
Encryption
SSL certificate, different options
Chapter 8: API Testing &amp
#x2013
Guards on the Gates
The need for automated tests
Types of testing
Acceptance testing
Functional testing
Integration testing.
What type of testing will we do?
Testing frameworks
CodeCeption introduction
Setup and understanding the structure
tests/{suite-name}/
tests/{suite-name}.suite.yml
tests/_support/_generated/{suite-name}TesterActions.php
tests/_support/{suite-name}Tester.php
tests/_support/Helper/{suite-name}.php
Creating the API suite
Configuring the API suite
Writing test cases
API tests for post resource
Other test cases
Chapter 9: Microservices
Introducing Microservices
How to divide an application into microservices?
Motivation towards microservices
Maintenance and debugging
Scalability
Technology diversity
Resilience
Replaceability
Parallelization
How it is different from SOA
Team structure
Challenges of micro-services
Infrastructure maintenance
Performance
Debugging and fault-finding
Logs should be centralized
Logs should be searchable
Track chain of requests
Dynamic log levels
Implementation
Deployments
Inter-services communication
Synchronous communication
Asynchronous communication
Shared library or common code
What's next
Index.
Notes:
Includes bibliographical references and index.
Description based on online resource; title from PDF title page (ebrary, viewed October 13, 2017).
OCLC:
1005351394

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Library Catalog Using Articles+ Library Account