Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
The Art of Modern PHP 8

You're reading from  The Art of Modern PHP 8

Product type Book
Published in Oct 2021
Publisher Packt
ISBN-13 9781800566156
Pages 420 pages
Edition 1st Edition
Languages
Author (1):
Joseph Edmonds Joseph Edmonds
Profile icon Joseph Edmonds

Table of Contents (19) Chapters

Preface 1. Section 1 – PHP 8 OOP
2. Chapter 1: Object-Oriented PHP 3. Chapter 2: Inheritance and Composition, Encapsulation and Visibility, Interfaces and Concretions 4. Chapter 3: Advanced OOP Features 5. Section 2 – PHP Types
6. Chapter 4: Scalar, Arrays, and Special Types 7. Chapter 5: Object Types, Interfaces, and Unions 8. Chapter 6: Parameter, Property, and Return Types 9. Section 3 – Clean PHP 8 Patterns and Style
10. Chapter 7: Design Patterns and Clean Code 11. Chapter 8: Model, View, Controller (MVC) Example 12. Chapter 9: Dependency Injection Example 13. Section 4 – PHP 8 Composer Package Management (and PHP 8.1)
14. Chapter 10: Composer For Dependencies 15. Chapter 11: Creating Your Own Composer Package 16. Section 5 – Bonus Section - PHP 8.1
17. Chapter 12: The Awesomeness That Is 8.1 18. Other Books You May Enjoy

It lives

Just to show that the toy MVC is fully functional, here is the bit of code that simulates a single hit to the home page:

src/Part3/Chapter8/toy_mvc.php

Repo: https://git.io/JRw53

<?php
declare(strict_types=1);
namespace Book\Part3\Chapter8;
use Book\Part3\Chapter8\ToyMVC\BrowserVisit;
require __DIR__ . '/../../../vendor/autoload.php';
$homePage = (new BrowserVisit())->visit('/');
echo $homePage;

Output:

To simulate the browser, we have a simple class called BrowserVisit:

src/Part3/Chapter8/ToyMVC/BrowserVisit.php

Repo:

<?php
declare(strict_types=1);
namespace Book\Part3\Chapter8\ToyMVC;
/**
 * This class lets us very simply simulate a browser visiting our toy MVC app.
 */
final class BrowserVisit
{
    private FrontController $frontController;
    public function __construct()
    {
        $this-...
lock icon The rest of the chapter is locked
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 $15.99/month. Cancel anytime}