The
PHP
Workshop

Built by a team of experts to help you unlock your next promotion, reboot your career, or kick off your latest side project.

Get Started Today

You'll be up and running with PHP in no time at all.

  • $34.99

    $34.99The PHP Workshop

    Unlock one year of full, unlimited access and get started right away!
    Buy Now

Engineered for Success

Nobody likes going through hundreds of pages of dry theory, or struggling with uninteresting examples that don’t compile. We've got you covered. Any time, any device.

  • Learn by doing real-world development, supported by detailed step-by-step examples, screencasts and knowledge checks.

  • Become a verified practitioner, building your credentials by completing exercises, activities and assessment checks.

  • Manage your learning based on your personal schedule, with content structured to easily let you pause and progress at will.

Learn By Doing

You already know you want to learn PHP 7, and a smarter way to learn PHP development is to learn by doing.

The PHP Workshop focuses on building up your practical skills so that you can develop cutting-edge, high-performance web applications. It’s ideal if you’re looking to work with an existing application, or even develop your own side project with a PHP framework like Laravel. You'll learn from real examples that lead to real results.

On Your Terms

Build up and reinforce key skills in a way that feels rewarding.

You won't have to sit through any unnecessary theory. If you're short on time you can jump into a single exercise each day or spend an entire weekend learning about third-party libraries. It's your choice.

An Ideal Start

Fast-paced and direct, The PHP Workshop is the ideal companion for PHP beginners.

You'll build and iterate on your code like a software developer, learning along the way. This process means that you'll find that your new skills stick, embedded as best practice. A solid foundation for the years ahead.

Begin Your Journey

A simple, straightforward and pain-free way to learn PHP.

  • $34.99

    $34.99The PHP Workshop

    Unlock one year of full, unlimited access and get started right away!
    Learn for Free

Everything You Need

Every Workshop includes access to dedicated support, course discussions and a wider learning community. Ask questions, share answers and work with the community to expand your learning.

  • Engage and participate in live user discussions, baked right into your course from start to finish. Share, learn and grow together.

  • Get live updates and interact directly with the product development, editorial and authoring teams across the Packt network.

  • Create, showcase and share your own learning outcomes and motivational stories across the entire workshop community.

Get Build-Ready

Every Workshop includes a whole host of features that work together to help you get the job done. You’ll be ready to tackle real-world development in no time.
  • Hack Your Brain

    We've applied the latest pedagogical techniques to deliver a truly multimodal experience. It'll keep you engaged and make the learning stick. It's science!

  • Build Real Things

    Nobody likes wasting their time. We cut right to the action and get you building real skills that real, working developers value. The perfect approach for a career move.

  • Learn From Experts

    We've paired technical experts with top editorial talent. They've worked hard to deliver you the maximum impact for each minute you spend learning. It's our secret sauce.

  • Verify Your Credentials

    You can become a verified practitioner. Complete the course to get a certificate. It's perfect for sharing on social media. Hello LinkedIn!

  • Receive Free Updates

    Technology keeps changing, and so do we. We keep versions updated independently, so you'll always have access. No more worrying about third-party release cycles.

  • Access Anywhere

    All you need is an internet connection. We've built every course so that it works on desktop and mobile, giving you options that fit within your schedule.

What's Inside

From A to Z, we've got you covered!

  • Workshop Onboarding

    • Welcome to The PHP Workshop
    • Installation and Setup
    • Credits
  • 1. Introducing PHP

    • Overview
    • Getting Started with PHP Web Development
    • Exercise 1.1: Printing Output via Shell
    • Exercise 1.1: Printing Output via Shell
    • Exercise 1.2: Printing Output with a PHP Script
    • Exercise 1.2: Printing Output with a PHP Script
    • Assigning and Using Variables
    • Exercise 1.3: Using Input Variables to Print Simple Strings
    • Exercise 1.3: Using Input Variables to Print Simple Strings
    • Exercise 1.4: Using the Built-in Server to Print a String
    • Exercise 1.4: Using the Built-in Server to Print a String
    • HTML and CSS
    • Exercise 1.5: Creating a Login Form Page Using Bootstrap
    • Exercise 1.5: Creating a Login Form Page Using Bootstrap
    • Exercise 1.6: Printing PHP Code Output between HTML Tags
    • Exercise 1.6: Printing PHP Code Output between HTML Tags
    • Exercise 1.7: Displaying Server Information
    • Exercise 1.7: Displaying Server Information
    • Additional Predefined Variables
    • Exercise 1.8: Assigning a Variable by Reference and Changing its Value
    • Exercise 1.8: Assigning a Variable by Reference and Changing its Value
    • Exercise 1.9: Using isset to Check whether a Variable Has Been Set
    • Exercise 1.9: Using isset to Check whether a Variable Has Been Set
    • Activity 1.1: Displaying Query Strings in the Browser
    • Summary
  • 2. Types and Operators

    • Overview
    • What are Data Types?
    • Exercise 2.1: Using Simple Data Types
    • Exercise 2.1: Using Simple Data Types
    • Arrays
    • Exercise 2.2: Creating a Multidimensional Array
    • Exercise 2.2: Creating a Multidimensional Array
    • Scalar Types
    • Exercise 2.3: Converting a Boolean to an Integer
    • Exercise 2.3: Converting a Boolean to an Integer
    • Exercise 2.4: Converting an Integer to a String
    • Exercise 2.4: Converting an Integer to a String
    • Exercise 2.5: Converting Centimeters to Meters
    • Exercise 2.5: Converting Centimeters to Meters
    • Operators and Expressions
    • Activity 2.1: Printing the BMI of a User
    • Summary
  • 3. Control Statements

    • Overview
    • Boolean Expressions
    • Boolean Constants
    • Logical Operators
    • Branching
    • Exercise 3.1: Creating a Basic Script to Implement the if...else Test Case
    • Exercise 3.1: Creating a Basic Script to Implement the if...else Test Case
    • Exercise 3.2: Creating a Script to Implement a Nested if...else Structure
    • Exercise 3.2: Creating a Script to Implement a Nested if...else Structure
    • Ternary Operator
    • Exercise 3.3: Creating a Script Using the if... elseif... else Statement
    • Exercise 3.3: Creating a Script Using the if... elseif... else Statement
    • The switch Case
    • Exercise 3.4: Creating a Script to Implement a Switch Case
    • Exercise 3.4: Creating a Script to Implement a Switch Case
    • Looping
    • Exercise 3.5: Printing the Numbers 1 to 10 Using a while Loop
    • Exercise 3.5: Printing the Numbers 1 to 10 Using a while Loop
    • The do…while Loop
    • Exercise 3.6: Converting a while Loop to a do...while Loop
    • Exercise 3.6: Converting a while Loop to a do...while Loop
    • The for Loop
    • Exercise 3.7: Using a for Loop to Print the Days of the Week
    • Exercise 3.7: Using a for Loop to Print the Days of the Week
    • The foreach Loop
    • Exercise 3.8: Using a foreach Loop to Print the Days of the Week
    • Exercise 3.8: Using a foreach Loop to Print the Days of the Week
    • Nesting Loops
    • Exercise 3.9: Using Nested foreach Loops
    • Exercise 3.9: Using Nested foreach Loops
    • The break Statement
    • Exercise 3.10: Using a break Statement to Terminate a Loop's Execution
    • Exercise 3.10: Using a break Statement to Terminate a Loop's Execution
    • Exercise 3.11: Using continue to Skip an Item in a List
    • Exercise 3.11: Using continue to Skip an Item in a List
    • Alternative Control Syntaxes
    • Activity 3.1: Creating a Movie Listing Script to Print Movies per Director
    • Tips for Control Structures
    • Summary
    • Survey I
  • 4. Functions

    • Overview
    • What is a Callable?
    • Exercise 4.1: Using Built-in Functions
    • Exercise 4.1: Using Built-in Functions
    • Types of Callables
    • Language Constructs
    • Introduction to Built-In Functions
    • Exercise 4.2: Working with print_r()
    • Exercise 4.2: Working with print_r()
    • A Varying Number of Parameters
    • Exercise 4.3: Using Built-In Functions with Arrays
    • Exercise 4.3: Using Built-In Functions with Arrays
    • Introduction to User-Defined Functions
    • Exercise 4.4: Using the $GLOBALS array
    • Exercise 4.4: Using the $GLOBALS array
    • The Single Responsibility Principle
    • Exercise 4.5: Writing a Function that Adds Two Numbers
    • Exercise 4.5: Writing a Function that Adds Two Numbers
    • Variable Functions
    • Exercise 4.6: Working with Anonymous Functions
    • Exercise 4.6: Working with Anonymous Functions
    • Exercise 4.7: Creating Variable Functions
    • Exercise 4.7: Creating Variable Functions
    • Exercise 4.8: Playing with Functions
    • Exercise 4.8: Playing with Functions
    • Activity 4.1: Creating a Calculator
    • Summary
  • 5. Object Oriented Programming

    • Overview
    • The Object Oriented Approach
    • Exercise 5.1: Using the Getter and Setter Methods
    • Exercise 5.1: Using the Getter and Setter Methods
    • Constructor
    • Exercise 5.2: Instantiating the Class and Printing the Details
    • Exercise 5.2: Instantiating the Class and Printing the Details
    • Inheritance
    • Exercise 5.3: Implementing Inheritance
    • Exercise 5.3: Implementing Inheritance
    • Access Modifiers
    • Exercise 5.4: Applying Access Modifiers
    • Exercise 5.4: Applying Access Modifiers
    • Static Fields and Methods
    • Exercise 5.5: Applying a Static Member
    • Exercise 5.5: Applying a Static Member
    • Class Abstraction
    • Exercise 5.6: Implementing an Abstract Class
    • Exercise 5.6: Implementing an Abstract Class
    • Interfaces
    • Exercise 5.7: Implementing an Interface
    • Exercise 5.7: Implementing an Interface
    • Abstract Classes versus Interfaces
    • Overriding
    • Exercise 5.8: Overriding an Inherited Method
    • Exercise 5.8: Overriding an Inherited Method
    • Overloading
    • Exercise 5.9: Implementing Attribute and Method Overloading
    • Exercise 5.9: Implementing Attribute and Method Overloading
    • Final Classes and Methods
    • Exercise 5.10: Implementing a Final Class and Methods
    • Exercise 5.10: Implementing a Final Class and Methods
    • Traits
    • Exercise 5.11: Implementing Trait
    • Exercise 5.11: Implementing Trait
    • Class Autoloading
    • Namespaces
    • Exercise 5.12: Implementing Namespaces
    • Exercise 5.12: Implementing Namespaces
    • Activity 5.1: Building a Student and Professor Object Relationship
    • Summary
  • 6: Using HTTP

    • Overview
    • The Request-Response Cycle of a Web Application
    • Query Strings
    • Exercise 6.1: Dumping the $_SERVER Data
    • Exercise 6.1: Dumping the $_SERVER Data
    • $_COOKIE
    • Exercise 6.2: Setting and Reading a Cookie
    • Exercise 6.2: Setting and Reading a Cookie
    • Exercise 6.3: Writing and Reading Data from a Session
    • Exercise 6.3: Writing and Reading Data from a Session
    • Exercise 6.4: Using Query Strings in Web Pages
    • Exercise 6.4: Using Query Strings in Web Pages
    • Exercise 6.5: Sending and Reading POST Data
    • Exercise 6.5: Sending and Reading POST Data
    • Exercise 6.6: Uploading a File and Validating its Type
    • Exercise 6.6: Uploading a File and Validating its Type
    • Securing Input and Output Data
    • Exercise 6.7: Sanitizing and Validating the User Input
    • Exercise 6.7: Sanitizing and Validating the User Input
    • Escaping the Output
    • Exercise 6.8: Securing against XSS
    • Exercise 6.8: Securing against XSS
    • Cross-Site Request Forgery (CSRF)
    • Exercise 6.9: Securing against CSRF
    • Exercise 6.9: Securing against CSRF
    • Building an Application (Bootstrapping the Examples)
    • Exercise 6.10: Building an Application: The Home Page
    • Exercise 6.10: Building an Application: The Home Page
    • Exercise 6.11: Building an Application: The Profile Page and the Login Form
    • Exercise 6.11: Building an Application: The Profile Page and the Login Form
    • Activity 6.1: Creating a Support Contact Form
    • Summary
    • Survey II
  • 7. Data Persistence

    • Overview
    • File I/O Handling
    • Exercise 7.1: A Simple File Read (All at Once)
    • Exercise 7.1: A Simple File Read (All at Once)
    • Reading Files with the fread Function
    • Exercise 7.2: Reading Files with the fread Function
    • Exercise 7.2: Reading Files with the fread Function
    • Exercise 7.3: Benchmark File Reading
    • Exercise 7.3: Benchmark File Reading
    • Exercise 7.4: Reading Files Line by Line
    • Exercise 7.4: Reading Files Line by Line
    • Exercise 7.5: Reading CSV Files
    • Exercise 7.5: Reading CSV Files
    • Exercise 7.6: Downloading a File
    • Exercise 7.6: Downloading a File
    • Exercise 7.7: Writing to Files
    • Exercise 7.7: Writing to Files
    • Exercise 7.8: Appending Content in Files
    • Exercise 7.8: Appending Content in Files
    • Exercise 7.9: Deleting a File with PHP
    • Exercise 7.9: Deleting a File with PHP
    • Exercise 7.10: Creating Directories and Moving Files to the Archive
    • Exercise 7.10: Creating Directories and Moving Files to the Archive
    • Exercise 7.11: Copying Files
    • Exercise 7.11: Copying Files
    • Databases
    • Exercise 7.12: Connecting to MySQL
    • Exercise 7.12: Connecting to MySQL
    • Exercise 7.13: Creating a Database
    • Exercise 7.13: Creating a Database
    • Creating a Table
    • Exercise 7.14: Creating the Table
    • Exercise 7.14: Creating the Table
    • Exercise 7.15: Inserting Data into a Table
    • Exercise 7.15: Inserting Data into a Table
    • SQL Injection
    • Exercise 7.16: Inserting Data Using Prepared Statements
    • Exercise 7.16: Inserting Data Using Prepared Statements
    • Fetching Data from MySQL
    • Exercise 7.17: Fetching Data from MySQL
    • Exercise 7.17: Fetching Data from MySQL
    • Exercise 7.18: Updating Records in MySQL
    • Exercise 7.18: Updating Records in MySQL
    • Exercise 7.19: Deleting Records from MySQL
    • Exercise 7.19: Deleting Records from MySQL
    • The Singleton Pattern
    • Activity 7.1: Contact Management Application
    • Summary
  • 8. Error Handling

    • Overview
    • Errors in PHP
    • Exercise 8.1: Using a Custom Error Handler
    • Exercise 8.1: Using a Custom Error Handler
    • Exercise 8.2: Logging with the Custom Error Handler
    • Exercise 8.2: Logging with the Custom Error Handler
    • Triggering a User-Level Error
    • Exercise 8.3: Triggering Errors
    • Exercise 8.3: Triggering Errors
    • Logging Errors at Script Shutdown
    • Exercise 8.4: Logging Fatal Errors at Shutdown
    • Exercise 8.4: Logging Fatal Errors at Shutdown
    • Exceptions
    • Exercise 8.5: Implementing Exceptions
    • Exercise 8.5: Implementing Exceptions
    • Exercise 8.6: Custom Exceptions
    • Exercise 8.6: Custom Exceptions
    • Custom Exception Handler
    • Exercise 8.7: Using a Custom Exception Handler
    • Exercise 8.7: Using a Custom Exception Handler
    • Translating Errors to Exceptions
    • Exercise 8.8: Translating Errors to Exceptions
    • Exercise 8.8: Translating Errors to Exceptions
    • Exercise 8.9: Simple Exception Handling
    • Exercise 8.9: Simple Exception Handling
    • Exercise 8.10: Better Usage of Exceptions
    • Exercise 8.10: Better Usage of Exceptions
    • Activity 8.1: Handling System and User-Level Errors
    • Summary
  • 9: Composer

    • Overview
    • Exercise 9.1: Getting Started with Composer
    • Exercise 9.1: Getting Started with Composer
    • Exercise 9.2: Initializing a Project
    • Exercise 9.2: Initializing a Project
    • Exercise 9.3: Adding Dependencies
    • Exercise 9.3: Adding Dependencies
    • Semantic Versioning
    • Exercise 9.4: Applying Version Constraints
    • Exercise 9.4: Applying Version Constraints
    • Exercise 9.5: Re-Installing Vendor File
    • Exercise 9.5: Re-Installing Vendor File
    • Exercise 9.6: Installing Development Dependencies
    • Exercise 9.6: Installing Development Dependencies
    • Packagist
    • Exercise 9.7: Discovering Packages on Packagist.org
    • Exercise 9.7: Discovering Packages on Packagist.org
    • Namespaces
    • Exercise 9.8: Using PSR-4 to Load Classes
    • Exercise 9.8: Using PSR-4 to Load Classes
    • Exercise 9.9: Implementing Monolog
    • Exercise 9.9: Implementing Monolog
    • Activity 9.1: Implementing a Package to Generate a UUID
    • Summary
    • Survey III
  • 10: Web Services

    • Overview
    • An Example Web Service
    • Exercise 10.1: JSON Encoding
    • Exercise 10.1: JSON Encoding
    • HTTP Headers
    • Exercise 10.2: Manual API Testing with Insomnia
    • Exercise 10.2: Manual API Testing with Insomnia
    • Exercise 10.3: Making a GET Request with Guzzle
    • Exercise 10.3: Making a GET Request with Guzzle
    • Exercise 10.4: Sending a POST Request with Headers
    • Exercise 10.4: Sending a POST Request with Headers
    • Activity 10.1: Making Your Own POST Request to httpbin.org
    • Summary
  • 11: PHP Unit

    • Overview
    • Unit Test
    • Exercise 11.1: Installing PHPUnit with PHAR
    • Exercise 11.1: Installing PHPUnit with PHAR
    • Exercise 11.2: Installing PHPUnit with Composer
    • Exercise 11.2: Installing PHPUnit with Composer
    • Exercise 11.3: Setting up a Testing Environment
    • Exercise 11.3: Setting up a Testing Environment
    • Exercise 11.4: Creating a Test Class
    • Exercise 11.4: Creating a Test Class
    • The Three "A"s for Unit Testing
    • Exercise 11.5: Using Assertions with TDD
    • Exercise 11.5: Using Assertions with TDD
    • Configuring PHPUnit with phpunit.xml
    • Exercise 11.6: Using setUp for Tests
    • Exercise 11.6: Using setUp for Tests
    • Logging Results
    • Exercise 11.7: Mock Deleting a Book
    • Exercise 11.7: Mock Deleting a Book
    • Activity 11.1: Creating a Contact Stub and Test
    • Summary
  • Activity Solutions

    • Activity 1.1: Displaying Query Strings in the Browser
    • Activity 1.1: Displaying Query Strings in the Browser
    • Activity 2.1: Printing the BMI of a User
    • Activity 2.1: Printing the BMI of a User
    • Activity 3.1: Creating a Movie Listing Script to Print Movies per Director
    • Activity 3.1: Creating a Movie Listing Script to Print Movies per Director
    • Activity 4.1: Creating a Calculator
    • Activity 4.1: Creating a Calculator
    • Activity 5.1: Building a Student and Professor Object Relationship
    • Activity 5.1: Building a Student and Professor Object Relationship
    • Activity 6.1: Creating a Support Contact Form
    • Activity 6.1: Creating a Support Contact Form
    • Activity 7.1: Contact Management Application
    • Activity 7.1: Contact Management Application
    • Activity 8.1: Handling System and User-Level Errors
    • Activity 8.1: Handling System and User-Level Errors
    • Activity 9.1: Implementing a Package to Generate a UUID
    • Activity 9.1: Implementing a Package to Generate a UUID
    • Activity 10.1: Making Your Own POST Request to httpbin.org
    • Activity 10.1: Making Your Own POST Request to httpbin.org
    • Activity 11.1: Creating a Contact Stub and Test
    • Activity 11.1: Creating a Contact Stub and Test

Get Verified

Complete The PHP Workshop to unlock your certificate.

You can unlock the certificate by completing the course. The credentials are easy to share, and are ideal for displaying on your LinkedIn profile.
A copy of a certificate for The PHP Workshop

Take A Step Forward

There has never been a better time to start learning PHP.

  • $34.99

    $34.99The PHP Workshop

    Unlock one year of full, unlimited access and get started right away!
    Learn for Free

Already Know PHP?

Don't worry, we've got your back with other languages and frameworks too!

Show me my options!