Should spl_object_hash() be deprecated?
spl_object_id() is faster and more memory efficient for object identity checks.
Is there still any real advantage to spl_object_hash() today, or is it mostly legacy compatibility?
spl_object_id() is faster and more memory efficient for object identity checks.
Is there still any real advantage to spl_object_hash() today, or is it mostly legacy compatibility?
I’m thinking about building a PHP c extension for JSONPath querying, inspired by zig-jsonpath.
Example:
<?php
/*
|--------------------------------------------------------------------------
| JSONPath examples
|--------------------------------------------------------------------------
|
| JSONPath allows querying nested JSON values using expressions.
| Similar to XPath but for JSON.
|
*/
$json = '{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
}
}';
/*
|--------------------------------------------------------------------------
| Get all authors
|--------------------------------------------------------------------------
*/
jsonpath_get($json, '$.store.book[*].author');
/*
Result:
[
"Nigel Rees",
"Evelyn Waugh",
"Herman Melville"
]
*/
/*
|--------------------------------------------------------------------------
| Get first book title
|--------------------------------------------------------------------------
*/
jsonpath_get($json, '$.store.book[0].title');
/*
Result:
"Sayings of the Century"
*/
/*
|--------------------------------------------------------------------------
| Recursive search
|--------------------------------------------------------------------------
*/
jsonpath_get($json, '$..price');
/*
Result:
[
8.95,
12.99,
8.99,
19.95
]
*/
/*
|--------------------------------------------------------------------------
| Filter books cheaper than 10
|--------------------------------------------------------------------------
*/
jsonpath_get($json, '$.store.book[?(@.price < 10)]');
/*
Result:
[
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
}
]
*/
/*
|--------------------------------------------------------------------------
| Books with ISBN
|--------------------------------------------------------------------------
*/
jsonpath_get($json, '$.store.book[?(@.isbn)]');
/*
Result:
[
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
}
]
*/
/*
|--------------------------------------------------------------------------
| Get all objects in store
|--------------------------------------------------------------------------
*/
jsonpath_get($json, '$.store.*');
/*
Result:
[
[...books...],
{
"color": "red",
"price": 19.95
}
]
*/
/*
|--------------------------------------------------------------------------
| Array slice
|--------------------------------------------------------------------------
*/
jsonpath_get($json, '$.store.book[:2]');
/*
Result:
First 2 books
*/
/*
|--------------------------------------------------------------------------
| Last book
|--------------------------------------------------------------------------
*/
jsonpath_get($json, '$.store.book[-1]');
/*
Result:
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
}
*/
/*
|--------------------------------------------------------------------------
| Wildcard everything
|--------------------------------------------------------------------------
*/
jsonpath_get($json, '$..*');
/*
Result:
Returns all values recursively
*/
Goals:
Faster than pure PHP
Low memory usage
wildcard/filter support
Maybe query raw JSON without full decoding
Would this be useful for:
1.WordPress
Laravel
API projects
Would love opinions before I start building
I’m working on a PHP 8.6 RFC to convert some invalid-value warnings/notices into consistent ValueError exceptions.
Looking for suggestions, edge cases, and compatibility feedback from the community.
I’m considering building a PHP C extension that reimplements the WordPress hooks system in C. The goal is to reduce overhead from PHP-level execution, potentially achieving ~5x performance improvements and ~2x lower memory usage.
Has anyone explored something similar? What challenges should I expect in terms of compatibility with existing plugins/themes and WordPress internals?
Has anyone here implemented face recognition using PHP only? I’m exploring "mailmug/php-dlib", but not sure how practical it is. Any suggestions or experiences?