Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PHP Web Development with Laminas

You're reading from   PHP Web Development with Laminas Build a fully secured and functional e-commerce application with PHP using the Laminas framework

Arrow left icon
Product type Paperback
Published in Nov 2022
Publisher Packt
ISBN-13 9781803245362
Length 394 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Flavio Gomes da Silva Lisboa Flavio Gomes da Silva Lisboa
Author Profile Icon Flavio Gomes da Silva Lisboa
Flavio Gomes da Silva Lisboa
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

1. B18382_FM
2. B18382_TOC_ePub FREE CHAPTER
3. B18382_Preface
4. B18382_Part1
5. B18382_01
6. B18382_02
7. B18382_03
8. B18382_04
9. B18382_Part2
10. B18382_05
11. B18382_06
12. B18382_07
13. B18382_08
14. B18382_09
15. B18382_10
16. B18382_Part3
17. B18382_11
18. B18382_12
19. B18382_13
20. B18382_14
21. B18382_Index
22. B18382_BM

Table of Contents

Preface

Part 1: Technical Background

1

Introducing Laminas for PHP Applications

Why do we need web frameworks?

Continuous integration and continuous delivery

The usefulness of a framework

From Zend Framework to Laminas

My introduction to Zend Framework

Zend Framework – the reference architecture for PHP applications

The differences between Zend Framework and Laminas

The technical and social infrastructure of the Laminas community

Summary

2

Setting Up the Environment for Our E-Commerce Application

Technical requirements

Installing Laminas

Installing Laminas through an isolated component of Laminas

Installing Laminas through an MVC skeleton application

Configuring the IDE – Eclipse for PHP developers

Integrating Laminas and Eclipse

Managing MySQL

Summary

3

Using Laminas as a Library with Test-Driven Development

Technical requirements

Understanding the requirements for developing our software

Use case – managing school classes

Implementing a structure for the use case

Creating our first automated test

Developing our use case with TDD

Creating our SchoolClassTest test class

Creating a test method in the SchoolClass class

Creating the SchoolClass class

Configuring autoloading of classes

Configuring the autoloading of test classes

Creating the config.php file and rerunning the SchoolClassTest test case

Creating a new testInserting test method

Creating an edition form edit.php

Creating a SchoolClassTest->testUpdating test method

Altering edit.php

Altering save.php

Creating the delete.php file

Generating code coverage reports

Summary

4

From Object-Relational Mapping to MVC Containers

Technical requirements

Using ORM

Use case – managing students

Implementing the use case

Running the SchoolClassTest->testListing test

Adjusting CRUD files

Using Laminas as a container

Creating the school3 project

Creating the School module

Ensuring the module has the right namespace

Implementing the test methods

Running the tests

Summary

Part 2: Creating an E-Commerce Application

5

Creating the Virtual Store Project

Technical requirements

Understanding the project requirements for the sample web application

Identifying use cases and actors

Understanding the class diagram for Whatstore

Creating the project instance

Understanding the structure of a Laminas project

Preparing the modules for our project

Summary

6

Models and Object-Relational Mappers with Behavior-Driven Development

Technical requirements

BDD with Behat

Creating our first scenario

Mapping a user story to an automated test

Creating models from user stories

Creating mappers from user stories

Adding a product to the products table

Checking whether the product was inserted

Creating a generic model and a generic mapper

Creating other models with Behat

Summary

7

Request Control and Data View

Technical requirements

Understanding the relationship between HTTP and PHP

The request life cycle in the Laminas MVC

Implementing CRUD with a controller and view pages

Testing our current test cases

Testing product insertion

Testing product recovery

Testing product updates

Testing product deletion

Creating the ProductAPIController class

Implementing the ProductController class

Implementing the pages for ProductController

Implementing the interaction between the web interface and API

Testing the interaction between the web interface and API

Summary

8

Creating Forms and Implementing Filters and Validators

Technical requirements

Generating a form for discounts with laminas-form

Creating CRUD implementation using the laminas-form component

Creating a class to define an HTML form

Filtering input data

Validating input data

Summary

9

Event-Driven Authentication

Technical requirements

Creating login and logout actions for the Inventory module

Creating tests for login and logout actions

Creating login and logout actions

Implementing the user authentication for the Inventory module

Creating the employee’s registration

Testing the login page

Verifying user identity based on events

Delegating the authentication listener to a module

Summary

10

Event-Driven Authorization

Technical requirements

Creating roles registration

Creating resources registration

Filling the resources table

Associating resources with roles

Associating roles with users

Implementing access control

Verifying users’ permissions

Modifying the test bootstrap

Creating an identity manager

Summary

Further reading

Part 3: Review and Refactoring

11

Implementing a Product Basket

Technical requirements

Managing the product inventory

Refactoring the customer home page

Controlling the product basket

Controlling the customers

Order closing

Decoupling the generic behavior of authentication

Summary

12

Reviewing and Improving Our App

Technical requirements

Principles of agile development

Eliminating duplicated code

Removing unnecessary configuration

Creating a product search box

Generating API documentation

Isolating identity management for each module

Modifying the class for identity management

Refactoring listener and controller classes

Summary

13

Tips and Tricks

Technical requirements

Creating mapped models

Customizing filters and validators

Creating a customized filter

Creating a customized validator

Understanding the Laminas view layer

Producing JSON responses with laminas-view

Uploading files with laminas-form

Changing the application layout

Mastering the controller layer

Detecting AJAX requests

Exchanging messages between the controller and view layers

Finishing controller actions

Summary

14

Last Considerations

Other Laminas components

Cache

CLI

Crypt

CSRF

DOM

Escaper

Feed

Hydrator

JSON-RPC server

LDAP

Log

Microservice-oriented development

Building APIs

Community resources

Summary

Index

Other Books You May Enjoy

You have been reading a chapter from
PHP Web Development with Laminas
Published in: Nov 2022
Publisher: Packt
ISBN-13: 9781803245362
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime