Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

PHP Collective

A collective where developers working with PHP can learn and connect about the open source scripting language.
1.5m Questions
+5
18.4k Members
+24
Contact

Pinned content

View all 3 collections

PHP admins have deemed these posts noteworthy.

Pinned
Score of 63
7467 views
2 minute read
How-to guide

Start learning PHP — Useful resources for beginners and advanced

Start learning PHP — Useful resources for beginners and advanced! If you're wondering where to start from learning the PHP language or needing some more knowledge to deep dive into the language, you ...
Pinned
Score of 44
10195 views
Collection

Common Mistakes to Avoid in PHP

A list of real issues most beginners encounter when using PHP.

Can you answer these questions?

View all unanswered questions

These questions still don't have an answer

Score of 1
0 answers
84 views

PHPUnit Coverage for preg_match

I have this very simple code which I am failing to see how to reach a coverage target of 100%. final class StringValidator { public function matches( string $pattern, string $...
Score of 0
0 answers
111 views

Woocomerce no product found hook not working

I am trying to execute a code on the product attribute page where there are no products this is my page as an example https://shop.mmstore.be/merk/rosso/. The problem is that the hook add_action( '...
Score of 1
0 answers
108 views

Only load content when accordion is expanded - WordPress & Elementor

I'm trying to clean up a client's page list by moving all of their forms (of which they have over 90, and all of them currently live on separate pages) into an accordion on one page using WordPress ...
Score of -1
0 answers
135 views

YouTube Aspera rejects a valid playlist ID returned by YouTube Data API with PLAYLIST_ID_WRONG_FORMAT

We create playlists programmatically using the YouTube Data API v3 (playlists.insert) with the official PHP SDK. Example: $playlist = new Google_Service_YouTube_Playlist(); $playlist->setSnippet($...
Best practices
0 votes
0 replies
104 views

Laravel AI SDK: Best practices of parsing PDF documents

Looking for best practices of Laravel AI SDK: I'm passing an AI agent a document (a Safety Data Sheet for a chemical), and I want a predefined JSON output. Would using a tool in this case be a good ...

Learn something new
These are the most recent articles in PHP Collective
Score of 4
761 views
9 minute read
How-to guide

Quick guide to Laravel package development

Contents Introduction Types of packages Characteristics of a package The Laravel package! Components of a Laravel package Example of a Laravel package Creating your Laravel package 1- Package ...
Score of 3
1216 views
2 minute read
How-to guide

Properly removing API from Laravel project

Sometimes a development team may decide to remove all API functionality from a Laravel project for various reasons, such as: No longer needing any API, and shifting focus to web application with ...
Score of 13
3026 views
1 minute read
How-to guide

How to trim   (or non-breaking space) in PHP?

The main problem is the way trim() function works. One cannot reliably trim a substring using this function, because it takes its second argument as a collection of characters, each of which would be ...
Score of 25
57272 views
3 minute read
Knowledge article

Evolution of Type Declarations in PHP

Introduction: PHP, being a dynamically typed language, traditionally allowed flexibility in variable types, providing both advantages and challenges in code maintenance and robustness. However, with ...
Score of 63
7467 views
2 minute read
How-to guide

Start learning PHP — Useful resources for beginners and advanced

Start learning PHP — Useful resources for beginners and advanced! If you're wondering where to start from learning the PHP language or needing some more knowledge to deep dive into the language, you ...