What is Safe PHP?
masterSafe PHP (thecodingmachine/safe) is a library that redeclares core PHP functions within the Safe namespace. While standard PHP functions often return false on failure, the Safe variants are designed to throw exceptions instead. This allows for cleaner code by removing the need for explicit false checks and enabling standard try/catch error handling.
Key features:
- All core PHP functions that return
falseon error are available in theSafenamespace. - Provides
Safe\DateTimeandSafe\DateTimeImmutableclasses where methods throw exceptions instead of returningfalse.