The Phonebook App
Explore how to develop a functional PHP phonebook application by implementing pure functions and a REPL loop. Understand how to process user commands such as add, search, delete, and list, while adhering to functional programming principles for clear and maintainable code.
We'll cover the following...
We'll cover the following...
Patterns implementation
Before completing the pattern matching, it’s possible to add two routines to categorize, and hence simplify the printing output.
- The first of these functions,
registryAction, conveys a message that signals the completion of a write action. It’s suitable for thecreateanddeletepattern primitives. - The second,
showRegistryData, prints formatted registry contents, and works well with theallandsearchpattern primitives, which are extensions of the phonebook’s read faculty.
The rest of the patterns should now resemble the code in the following snippet:
Phonebook in action
The REPL is almost complete at this point. The only glaring absence in the design is an ...