Safe
PHP Defer
Our great sponsors
Safe | PHP Defer | |
---|---|---|
7 | 2 | |
2,305 | 278 | |
0.8% | 1.8% | |
0.6 | 3.5 | |
7 days ago | 7 months ago | |
PHP | PHP | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Safe
-
PHP libraries and tools
thecodingmachine/safe: All PHP functions, rewritten to throw exceptions instead of returning false
-
Oh boy here we go again…
There are workarounds with some third party libraries, but yeah, it's a pain.
- Which inconsistences of PHP annoy you the most?
-
Any ideas about why json_encode would return empty for a request on local dev, but not empty on server?
- try not to use the built-in json_encode, as it doesnt have proper error handling. Use instead this: https://github.com/thecodingmachine/safe and Safe\json_encode()
-
Native defer & errdefer
Not what you asked for, in modern codebases it's advised to use things like https://github.com/thecodingmachine/safe
-
Use namespaced functions to replace native functions - github.com/rezen/proxyz
The goal of https://github.com/thecodingmachine/safe is different than proxyz. My goal is a method proxy that allows you to override or watch the behaviour of a function from the "global namespace" effortlessly.
-
preg_last_error() and json_last_error()
Safe-PHP redeclares all core PHP functions (in a new namespace) to throw exceptions properly. I use this on almost every project now.
PHP Defer
- A practical use case of anonymous classes in PHP
-
Native defer & errdefer
php-defer/php-defer: Golang's defer statement for PHP (github.com)
What are some alternatives?
PHP Dotenv - Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
Workerman - An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols.
Symfony VarDumper - Provides mechanisms for walking through any arbitrary PHP variable
React - Event-driven, non-blocking I/O with PHP.
Expose - A beautiful, fully open-source, tunneling service - written in pure PHP
Event - Event package for your app and domain
phpstan-safe-rule - A PHPStan rule to be used with the thecodingmachine/safe package
EventSaucePHP - A pragmatic event sourcing library for PHP with a focus on developer experience.
Symfony Dotenv - Registers environment variables from a .env file
Rx.PHP - Reactive extensions for PHP.
Yo! Symfony TOML - A PHP parser for TOML
Amp - A non-blocking concurrency framework for PHP applications. 🐘