Contents
Introduction
Section 1: Auditing
What's Covered?
Planning Your Auditing Strategy
Getting Into the Right Mindset
Recording Your Findings
Automated Tooling
PHP Insights
Enlightn
Larastan
Style CI
Code Coverage
Manual Auditing
Investigating "raw" Database Queries
Finding Incorrect Authorisation
Checking Validation
Finding "Fake Facades"
Finding Business Logic in Helpers
Finding N+1 Queries
Finding Controllers That Use Other Controllers
Finding Logic and Queries in Blade Views
Finding Hard-Coded Credentials
Check Open Package Routes
Reviewing Project Documentation
Section 2: Testing
What's Covered?
Planning Your Testing Strategy
The Benefits of Writing Tests
Spotting Bugs Early
Making Future Work and Refactoring Easier
Changing the Way You Approach Writing Code
Tests-As-Documentation
Prove That Bugs Exist
Structuring Your Tests
Directory Structure
Choosing What To Test
Test Structure
Data Providers
Writing the Tests
Prioritising Mission-Critical Tests First
Writing the Rest of the Tests
Benefits of Writing the Easy Tests First
Preventing Test Fatigue
Testing Your UI with Laravel Dusk
Installation
Testing a Simple Form
Dusk Pages and Selectors
Running Failed Tests and Groups
Creating a CI Workflow Using GitHub Actions
Using an .env.ci File
Running the Test Suite
Larastan
Laravel Dusk
Output
Section 3: Fixing
What's Covered?
Planning Your Fixing Strategy
Using an Error Reporting System
Types of Errors
The Benefits of an Automated Error Reporting System
Error Reporting Using Flare
Uptime Checking, Queue Monitoring, and Scheduler Monitoring
Uptime Monitoring with Oh Dear
Scheduler Monitoring with Oh Dear
Queue Monitoring with Oh Dear
Updating PHP, Laravel, and Packages
Upgrading in Small Increments
Automating the Upgrade Using Laravel Shift
Planning Upgrades Early
Using a Suitable Local Development Environment
Using Tests to Fix Bugs
What is Test-Driven Development?
The Advantages of Test-Driven Development
The Disadvantages of Test-Driven Development
Fixing a Real Bug Using Test-Driven Development
Safely Removing Dead Code
Checking the Version Control History
Scream Test
Logging or Reporting the Usage
Removing the Code with an Atomic Commit
Section 4: Improving
What's Covered?
Planning Your Improvement Strategy
Making the Most of PHP's Type System
Using Type Hints and Return Types
Union Types
Type Hints and Return Types in Closures
DRYing Up Your Code
Advantages of DRYing Up Your Code
When to DRY Up Your Code
Refactoring Conditions
Reducing Indented Code
Replacing if and elseif with match
Using the Nullsafe Operator
Using Database Transactions
Adding the Database Transactions
Manually Using Database Transactions
Tips for Interacting with Third-Party Services
Using Automatic or Manual Transactions
Dispatching Queued Jobs inside Database Transactions
Improving the Testability of Your Code
Using Objects Over Arrays
Final Words
Discount Codes
Flare
Oh Dear
StyleCI
Laravel Security In Depth
React Hooks allow you to easily encapsulate, reuse, and refactor logic with the same level of simplicity that components bring to user interface organization.
In this second edition, React expert and author of many popular React books, Daniel Bugl guides you through the full spectrum of React Hooks, and teaches you how to handle forms, routing, and data fetching in modern React development. This edition is fully updated to React 19, with a revamped structure, expanded real-world use cases, and coverage of all newly introduced Hooks.
Starting with the fundamentals, you'll gain a deep understanding of how Hooks work under the hood and how to apply Hooks patterns efficiently. The chapters guide you through using State, Reducer, and Effect Hooks to manage application state, side effects, and complex logic for building your first Hook-based app. You'll utilize Suspense and Context APIs for streamlined data fetching and state management, master Form Actions for handling submissions, and implement routing with Hooks. You’ll also create custom Hooks for advanced functionality and write tests for reliability. Finally, you’ll learn how to refactor an existing app with class components into modern Hooks architecture.
By the end of this React book, you'll be well-equipped to use React Hooks to modernize and optimize your React projects.
Master and apply new React 19 Hooks, such as useActionState, useFormStatus, useOptimistic, and others
Use React Hooks and Context to manage state in your web applications
Efficiently fetch, update, and cache data using TanStack Query and Suspense
Manage user input and form submission using Form Actions with Hooks
Discover how to implement routing in your apps using React Router and Hooks
Create and test your own Hooks to encapsulate, reuse, and refactor logic in your apps
This book is ideal for React developers looking to modernize their applications using React Hooks, Context, and Suspense. Beginners and experienced developers alike will gain a solid understanding of Hooks and their internal workings. If you're familiar with React and JavaScript, this book will help you upskill by teaching you best practices, performance optimization, and scalable application building. No prior experience with Hooks is required—this book covers everything from fundamentals to advanced patterns.